
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
Angular
The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.
Usage information and reference details can be found in Angular documentation.
License: MIT