microsoft / microsoft/TypeScript

Function's attached JSDoc is not preserved when using OmitThisParameter

Open
#54,783 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🔎 Search Terms

JSDoc, types with docs, preserve docs, OmitThisParameter, bind, inherit description

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about "Something to do with this" and "Strong typing of Function members call/bind/apply"
⏯ Playground Link

Playground link with relevant code

💻 Code
/**
 * This description is lost
 * 
 * @param p As well as this decription
 */
function func(this: {}, p: string): void {}

const f = func as OmitThisParameter<typeof func>;
const g = func.bind({});
🙁 Actual behavior

Hovering over f (or g) shows the type but not the descriptions that were attached to func.

🙂 Expected behavior

f and g to inherit the descriptions of func.

Clarification

The problem mainly lies with OmitThisParameter as bind'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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Playground reproduction and inspect how OmitThisParameter is declared and applied to func, including the bind declaration that uses it. The issue is done when hovering over f and g preserves func's description and @param documentation, with the existing behavior checked against the related #50715 discussion.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.