-
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
Parameters of overridden methods are made implicit any when using JSDoc @override
#59320
Comments
It isn't. You probably forgot to fill out this section of the issue template. This aligns with the behaviour of TypeScript code. Derived classes don't automatically infer the types based on the base class. This is a duplicate of #23911. |
I did not miss it, I just don't see the significance. You expect the overridden method to automatically infer the argument types as the base, but that's currently not supported, as per the linked issue. That you specify the type with JSDoc instead of TypeScript makes no difference.
I don't see anything of relevance here either. It doesn't even say that the JSDoc of the parent should be inherited. But the team will decide if it's a duplicate or not. :-) |
Unfortunately, even if this deviates from JSDoc documentation, this is "working as intended". This behavior aligns with the behavior of the |
NB: Also not a TS team member, so I have no authority here. Some notes on terminology: A type annotation is when you use a colon followed by the type. Inference is also not the same as type checking. TS can and will check the override for compatibility, but it won't infer the parameter type for you. The I think you might not be happy with this terminology but that's the way these terms are used in TypeScript. Everyone finds the current behavior around Maybe you're asking that specifically |
When you don't have a type annotation it falls back to |
A type annotation is an annotation that provides a type. I can get why the other behavior is desirable but it's just factually not a bug. The code is working the way we wanted it to work when we wrote it. You can disagree with what was wanted! But that doesn't make it a bug. |
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
🔎 Search Terms
"jsdoc @override"
"@override"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/MYGwhgzhAEBCkFMDC4rQN4ChPWgegCoCdcDoABABzACcwBbDCAFxoEsA7AcwF9pmAnpQTQS0MuRoJmAVxocY6Fu248xBPCQBmAex0AKQcICUGMdCmz5-IQhJq1mUJBhIAFmxAATFC+gIAD2YEDi8YeAhkVEVRXEJiXHEKHQA3BBp2LztEjW09Q1tTLESLaTkOG2F7TB4gA
💻 Code
🙁 Actual behavior
The
type
param passed toChildClass.foo
does not inherit thestring
type used in the same method of theBaseClass
and evaluates as implicitany
🙂 Expected behavior
The
type
param passed toChildClass.foo
should inherit thestring
type used in the same method of theBaseClass
Additional information about the issue
This bug is also present when using
@inheritdoc
, which should not be the case.The text was updated successfully, but these errors were encountered: