microsoft / microsoft/TypeScript

Cannot specify a JSDoc `@overload` signature using the `@type` tag

Open
#52,368 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback checkJs Domain: JavaScript Domain: JSDoc Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Often, I use @type because the @param + @return syntax is so unwieldy; however, it's not usable with @overload.

// @ts-check

/**
 * @overload
 * @type {(x: number) => number}
 */
/**
 * @type {(x: number) => number}
 */
function id(x) {
    return x;
}

id(123).toFixed(2);
// ~~~ Expected 0 arguments, but got 1.

I'd expect the above not to error; but it does.

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 by reproducing the minimal JavaScript example with @ts-check and the paired JSDoc @overload and @type tags. Trace how the type checker handles @overload declarations using @type, then verify that id(123).toFixed(2) no longer reports an argument-count error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.