-
Notifications
You must be signed in to change notification settings - Fork 27k
Open
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerarea: docsRelated to the documentationRelated to the documentationbreaking changescompiler: parserhelp wantedAn issue that is suitable for a community contributor (based on its complexity/scope).An issue that is suitable for a community contributor (based on its complexity/scope).
Milestone
Description
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
Yes
Description
For expression, which can be a valid class field or template variable, a collision may occur when referencing it in a template, for example in or typeof.
If we create something like this:
@Component({
template: `{{ in }}`
})
export class App {
public in = 0;
}
in is treated as an expression instead of a class field. The solution, is to use this.in, then it refers to the field. Unfortunately, this cannot be applied to template variables. Maybe the compiler should handle these cases better and check if a collision can occur in a given context and display a better warning / error.
Bunus points :)
- It seems that
indoes not require anything before or after itself, unliketypeofwhich requires something after itself, for example:
{{ typeof }} // NG5002: Parser Error: Unexpected end of expression: typeof at the end of the expression [ typeof ]
{{ typeof 'value' }} // OK - return 'string'
{{ in }} // OK - return string 'in', but should throw error
{{ 1 in values }} // OK- The documentation is missing information about support for
inandtypeof, for example.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 20.3.10
Node: 20.19.1
Package Manager: npm 10.8.2
OS: linux x64
Angular: 20.3.12
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, router
Package Version
------------------------------------
@angular-devkit/architect 0.2003.10
@angular-devkit/core 20.3.10
@angular-devkit/schematics 20.3.10
@angular/build 20.3.10
@angular/cli 20.3.10
@schematics/angular 20.3.10
rxjs 7.8.2
typescript 5.8.2
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerarea: docsRelated to the documentationRelated to the documentationbreaking changescompiler: parserhelp wantedAn issue that is suitable for a community contributor (based on its complexity/scope).An issue that is suitable for a community contributor (based on its complexity/scope).