mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(language-service): account for strictTemplates being enabled by default
We were raising the suggestion about enabling `strictTemplates` when `strictTemplates` is ommitted, however the option is now enabled by default.
Fixes #69905.
(cherry picked from commit e606a020e9)
This commit is contained in:
committed by
Alex Rickabaugh
parent
da08a8fa59
commit
a99fb915c0
@@ -899,7 +899,7 @@ export class LanguageService {
|
||||
project.readFile(path),
|
||||
);
|
||||
|
||||
if (!this.options.strictTemplates) {
|
||||
if (this.options.strictTemplates === false) {
|
||||
diagnostics.push({
|
||||
messageText:
|
||||
'Some language features are not available. ' +
|
||||
|
||||
@@ -107,9 +107,11 @@ describe('language service adapter', () => {
|
||||
});
|
||||
|
||||
describe('compiler options diagnostics', () => {
|
||||
it('suggests turning on strict flag', () => {
|
||||
it('suggests turning on strict flag when strictTemplates is explicitly false', () => {
|
||||
configFileFs.overwriteConfigFile(TSCONFIG, {
|
||||
angularCompilerOptions: {},
|
||||
angularCompilerOptions: {
|
||||
strictTemplates: false,
|
||||
},
|
||||
});
|
||||
const diags = ngLS.getCompilerOptionsDiagnostics();
|
||||
const diag = diags.find(isSuggestStrictTemplatesDiag);
|
||||
@@ -128,6 +130,16 @@ describe('language service adapter', () => {
|
||||
const diag = diags.find(isSuggestStrictTemplatesDiag);
|
||||
expect(diag).toBeUndefined();
|
||||
});
|
||||
|
||||
it('does not suggest turning on strict mode is strictTemplates flag is ommitted', () => {
|
||||
configFileFs.overwriteConfigFile(TSCONFIG, {
|
||||
angularCompilerOptions: {},
|
||||
});
|
||||
const diags = ngLS.getCompilerOptionsDiagnostics();
|
||||
const diag = diags.find(isSuggestStrictTemplatesDiag);
|
||||
expect(diag).toBeUndefined();
|
||||
});
|
||||
|
||||
function isSuggestStrictTemplatesDiag(diag: ts.Diagnostic) {
|
||||
return diag.code === ngErrorCode(ErrorCode.SUGGEST_STRICT_TEMPLATES);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user