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

ScriptKind Error with library projects #2538

Open
datstarkey opened this issue Oct 18, 2024 · 1 comment
Open

ScriptKind Error with library projects #2538

datstarkey opened this issue Oct 18, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@datstarkey
Copy link

datstarkey commented Oct 18, 2024

Describe the bug

When working with a library project in a mono repo with the tsconfig module resolution set to : "moduleResolution": "NodeNext", it eventually starts getting this error on the svelte LSP, which eventually seems to cause the TS server or Svelte server to crash at some point and loses all intellisense.

Error: Debug Failure. False expression: Script kind should match provided ScriptKind:3 and sourceFile.scriptKind: 1, !entry: false
    at getDocumentRegistryEntry (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:140976:11)
    at acquireOrUpdateDocument (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:141006:32)
    at Object.updateDocumentWithKey (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:140961:12)
    at getOrCreateSourceFileByPath (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:149933:37)
    at Object.getOrCreateSourceFile (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:149919:14)
    at c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:149840:42
    at Object.getSourceFileWithCache [as getSourceFile] (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:124075:24)
    at findSourceFileWorker (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:126536:23)
    at findSourceFile (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:126452:20)
    at processImportedModules (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:126852:11)

I've only been able to reliably reproduce it by removing the <script lang="ts"> line a svelte component inside the library project, saving and then adding it back, when its referenced by another project.

After doing that, adding a new svelte file will then cause this error to appear.

Error: Could not find source file: '{YOUR FILE PATH HERE}'.
    at getValidSourceFile (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:149757:22)
    at Object.getSyntacticDiagnostics (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\typescript\lib\typescript.js:150016:44)
    at DiagnosticsProviderImpl.getDiagnostics (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\svelte-language-server\dist\src\plugins\typescript\features\DiagnosticsProvider.js:63:32)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:545:9)
    at process.processTimers (node:internal/timers:519:7)
    at async PluginHost.tryExecutePlugin (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\svelte-language-server\dist\src\plugins\PluginHost.js:367:20)
    at async Promise.all (index 2)
    at async PluginHost.execute (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\svelte-language-server\dist\src\plugins\PluginHost.js:344:24)
    at async PluginHost.getDiagnostics (c:\Users\{OMITTED}\.vscode\extensions\svelte.svelte-vscode-109.1.0\node_modules\svelte-language-server\dist\src\plugins\PluginHost.js:47:38)

The only way to resolve this is a extension restart.

Changing to "moduleResolution":"bundler" seems to prevent this way of creating the error, but in one of my larger projects after about 20-30 minutes the same issue crops back up, I just cant reliably recreate it.

Reproduction

https://github.com/datstarkey/svelte-error

instructions in root readme.md on how to recreate

Expected behaviour

A library project should work without any need for a build step during development without needing to restart the extension.

System Info

  • OS: Windows
  • IDE: VSCode
  • Svelte: v5.0.0-next.269

Which package is the issue about?

No response

Additional Information, eg. Screenshots

No response

@datstarkey datstarkey added the bug Something isn't working label Oct 18, 2024
@datstarkey
Copy link
Author

#2534 Seems to related to the same issue

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