-
Notifications
You must be signed in to change notification settings - Fork 887
Conversation
function bar(a = 5, b = true, c = "bah") { } | ||
|
||
// not errors, types are not inferrable | ||
function baz(a: any = 5, b: any = true, c: any = "bah") { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be out of scope for this PR, but I wonder if we can lint for inferrable return types from functions / class methods?
for example, if a function doesn't return
, we infer its return type as void
. we use this convention in our rule walkers (at one point I did a pass and removed a lot of : void
annotations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this as well. We could probably add a feature for functions w/ one return statement where the declared return type is the same as the type of the return statement. Or reduce the scope and only do it for void, string, number, and boolean. But yeah, let's keep that as a separate feature for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, can you file a follow-up issue to track that enhancement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #695
looks pretty good overall; needs merge conflict resolution |
15dc448
to
eb04955
Compare
still waiting on removal of the typo fix in README |
eb04955
to
531daf5
Compare
[changes made] |
New Rule: no-inferrable-types
Resolves #676