microsoft / microsoft/TypeScript

Declaration merging in plain JS with JSDoc

Open
#57,559 9 comments 0 reactions 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

🔍 Search Terms

jsdoc declaration merging

✅ Viability Checklist
⭐ Suggestion

Ability to merge declarations.

📃 Motivating Example

For example, this is a declaration merge in TS:

export const Foo = makeFooClass()
export type Foo = InstanceType<typeof Foo>

In JS we can't do this. I was hoping for something similar to this to achieve the same:

export const Foo = makeFooClass() // returns a class
/** @export {InstanceType<typeof Foo>} Foo */
💻 Use Cases
  1. What do you want to use this for? To merge declarations in certain cases.
  2. What shortcomings exist with current approaches? There's no way to do it AFAICT
  3. What workarounds are you using in the meantime? None

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 motivating TypeScript and plain JavaScript examples in the issue, then read the discussion to understand the proposed declaration-merging behavior and existing limitations. Done means agreeing on a viable JSDoc design and implementing declaration merging without changing emitted JavaScript or existing runtime behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.