-
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
Function's attached JSDoc is not preserved when using OmitThisParameter #54783
Comments
I'd say this is definitely a "missing feature". For any arbitrary type definition type X<T, U> = // whatever there aren't any rules for whether JS Doc should show what (if anything) is on |
Although the general case would be awesome to have, it would be non-trivial to determine its resulting JS Doc. |
It isn’t though because |
It can be changed into an I would understand if this isn't a path the TypeScript team would like to take 😅 |
It looks like my test case above was misleading as it depends on having assignments that preserve the docs (which I believe is not supported). I think the following code better demonstrates the issue: const F = {
/**
* This description is lost
*/
foo(this: string): void {},
};
const a: { [K in keyof typeof F]: OmitThisParameter<typeof F[K]> } = {} as any;
const b: { [K in 'foo']: OmitThisParameter<typeof F[K]> } = {} as any;
const c: { foo: OmitThisParameter<typeof F['foo']> } = {} as any;
a.foo(); // <- doc preserved ✅
b.foo(); // <- doc NOT preserved ❌
c.foo(); // <- doc NOT preserved ❌ Why is the description preserved in the case of Note: The description is preserved in all three cases when not using |
Bug Report
🔎 Search Terms
JSDoc, types with docs, preserve docs, OmitThisParameter, bind, inherit description
🕗 Version & Regression Information
this
" and "Strong typing ofFunction
memberscall
/bind
/apply
"⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Hovering over
f
(org
) shows the type but not the descriptions that were attached tofunc
.🙂 Expected behavior
f
andg
to inherit the descriptions offunc
.Clarification
The problem mainly lies with
OmitThisParameter
asbind
's declaration uses it.I'm also not sure if this is considered a bug or a missing feature, so I apologize in advance if this is not the right way to report it.
Might be related to #50715
The text was updated successfully, but these errors were encountered: