knowledge
knowledge copied to clipboard
Extend typedef rule to support arrow functions
Motivation
When defining functions, that are actually constants using arrow function, current typecheck does not check whether those functions have return type
Proposal
I suggest extending typedef rule to support arrow-call-signature
...
"typedef": [
true,
"call-signature",
"parameter",
"arrow-call-signature"
],
...
Impact
This will mean that functions defined following way will need to have return type
const uselessFunction = (text: string) => {
return 'I am super useless'
};
Should be:
const uselessFunction = (text: string): string => {
return 'I am super useless'
};
Pros
Improved code readability
Links and References
https://palantir.github.io/tslint/rules/typedef/
I've implemented it on the website and it requires tslint ignore comment to the *.routing.ts as with "new" routing syntax
{
path: 'wololo',
loadChildren: () => // <-- here it wants a typing
import('./wololo/wololo.module').then(m => m.WololoModule),
},
I'd recommend using // tslint:disable: typedef on these "routing" files