diff --git a/packages/language-server/src/plugins/typescript/service.ts b/packages/language-server/src/plugins/typescript/service.ts index 9ae3a31d2..06a5c2a51 100644 --- a/packages/language-server/src/plugins/typescript/service.ts +++ b/packages/language-server/src/plugins/typescript/service.ts @@ -228,7 +228,16 @@ async function createLanguageService( forcedCompilerOptions, tsconfigPath, undefined, - [{ extension: 'svelte', isMixedContent: false, scriptKind: ts.ScriptKind.TSX }] + [ + { + extension: 'svelte', + isMixedContent: true, + // Deferred was added in a later TS version, fall back to tsx + // If Deferred exists, this means that all Svelte files are included + // in parsedConfig.fileNames + scriptKind: ts.ScriptKind.Deferred ?? ts.ScriptKind.TSX + } + ] ); const compilerOptions: ts.CompilerOptions = { diff --git a/packages/language-server/test/plugins/typescript/features/CompletionProvider.test.ts b/packages/language-server/test/plugins/typescript/features/CompletionProvider.test.ts index ebc3c4c46..a1a79e21a 100644 --- a/packages/language-server/test/plugins/typescript/features/CompletionProvider.test.ts +++ b/packages/language-server/test/plugins/typescript/features/CompletionProvider.test.ts @@ -606,12 +606,12 @@ describe.only('CompletionProviderImpl', () => { item! ); - assert.strictEqual(detail, 'Auto import from ./imported-file.svelte\nclass ImportedFile'); + assert.strictEqual(detail, 'Auto import from ../imported-file.svelte\nclass ImportedFile'); assert.strictEqual( harmonizeNewLines(additionalTextEdits![0]?.newText), // " instead of ' because VSCode uses " by default when there are no other imports indicating otherwise - `${newLine}import ImportedFile from "./imported-file.svelte";${newLine}` + `${newLine}import ImportedFile from "../imported-file.svelte";${newLine}` ); assert.deepEqual( @@ -641,12 +641,12 @@ describe.only('CompletionProviderImpl', () => { item! ); - assert.strictEqual(detail, 'Auto import from ./imported-file.svelte\nclass ImportedFile'); + assert.strictEqual(detail, 'Auto import from ../imported-file.svelte\nclass ImportedFile'); assert.strictEqual( harmonizeNewLines(additionalTextEdits![0]?.newText), // " instead of ' because VSCode uses " by default when there are no other imports indicating otherwise - `${newLine}` );