3959511b80
The template type checker generates TypeScript expressions for any expression that occurs in a template, so that TypeScript can check it and produce errors. Some expressions as they occur in a template may be translated into TypeScript code multiple times, for instance a binding to a directive input that has a template guard. One example would be the `NgIf` directive, which has a template guard to narrow the type in the template as appropriate. Given the following template: ```typescript @Component({ template: '<div *ngIf="person">{{ person.name }}</div>' }) class AppComponent { person?: { name: string }; } ``` A type check block (TCB) with roughly the following structure is created: ```typescript function tcb(ctx: AppComponent) { const t1 = NgIf.ngTypeCtor({ ngIf: ctx.person }); if (ctx.person) { "" + ctx.person.name; } } ``` Notice how the `*ngIf="person"` binding is present twice: once in the type constructor call and once in the `if` guard. As such, TypeScript will check both instances and would produce duplicate errors, if any were found. Another instance is when the safe navigation operator is used, where an expression such as `person?.name` is emitted into the TCB as `person != null ? person!.name : undefined`. As can be seen, the left-hand side expression `person` occurs twice in the TCB. This commit adds the ability to insert markers into the TCB that indicate that any errors within the expression should be ignored. This is similar to `@ts-ignore`, however it can be applied more granularly. PR Close #34417 |
||
---|---|---|
.circleci | ||
.devcontainer | ||
.github | ||
.vscode | ||
aio | ||
docs | ||
integration | ||
modules | ||
packages | ||
scripts | ||
third_party | ||
tools | ||
.bazelignore | ||
.bazelrc | ||
.clang-format | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.mailmap | ||
.nvmrc | ||
BUILD.bazel | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
LICENSE | ||
README.md | ||
WORKSPACE | ||
browser-providers.conf.js | ||
gulpfile.js | ||
karma-js.conf.js | ||
package.json | ||
protractor-perf.conf.js | ||
shims_for_IE.js | ||
test-events.js | ||
test-main.js | ||
tslint.json | ||
yarn.lock | ||
yarn.lock.readme.md |
README.md
Angular
Angular is a development platform for building mobile and desktop web applications using TypeScript/JavaScript and other languages.
Quickstart
Changelog
Learn about the latest improvements.
Want to help?
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.