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
8 changes: 5 additions & 3 deletions packages/language-server/src/plugins/typescript/service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { dirname, join, resolve, basename } from 'path';
import ts from 'typescript';
import {
DiagnosticSeverity,
PublishDiagnosticsParams,
RelativePattern,
TextDocumentContentChangeEvent
Expand Down Expand Up @@ -803,7 +804,7 @@ async function createLanguageService(
const excludeText = JSON.stringify(exclude);
const svelteConfigDiagnostics: ts.Diagnostic[] = [
{
category: ts.DiagnosticCategory.Error,
category: ts.DiagnosticCategory.Warning,
code: TsconfigSvelteDiagnostics.NO_SVELTE_INPUT,
file: undefined,
start: undefined,
Expand Down Expand Up @@ -977,13 +978,14 @@ async function createLanguageService(
diagnostics: svelteConfigDiagnostics.map((d) => ({
message: d.messageText as string,
range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } },
severity: ts.DiagnosticCategory.Error,
severity: DiagnosticSeverity.Warning,
source: 'svelte'
}))
});
projectConfig.errors = projectConfig.errors
const new_errors = projectConfig.errors
.filter((e) => !codes.includes(e.code))
.concat(svelteConfigDiagnostics);
projectConfig.errors.splice(0, projectConfig.errors.length, ...new_errors);
}

// https://github.com/microsoft/TypeScript/blob/23faef92703556567ddbcb9afb893f4ba638fc20/src/server/project.ts#L1624
Expand Down
16 changes: 13 additions & 3 deletions packages/language-server/src/svelte-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,23 @@ export class SvelteCheck {
};
};

if (lsContainer.configErrors.length > 0) {
if (
lsContainer.configErrors.some((error) => error.category === ts.DiagnosticCategory.Error)
) {
return reportConfigError();
}

const lang = lsContainer.getService();
if (lsContainer.configErrors.length > 0) {
if (
lsContainer.configErrors.some((error) => error.category === ts.DiagnosticCategory.Error)
) {
return reportConfigError();
}

const files = lang.getProgram()?.getSourceFiles() || [];
const options = lang.getProgram()?.getCompilerOptions() || {};

return await Promise.all(
const diagnostics = await Promise.all(
files.map((file) => {
const uri = pathToUrl(file.fileName);
const doc = this.docManager.get(uri);
Expand Down Expand Up @@ -314,6 +318,12 @@ export class SvelteCheck {
})
);

if (lsContainer.configErrors.length) {
diagnostics.push(...reportConfigError());
}

return diagnostics;

function reportConfigError() {
const grouped = groupBy(
lsContainer.configErrors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ export function processInstanceScriptContent(
const tsAst = ts.createSourceFile(
'component.ts.svelte',
scriptContent,
ts.ScriptTarget.Latest,
ts.JSDocParsingMode
? {
languageVersion: ts.ScriptTarget.Latest,
// Exists since TS 5.3
jsDocParsingMode: ts.JSDocParsingMode.ParseNone
}
: ts.ScriptTarget.Latest,
true,
ts.ScriptKind.TS
);
Expand Down