Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/language-server/src/plugins/typescript/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
`<script>${newLine}import ImportedFile from "./imported-file.svelte";` +
`<script>${newLine}import ImportedFile from "../imported-file.svelte";` +
`${newLine}${newLine}</script>${newLine}`
);

Expand Down