microsoft / microsoft/TypeScript

Support JSDoc `@function`

Open
#14,275 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Committed Domain: JSDoc Suggestion VS Code Tracked
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

From: https://github.com/Microsoft/vscode/issues/21321

TypeScript Version: 2.2.1 / nightly (2.2.0-dev.201xxxxx)

Code

// test-module.d.ts
declare module 'test-module' {
    declare function func<T>(c: T): (y: any) => any;
}
// example.js
import { func } from 'test-module';

/** 
 * @function
 * @param {number} c first number
 * @returns {number} result
 */
const thisDoesNot = func(1);

Expected behavior:
The JSDoc specifications give thisDoesNot a type of (c: number) => number

Actual behavior:
The type from the *.d.ts file is preferred instead, giving thisDoesNot a type of (c: any) => any

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

Reproduce the issue with the shown test-module.d.ts and example.js snippets, then trace TypeScript's JSDoc @function handling and how imported declaration types are selected. Done means the JSDoc annotations produce (c: number) => number for thisDoesNot without regressing normal declaration-file typing.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Feature
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.