Reputation: 63
I have a component generated by angular-cli and the resulting code for the .ts file has:
ngOnInit() {
}
instead of
ngOnInit(): void {
}
My tslint is configured to always want typedefs present, but the cli generates code without typedefs - that is my issue.
Is there a way to configure the cli to always set the required typedefs or are my only options are to disable this tslint check or fix it manually?
Upvotes: 6
Views: 3093
Reputation: 12376
Angular CLI uses blueprints to generate artifacts, and there is a directory @angular/cli/blueprints in your node_modules. For example, there is a subfolder component/files/path where you can find a template for the component generation. The Angular CLI team promises to allow creating custom blueprints in the future, but as of today, you can't just modify the template.
If you just need to add void to the method signature, do it manually or disable the corresponding tslint rule.
The other hacky way would be to use the library angular-cli-tools for template generation ( see https://github.com/littleuniversestudios/angular-cli-tools), but since you just want to add the void return type just do it manually.
Upvotes: 5