language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

ScriptKind Error with library projects

Open datstarkey opened this issue 1 year ago • 1 comments

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

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 avatar Oct 18 '24 12:10 datstarkey

#2534 Seems to related to the same issue

datstarkey avatar Oct 18 '24 12:10 datstarkey