From 197f3f4a2677f60cc85ac6656d9300927a611500 Mon Sep 17 00:00:00 2001 From: Doug Parker Date: Thu, 20 Jan 2022 10:32:24 -0800 Subject: [PATCH] fix(compiler-cli): remove leftover `_extendedTemplateDiagnostics` requirements (#44777) Refs #42966. There were two remaining places where `_extendedTemplateDiagnostics` needed to be set which should have been removed in #44712 but got missed. This updates them to only require `strictTemplates` and not `_extendedTemplateDiagnostics` so the feature is properly enabled in production. PR Close #44777 --- packages/compiler-cli/src/ngtsc/core/src/compiler.ts | 4 ++-- packages/language-service/test/diagnostic_spec.ts | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts index b7f5a18f837..66650b823fa 100644 --- a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts +++ b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts @@ -446,7 +446,7 @@ export class NgCompiler { diagnostics.push( ...this.getNonTemplateDiagnostics().filter(diag => diag.file === file), ...this.getTemplateDiagnosticsForFile(file, optimizeFor)); - if (this.options._extendedTemplateDiagnostics) { + if (this.options.strictTemplates) { diagnostics.push(...this.getExtendedTemplateDiagnostics(file)); } return this.addMessageTextDetails(diagnostics); @@ -460,7 +460,7 @@ export class NgCompiler { const ttc = compilation.templateTypeChecker; const diagnostics: ts.Diagnostic[] = []; diagnostics.push(...ttc.getDiagnosticsForComponent(component)); - if (this.options._extendedTemplateDiagnostics) { + if (this.options.strictTemplates) { const extendedTemplateChecker = compilation.extendedTemplateChecker; diagnostics.push(...extendedTemplateChecker.getDiagnosticsForComponent(component)); } diff --git a/packages/language-service/test/diagnostic_spec.ts b/packages/language-service/test/diagnostic_spec.ts index f3ad5ace398..20dcd2096c7 100644 --- a/packages/language-service/test/diagnostic_spec.ts +++ b/packages/language-service/test/diagnostic_spec.ts @@ -384,7 +384,7 @@ describe('getSemanticDiagnostics', () => { expect(diags[0].category).toEqual(ts.DiagnosticCategory.Warning); }); - it('should not produce invalid banana in box warning without the required flags', () => { + it('should not produce invalid banana in box warning without `strictTemplates`', () => { const files = { 'app.ts': ` import {Component} from '@angular/core'; @@ -397,7 +397,9 @@ describe('getSemanticDiagnostics', () => { } ` }; - const project = createModuleAndProjectWithDeclarations(env, 'test', files); + const project = createModuleAndProjectWithDeclarations(env, 'test', files, { + strictTemplates: false, + }); const diags = project.getDiagnosticsForFile('app.ts'); expect(diags.length).toEqual(0); @@ -426,7 +428,7 @@ describe('getSemanticDiagnostics', () => { expect(diags[0].category).toEqual(ts.DiagnosticCategory.Warning); }); - it('should not produce invalid banana in box warning in external html file without the required flags', + it('should not produce invalid banana in box warning in external html file without `strictTemplates`', () => { const files = { 'app.ts': ` @@ -441,7 +443,9 @@ describe('getSemanticDiagnostics', () => { `, 'app.html': `
` }; - const project = createModuleAndProjectWithDeclarations(env, 'test', files); + const project = createModuleAndProjectWithDeclarations(env, 'test', files, { + strictTemplates: false, + }); const diags = project.getDiagnosticsForFile('app.html'); expect(diags.length).toEqual(0);