-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
"Implicitly has type 'any'" when type annotation is provided #50864
Comments
The magic words are:
You're initializing
But... There is no type annotation provided. You assume the type can be inferred, but there's no type annotation. A type annotation would look like this: definitelyAString: string = ... The |
The chain of circularity is as follows:
|
Thank you very much @MartinJohns and @RyanCavanaugh for your very kind and complete answers.
without getting errors.
Have a nice day. |
It mentioned the option to add a type annotation in the error message.
As far as I know the compiler would have to be rewritten basically from scratch, and introduce a two-phase type check. Very unlikely to happen. |
There's a good discussion about this in #45213 |
This issue has been marked as 'Not a Defect' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
π Search Terms
implicit any, filter object properties by type, key remapping
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Error: 'definitelyAString' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
π Expected behavior
Since "getString" method has an explicit return type (string), in my opinion "type annotation" is provided, and the error should not be thrown.
The text was updated successfully, but these errors were encountered: