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

Type definitions are not loaded immediately after tsserver startup when using createAsyncLanguageServicePlugin #254

Closed
mizdra opened this issue Dec 8, 2024 · 4 comments

Comments

@mizdra
Copy link

mizdra commented Dec 8, 2024

Summary

The behavior immediately after tsserver initialization is different between createAsyncLanguageServicePlugin and createLanguageServicePlugin.

In createLanguageServicePlugin, tsserver loads the type definitions of the files that Volar.js processes. However, createAsyncLanguageServicePlugin does not.

How to repdoduce

reproduction: mizdra/playground-volar-typescript-service-plugin@e73b0e1

  1. Checkout mizdra/playground-volar-typescript-service-plugin@e73b0e1
  2. Open workspace on VS Code
  3. When the tsdk switching prompt appears, select "Allow".
  4. Open example/index.ts in the tab
  5. Restart tsserver
2024-12-08.18.38.50.mov

Expected behavior

tsserver loads the type definitions of ts-logo-256.png.

Actual behavior

tsserver does not load the type definitions of ts-logo-256.png. When import specifier is changed, the tsserver loads the type definition.

@mizdra
Copy link
Author

mizdra commented Dec 8, 2024

Is this a bug? Or is this expected behavior? Are there any technical limitations with createAsyncLanguageServicePlugin?

@johnsoncodehk
Copy link
Member

A quick look, createAsyncLanguageServicePlugin relies on using markAsDirty to refresh diagnostics after initialization, the problem may be that markAsDirty is no longer working now. (I haven't tried the repro case yet.)

@johnsoncodehk
Copy link
Member

It seems to be caused by starting from a certain TS version, the module resolved cache of a file will only be updated when the file content is changed. (Still digging for a solution.)

@mizdra
Copy link
Author

mizdra commented Dec 15, 2024

I confirmed that the problem has been fixed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants