Skip to content

Commit d03970f

Browse files
JeanMecheAndrewKushnir
authored andcommitted
refactor(compiler-cli): remove canVisitStructuralAttributes from TemplateCheckWithVisitor (angular#63809)
This enables checking of expressions of structural directives in template diagnostics. PR Close angular#63809
1 parent dd2f53b commit d03970f

File tree

3 files changed

+2
-18
lines changed
  • packages/compiler-cli/src/ngtsc/typecheck/extended

3 files changed

+2
-18
lines changed

packages/compiler-cli/src/ngtsc/typecheck/extended/api/api.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,6 @@ export interface TemplateCheckFactory<
8383
export abstract class TemplateCheckWithVisitor<Code extends ErrorCode>
8484
implements TemplateCheck<Code>
8585
{
86-
/**
87-
* When extended diagnostics were first introduced, the visitor wasn't implemented correctly
88-
* which meant that it wasn't visiting the `templateAttrs` of structural directives (e.g.
89-
* the expression of `*ngIf`). Fixing the issue causes a lot of internal breakages and will likely
90-
* need to be done in a major version to avoid external breakages. This flag is used to opt out
91-
* pre-existing diagnostics from the correct behavior until the breakages have been fixed while
92-
* ensuring that newly-written diagnostics are correct from the beginning.
93-
* TODO(crisbeto): remove this flag and fix the internal brekages.
94-
*/
95-
readonly canVisitStructuralAttributes: boolean = true;
96-
9786
abstract code: Code;
9887

9988
/**
@@ -153,11 +142,8 @@ class TemplateVisitor<Code extends ErrorCode> extends CombinedRecursiveAstVisito
153142

154143
this.visitAllTemplateNodes(template.directives);
155144

156-
// TODO(crisbeto): remove this condition when deleting `canVisitStructuralAttributes`.
157-
if (this.check.canVisitStructuralAttributes || isInlineTemplate) {
158-
// `templateAttrs` aren't transferred over to the inner element so we always have to visit them.
159-
this.visitAllTemplateNodes(template.templateAttrs);
160-
}
145+
// `templateAttrs` aren't transferred over to the inner element so we always have to visit them.
146+
this.visitAllTemplateNodes(template.templateAttrs);
161147

162148
this.visitAllTemplateNodes(template.variables);
163149
this.visitAllTemplateNodes(template.references);

packages/compiler-cli/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {TemplateCheckFactory, TemplateCheckWithVisitor, TemplateContext} from '.
2121
* otherwise it would produce inaccurate results.
2222
*/
2323
class NullishCoalescingNotNullableCheck extends TemplateCheckWithVisitor<ErrorCode.NULLISH_COALESCING_NOT_NULLABLE> {
24-
override readonly canVisitStructuralAttributes = false;
2524
override code = ErrorCode.NULLISH_COALESCING_NOT_NULLABLE as const;
2625

2726
override visitNode(

packages/compiler-cli/src/ngtsc/typecheck/extended/checks/optional_chain_not_nullable/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {TemplateCheckFactory, TemplateCheckWithVisitor, TemplateContext} from '.
2828
* otherwise it would produce inaccurate results.
2929
*/
3030
class OptionalChainNotNullableCheck extends TemplateCheckWithVisitor<ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE> {
31-
override readonly canVisitStructuralAttributes = false;
3231
override code = ErrorCode.OPTIONAL_CHAIN_NOT_NULLABLE as const;
3332

3433
constructor(private readonly noUncheckedIndexedAccess: boolean) {

0 commit comments

Comments
 (0)