base on Alex Rickabaugh's doc
{
"compilerOptions": {
...
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
}
}
<div *ngIf="someFlag">
{{childViewExp.wrongProp}}
</div>
interface ChildViewExp {
correctProp: string;
}
@Component({
...
})
export class SampleComponent implements OnInit {
childViewExp: ChildViewExp = {correctProp: 'test'};
constructor() {}
ngOnInit() {}
}
<div *ngIf="someFlag">
{{childViewExp.wrongProp}}
</div>
fullTemplateTypeCheck | ViewEngine | Ivy |
---|---|---|
false | doesn't check | Same with VE |
true | check type in expression | Same with VE |
<lib-sample-lib [libInput]="libInputWrapper.input"></lib-sample-lib>
fullTemplateTypeCheck | ViewEngine | Ivy |
---|---|---|
false | doesn't check | Same with VE |
true | check type in expression | 1. Check type in expression 2. Check the value of expression assignable to input or not |
<img [src]="image.url">
<img [src]="image.size">
fullTemplateTypeCheck | ViewEngine | Ivy |
---|---|---|
false | doesn't check | Same with VE |
true | check type in expression | 1. Check type in expression 2. Check the value of expression assignable to input or not? |
<img [src]="(image$ | async).url">
<img [src]="(image$ | async).urll">
fullTemplateTypeCheck | ViewEngine | Ivy |
---|---|---|
false | doesn't check | Same with VE |
true | check type of the return value of the pipe | Same with VE |
<lib-sample-lib (libOutput)="libOutputEmitted($event)"></lib-sample-lib>
fullTemplateTypeCheck | ViewEngine | Ivy |
---|---|---|
false | $event will be any | Same with VE |
true | $event will be any | $event will be the exact type produced by EventEmitter? |
<button (click)="btnClicked($event)"></button>
fullTemplateTypeCheck | ViewEngine | Ivy |
---|---|---|
false | $event will be any | Same with VE |
true | $event will be any | Same with VE |
<li *ngFor="let item of items">
{{item.wrongProp}}
</li>
fullTemplateTypeCheck | ViewEngine | Ivy |
---|---|---|
false | will not check | Same with VE |
true | item will be any | item will be the exact type |
<component #ref></component>
{{ref.something}}
fullTemplateTypeCheck | ViewEngine | Ivy |
---|---|---|
false | ref will be any | Same with VE (now has bug) |
true | ref will be the component type | Same with VE |
<input #ref>
{{ref.wrongValue}}
fullTemplateTypeCheck | ViewEngine | Ivy |
---|---|---|
false | ref will be any | Same with VE (now has bug) |
true | ref will be any | ref will be the exact type of the element (in this case will be HTMLInputElement) |
@Directive({
selector: '[dir]', exportAs: 'dir',
})
export class Dir<T> {
@Input() dir!: T;
field: T;
}
<div [dir]="3" #ref="dir">{{ref.field.length}}</div>
fullTemplateTypeCheck | ViewEngine | Ivy |
---|---|---|
false | ref will be any | Same with VE (now has bug) |
true | ref will be any | ref will be the exact type of the dir |