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

VSCode shows error/any for generated types #2053

Closed
probablykasper opened this issue Jun 12, 2023 · 4 comments
Closed

VSCode shows error/any for generated types #2053

probablykasper opened this issue Jun 12, 2023 · 4 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@probablykasper
Copy link

probablykasper commented Jun 12, 2023

Describe the bug

SvelteKit generated types often don't work correctly with VSCode. It could be a bigger issue than just with Locals, I'm not sure.

In my production repo I have a +layout.ts which receives
In the reproduction repo I have a +layout.ts which receives data from +layout.server.ts.

If I open +layout.ts in VSCode, it shows the data type as any:

{
    session: any;
}

Then if I open the +layout.server.ts, it shows the reason for that:
image

If I just update +layout.server.ts, the error goes away and the types are correct in both files.

Reproduction

Repo: https://github.com/probablykasper/sveltekit-generated-any

Screen.Recording.2023-06-12.at.07.32.37.mp4

Expected behaviour

The type error shouldn't happen. If some error like this does happen, it would be nice to avoid silently using any and instead provide some hint that there's an error somewhere

System Info

  • OS: [e.g. Windows]
  • IDE: [e.g. VSCode, Atom]

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

Tested with a fresh VSCode instance, with only the Svelte for VSCode extension

@probablykasper probablykasper added the bug Something isn't working label Jun 12, 2023
@mvartuc
Copy link

mvartuc commented Jul 23, 2023

Any update on this? I'm having the same issue, haven't found a workaround so far.

@gterras
Copy link

gterras commented Aug 28, 2023

Doesn't seem limited to VSC by the way, same issue on Sublime.

@MystPi
Copy link

MystPi commented Sep 7, 2023

I consistently have this problem every time I open a file that uses auto-generated types. While the issue goes away after editing the file, it would be better if this didn't happen at all.

@einarpersson
Copy link

I wrote about this here sveltejs/kit#10703

I am having this problem on a daily basis to such an extent that it is unusable. My impression is that it has increased in frequency (or maybe it is just my app that has grown, which amplifies the problem).

Any update / work on this?

dummdidumm pushed a commit that referenced this issue Sep 19, 2023
#2053

If a file is patched the first time, typescript might have cached the unpatched version. It won't update even if we return the patched version in getScriptSnapshot. This should only happen to files the client opens after the first compilation of the proxy language service. In the first compilation, there won't be any files in the cache. And once there are any updates TypeScript will reparse the file with the patched snapshot.
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

6 participants