Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

New Rule: no-inferrable-types #690

Merged
merged 1 commit into from Sep 28, 2015
Merged

New Rule: no-inferrable-types #690

merged 1 commit into from Sep 28, 2015

Conversation

jkillian
Copy link
Contributor

Resolves #676

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") { }
Copy link
Contributor

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).

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #695

@adidahiya
Copy link
Contributor

looks pretty good overall; needs merge conflict resolution

@adidahiya
Copy link
Contributor

still waiting on removal of the typo fix in README

@jkillian
Copy link
Contributor Author

[changes made]

adidahiya added a commit that referenced this pull request Sep 28, 2015
@adidahiya adidahiya merged commit 8e5ebf1 into master Sep 28, 2015
@adidahiya adidahiya deleted the inferrable-types branch September 28, 2015 21:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants