Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --listExplicitAny or --warnExplicitAny #13316

Closed
unional opened this issue Jan 6, 2017 · 11 comments
Closed

Add --listExplicitAny or --warnExplicitAny #13316

unional opened this issue Jan 6, 2017 · 11 comments
Labels
Out of Scope This idea sits outside of the TypeScript language design constraints Suggestion An idea for TypeScript

Comments

@unional
Copy link
Contributor

unional commented Jan 6, 2017

Agree with @aluanhaddad in his comment about the backfire effect of --noImplicitAny
#11839 (comment)

It would be nice to add --listExplicitAny or --warnExplicitAny flag to catch those unfortunate circumstances.

Doing a text search for : any may work, but I worry that there may be some case this simple text search is not sufficient.
Since the compiler has all the information needed, it may be better to let the compiler helping out here.

@DanielRosenwasser
Copy link
Member

Would find-all-references on built-in types be sufficient?

@unional
Copy link
Contributor Author

unional commented Jan 6, 2017

Do you mean it is available (or to be made available) in the compiler API or as a flag?

Will find-all-references differentiate between implicit any and explicit any?
^ will probably do not matter because the context of this discussion is to enable --noImplicitAny, thus all any are explicit.

It is probably a better route as it is more generic. 🌷

@DanielRosenwasser
Copy link
Member

It doesn't exist now, but I'd like it to.

Find all references would find explicit annotations and uses of any.

@unional
Copy link
Contributor Author

unional commented Jan 6, 2017

Feel free to change the title to reflect find-all-reference 🌷

@aluanhaddad
Copy link
Contributor

@unional thanks taking up the cause ❤️!

Being able to find all references on any would be great, so I'm all for that, but it would be really nice to have a --warnExplicitAny flag as you suggest in your opening post.
This could raise an error, or offer a codefix, whenever an explicit any adorns a declaration that would not otherwise be an implicit any.

@NN---
Copy link

NN--- commented Jan 11, 2017

You can use TSLint https://palantir.github.io/tslint/rules/no-any/

@unional
Copy link
Contributor Author

unional commented Jan 12, 2017

@NN--- tslint does not allow you to just pass in a rule in the command line.
The purpose of this is to just run a check to see if there are any not appropriated any usage in the code.

In regular development, you would like to have this turned off so it won't distract the developers.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 13, 2017

What about never should we have a flag for it too? what about void in argument position? or undefined in function return positions? what about JSON.parse would it be marked as an error as well? what would be and what would not be..

I do not think we would add a flag like such, this seems to fall in the realm of style/lint tools.

I do support enabling find all references for any (and other primitive types), we disallow them today to avoid noise, but seems artificial.

@mhegazy mhegazy added Out of Scope This idea sits outside of the TypeScript language design constraints Suggestion An idea for TypeScript labels Jan 13, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Jan 13, 2017

Filed #13473 to track find all refs.

@unional
Copy link
Contributor Author

unional commented Feb 7, 2017

Close this as #13566 landed? How to use it?

@mhegazy
Copy link
Contributor

mhegazy commented Feb 7, 2017

#13566 is in, but there is still a bug #13846. should be fixed for 2.2.1

@mhegazy mhegazy closed this as completed Feb 7, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Out of Scope This idea sits outside of the TypeScript language design constraints Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

5 participants