question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Each Block Typing Issue

See original GitHub issue

I’m trying to iterate over a properties values by using {#each…}, and I have two typings (this is a TypeScript project) in my Svelte component.

<script lang="ts">
    import Transition from './Transition/Transition.svelte';

    type Options = { text: string, value?: string }[];
    type OptionsGroup = Options[];

    export let options: Options | OptionsGroup = [];
</script>

{#each options as option}
    <div>example</div>
{/each}

I would expect the type of option in the each statement to be Options | OptionsGroup but VS Code is giving me an error saying:

Argument of type ‘Options | OptionsGroup’ is not assignable to parameter of type ‘ArrayLike<{ text: string; value?: string; }>’.

I’m unsure of what exactly is going wrong as the build and dev tasks are working fine with no errors at all, it only seems to be an issue with VS Code.

System:

  • OS: Manjaro (Linux)
  • IDE: VSCode
  • Plugin/Package: Svelte for VSCode

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
JAD3Ncommented, Jan 6, 2021

Thank you for the clarification, I’ve amended my typings as recommend and that has pretty much solved it.

1reaction
dummdidummcommented, Jan 5, 2021

@dkzlv that’s #619

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Solve Common Keyboard and Typing Problems
Here are answers to some of the most common typing problems, from disappearing text to jumping cursors.
Read more >
Windows will not allow typing in the search or info blocks.
On my Laptop, latest Windows 10 Update installed. I have an issue that I can not input any information that requires typing!
Read more >
Keyboard Gone Mad and Typing on Its Own? 6 Ways to Fix It ...
To prevent this, open the keyboard keys that are being pressed automatically and clean underneath them. This may resolve the problem. Subscribe ...
Read more >
Unable to type in existing blocks in a Column - WordPress.org
I can reproduce the problem by placing the cursor anywhere within the text and pressing Shift while I click elsewhere in the text....
Read more >
iOS 8 update causes keyboard to block text. Annoying!
to iOS 8 there have been issues with the keyboard blocking the text while typing and scrolling. It gets to a point where...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found