Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is this line marked as error? #2556

Open
dm-de opened this issue Nov 2, 2024 · 0 comments
Open

Why is this line marked as error? #2556

dm-de opened this issue Nov 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dm-de
Copy link

dm-de commented Nov 2, 2024

Describe the bug

<script>
	let { array = [] } = $props()
	let array2 = $derived(array.filter(i => !i.hidden))
</script>

In this short example, filter is marked red
'array' is of type 'unknown'.

For example, when I use next code in TS playground, it will not mark array or filter as error. Expected errors are $props() and i. But not arary or filter.

let { array = [] } = $props()
array.filter(i => !i.hidden) 

My configuration:
installed using Vite (fresh installation)
but not Svelte kit
just JS Svelte 5 (newest)
or even TS (no difference)
newest Svelte extension for VS code
newest VS Code update

Such error come up with Svelte 5 first (Svelte 4 show no errors).
I hoped all the time that this will be fixed with final v5.

I played with checkJS - or ts-nocheck.
But this will hide any error.

sv3

Reproduction

<script>
	let { array = [] } = $props()
	let array2 = $derived(array.filter(i => !i.hidden))
</script>

Expected behaviour

no error

System Info

  • OS: Windows
  • IDE: VSCode

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

@dm-de dm-de added the bug Something isn't working label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant