angular-cn/packages/compiler/test/expression_parser
Paul Gschwendtner 3c726c3516 fix(compiler): unclear lexer error when using private identifier in expressions (#42027)
TypeScript supports ECMAScript private identifiers. It can happen that
developers intend to access such members from within an expression.

This currently results in an unclear error from the lexer. e.g.

```
'Parser Error: Unexpected token # at column 1 in [{{#myField}}] in C:/test.ts@5:2
```

We could improve such errors by tokenizing private identifiers similar to
how the TypeScript scanner processes them. Later we can report better
errors in the expression parser or in the typecheck block. This commit
causes all private identifier tokens to be disallowed, so it never
reaches the type checker. This is done intentionally as private
identifiers should not be considered valid Angular syntax, especially
because private fields are not guaranteed to be accessible from within
a component/directive definition (e.g. there cases where a template
function is generated outside of the class; which results in private
members not being accessible; and this results in mixed/confusing
behavior).

Fixes #36003.

PR Close #42027
2021-05-18 10:15:12 -07:00
..
utils refactor(compiler): add an `argumentSpan` to the method call AST (#41581) 2021-04-13 12:39:17 -07:00
BUILD.bazel build: derive ts_library dep from jasmine_node_test boostrap label if it ends in `_es5` (#34736) 2020-01-15 14:58:07 -05:00
ast_spec.ts refactor(compiler): tidy up interpolation splitting (#39717) 2020-11-20 08:35:56 -08:00
lexer_spec.ts fix(compiler): unclear lexer error when using private identifier in expressions (#42027) 2021-05-18 10:15:12 -07:00
parser_spec.ts fix(compiler): unclear lexer error when using private identifier in expressions (#42027) 2021-05-18 10:15:12 -07:00