-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Return type annotation missing error #1146
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
The issue is not no-implicit-any. The problem is the compiler was resolving g the type of Dervived2, that is trying to build a structure for how objects of this type look like. It figured that it has a foo method, then it tried to get the signature for it. Since it does not have a return type annotation, the compiler then needs to look at all return statements to get the return type. In this case it is the type assertion that defines the type. Now here is the issue we do not really know what dervided2 is, cause we were just trying to figure this our. In these situations the compiler breaks the tie by giving it an any type. The warning basically tells you the compiler could not infer the type as you write it and set it to any. An explicit type annotation should do the trick. Hope that helps. |
Hopefully we will eventually figure something more concrete out here, but for now the compiler is still in a recursive type inference situation when it is trying to decide whether or not the operand of the type assertion is assignable to the asserted type, which triggers a 'recursive any'. |
Hi,
VS: 2013 Update 4
TS: 1.3
Here's some code that compiles correctly:
Here's some other code that fails:
I'm aware that a bug with implicit-any and recursive methods has been fixed, but to me it's pretty clear that the return value for
Derived2.foo
isDerived2
.The text was updated successfully, but these errors were encountered: