I have 2 angular components.
ButtonComponent
that has an input of type ButtonText
@Component({
selector: 'app-button',
template: '<h1></h1>',
})
export class ButtonComponent {
@Input() text: ButtonText;
}
export class ButtonText {
constructor(private text: string) {
}
}
And MainComponent
that uses button and passes input to it:
@Component({
selector: 'app-root',
template: '<app-button [text]="title"></app-button>',
})
export class AppComponent {
title = 'compiler-playground';
test: ButtonText = new ButtonText('text');
}
Problem - if I pass a parameter with wrong type to input. ng build
returns no any errors or warnings. I have tried a lot of possible angular compiler flags described [in angular docs]:(https://github.com/angular/angular/blob/master/aio/content/guide/aot-compiler.md#compiler-options)
"angularCompilerOptions": {
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"skipTemplateCodegen": false,
"trace": true,
"debug": true
}
Question: how can I achieve static type checking during compilation? Or maybe there are any static analysis tools that can achieve this such as template linters?