-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Can't infer from this
type on static class method call in JS Doc
#50952
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
any
and this inferred any
fails to generate any noImplicitAny
errorsthis
, the type inferred is any
and this inferred any
fails to generate any noImplicitAny
errors
Did this get missed? |
this
, the type inferred is any
and this inferred any
fails to generate any noImplicitAny
errorsthis
type on static class method call in JS Doc
This can be vastly simplified: export class Test {
/**
* @template C
* @this {C}
* @return {C}
*/
static test() {
return this;
}
}
// p: any, should be p: typeof Test
const p = Test.test(); |
@RyanCavanaugh Yeah, I tried simplifying it further, but wasn't quite able to get it that simple. 😅 |
@RyanCavanaugh It seems that the problem is not limited to static methods. export class Test {
/**
* @template T
* @this {T}
* @return {T}
*/
test() {
return this;
}
}
const t = new Test();
const p = t.test(); // any?
p; I think it's because |
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
💻 Code
JavaScript:
Compiler Options
Playground Link: Provided
TypeScript:
Output
Compiler Options
Playground Link: Provided
🙁 Actual behavior
The inferred type for
handle
to in the JS version isany
, and the--noImplicitAny
option is not respected.🙂 Expected behavior
The inferred type for
handle
to benumber
for both, as the types are fully equivalent.The text was updated successfully, but these errors were encountered: