Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
disable semantic errors in js tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbirtles committed May 5, 2019
1 parent 500556e commit 644261b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/plugins/TypeScriptPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,19 @@ export class TypeScriptPlugin
}

const lang = getLanguageServiceForDocument(document, this.createDocument);
const syntaxDiagnostics = lang.getSyntacticDiagnostics(document.getFilePath()!);
const semanticDiagnostics = lang.getSemanticDiagnostics(document.getFilePath()!);
return [...syntaxDiagnostics, ...semanticDiagnostics].map(diagnostic => ({
const isTypescript =
getScriptKindFromAttributes(document.getAttributes()) === ts.ScriptKind.TS;

let diagnostics: ts.Diagnostic[] = lang.getSyntacticDiagnostics(document.getFilePath()!);

if (isTypescript) {
diagnostics.push(...lang.getSemanticDiagnostics(document.getFilePath()!));
}

return diagnostics.map(diagnostic => ({
range: convertRange(document, diagnostic),
severity: DiagnosticSeverity.Error,
source:
getScriptKindFromAttributes(document.getAttributes()) === ts.ScriptKind.TS
? 'ts'
: 'js',
source: isTypescript ? 'ts' : 'js',
message: ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'),
}));
}
Expand Down

0 comments on commit 644261b

Please sign in to comment.