tomblachut / svelte-intellij

Svelte components in WebStorm and friends
MIT License
485 stars 38 forks source link

Default values of generic type parameters not applied properly #288

Closed tmarsik42 closed 2 years ago

tmarsik42 commented 2 years ago

I noticed some generic types are not referenced properly in svelte files, if they have default value.

I'll include some code snippets to better illustrate what I'm talking about.

Examples are taken from urql. From operationStore.d.ts

export interface OperationStore<Data = any, Vars = any, Result = Data>

AFAIU, if not specified, third generic (Result) is supposed to be the same type as the first one (Data).

something.svelte

Snímek obrazovky 2022-05-05 v 19 14 08

As you can see in screenshot, if I specify two generics in svelte file, I get unreferenced third generic Data that is the culprit of unresolved variable errors I get in Webstorm.

Now if I do the same in standalone ts file something.ts I get correct types.

Snímek obrazovky 2022-05-05 v 19 19 06

At first I thought it's a problem with tsconfig or something, but in VSCode, I get the same result in svelte file as in Webstorm in typescript file.

Snímek obrazovky 2022-05-05 v 19 24 01

edit: It's also interesting that inferred typing in svelte files works correctly

Snímek obrazovky 2022-05-05 v 19 28 51
tmarsik42 commented 2 years ago

This was resolved for me in Webstorm 2022.1.2 with typescript improvements https://blog.jetbrains.com/webstorm/2022/06/webstorm-2022-1-2/

tomblachut commented 2 years ago

@tmarsik42 That's great to hear, thanks for confirming,