-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[no-inferrable-types] Add an option to enable it for any values #907
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
Comments
Doesn't
|
No, none of the cases listed there are handled by Wouldn't it be possible to make it require type checker only when a new option is enabled? |
I don't think this belongs in In your case, functions aren't easily identifiable because you need to inspect their return type. |
Makes sense, would it worth it to rename it then? Maybe to something like
Type assertion has a strict definition in typescript docs, so I think that may make it a bit confusing. Maybe it would make sense to rename it to |
Mmmm I always think of it as "explicit type assertion" ( Flip flopping a bit, sorry, but yeah if we're being correct with the terminology, I guess it probably does just belong in Thinking about it more TBH |
Is this a duplicate of #295? |
actually, I think it is - good catch. |
Currently this rule warns only when rhs is either a literal or an associated global constructor function. I'd like to have an option to warn about any cases when type annotation doesn't change variable type.
I've done a bit of testing and apparently equal types have the same reference (even in the
invalid2
case), so something liketypeChecker.getTypeAtLocation(typeAnnotation) === typeChecker.getTypeAtLocation(initializer)
can be enough to check this.The text was updated successfully, but these errors were encountered: