refactor(compiler): cleanup complier flags

- checkQueries was unused
- use explicit `true` for the flags that are enabled by `strictTemplates`.

(cherry picked from commit 516170741d)
This commit is contained in:
Matthieu Riegler
2026-09-28 21:57:12 +00:00
committed by Andrew Scott
parent a6e6097b3d
commit 82a930db40
4 changed files with 11 additions and 21 deletions
@@ -1089,33 +1089,32 @@ export class NgCompiler {
let typeCheckingConfig: TypeCheckingConfig;
if (strictTemplates) {
typeCheckingConfig = {
applyTemplateContextGuards: strictTemplates,
checkQueries: false,
applyTemplateContextGuards: true,
checkTemplateBodies: true,
alwaysCheckSchemaInTemplateBodies: true,
checkTypeOfInputBindings: strictTemplates,
checkTypeOfInputBindings: true,
honorAccessModifiersForInputBindings: false,
checkControlFlowBodies: true,
strictNullInputBindings: strictTemplates,
checkTypeOfAttributes: strictTemplates,
strictNullInputBindings: true,
checkTypeOfAttributes: true,
// Even in full template type-checking mode, DOM binding checks are not quite ready yet.
checkTypeOfDomBindings: false,
checkTypeOfOutputEvents: strictTemplates,
checkTypeOfAnimationEvents: strictTemplates,
checkTypeOfOutputEvents: true,
checkTypeOfAnimationEvents: true,
// Checking of DOM events currently has an adverse effect on developer experience,
// e.g. for `<input (blur)="update($event.target.value)">` enabling this check results in:
// - error TS2531: Object is possibly 'null'.
// - error TS2339: Property 'value' does not exist on type 'EventTarget'.
checkTypeOfDomEvents: strictTemplates,
checkTypeOfDomEvents: true,
checkUnclaimedEventNames: false, // 3p-only
// g3-only checkUnclaimedEventNames: strictTemplates,
checkTypeOfDomReferences: strictTemplates,
// g3-only checkUnclaimedEventNames: true,
checkTypeOfDomReferences: true,
// Non-DOM references have the correct type in View Engine so there is no strictness flag.
checkTypeOfNonDomReferences: true,
// Pipes are checked in View Engine so there is no strictness flag.
checkTypeOfPipes: true,
strictSafeNavigationTypes: strictTemplates,
useContextGenericType: strictTemplates,
strictSafeNavigationTypes: true,
useContextGenericType: true,
strictLiteralTypes: true,
enableTemplateTypeChecker: this.enableTemplateTypeChecker,
useInlineTypeConstructors,
@@ -1129,7 +1128,6 @@ export class NgCompiler {
} else {
typeCheckingConfig = {
applyTemplateContextGuards: false,
checkQueries: false,
checkTemplateBodies: false,
checkControlFlowBodies: false,
// Enable deep schema checking in "basic" template type-checking mode only if Closure
@@ -1170,7 +1170,6 @@ describe('type check blocks', () => {
];
const BASE_CONFIG: TypeCheckingConfig = {
applyTemplateContextGuards: true,
checkQueries: false,
checkTemplateBodies: true,
checkControlFlowBodies: true,
alwaysCheckSchemaInTemplateBodies: true,
@@ -282,7 +282,6 @@ export function ngForTypeCheckTarget(): TypeCheckingTarget {
export const ALL_ENABLED_CONFIG: Readonly<TypeCheckingConfig> = {
applyTemplateContextGuards: true,
checkQueries: false,
checkTemplateBodies: true,
checkControlFlowBodies: true,
alwaysCheckSchemaInTemplateBodies: true,
@@ -442,7 +441,6 @@ export function tcb(
const fullConfig: TypeCheckingConfig = {
applyTemplateContextGuards: true,
checkQueries: false,
checkTypeOfInputBindings: true,
honorAccessModifiersForInputBindings: false,
strictNullInputBindings: true,
-5
View File
@@ -252,11 +252,6 @@ export interface TypeCheckingConfig {
*/
alwaysCheckSchemaInTemplateBodies: boolean;
/**
* Whether to check resolvable queries.
*/
checkQueries: false;
/**
* Whether to check if control flow syntax will prevent a node from being projected.
*/