Skip to content

Commit 6ac209c

Browse files
clydinthePunderWoman
authored andcommitted
fix(language-service): avoid generating TS suggestion diagnostics for templates (#56241)
Angular's template files are not valid TypeScript. Attempting to get suggestion diagnostics from the underlying TypeScript language service will result in a large amount of false positives. Only actual TypeScript files should be analyzed by the underlying TypeScript language service for suggestions. PR Close #56241
1 parent 0c72976 commit 6ac209c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/language-service/src/ts_plugin.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
3838
return [];
3939
}
4040

41+
function getSuggestionDiagnostics(fileName: string): ts.DiagnosticWithLocation[] {
42+
if (!angularOnly && isTypeScriptFile(fileName)) {
43+
return tsLS.getSuggestionDiagnostics(fileName);
44+
}
45+
46+
// Template files do not currently produce separate suggestion diagnostics
47+
return [];
48+
}
49+
4150
function getSemanticDiagnostics(fileName: string): ts.Diagnostic[] {
4251
const diagnostics: ts.Diagnostic[] = [];
4352
if (!angularOnly && isTypeScriptFile(fileName)) {
@@ -311,6 +320,7 @@ export function create(info: ts.server.PluginCreateInfo): NgLanguageService {
311320
...tsLS,
312321
getSyntacticDiagnostics,
313322
getSemanticDiagnostics,
323+
getSuggestionDiagnostics,
314324
getTypeDefinitionAtPosition,
315325
getQuickInfoAtPosition,
316326
getDefinitionAtPosition,

0 commit comments

Comments
 (0)