Skip to content

Support JSDoc @function #14275

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

Open
mjbvz opened this issue Feb 23, 2017 · 2 comments
Open

Support JSDoc @function #14275

mjbvz opened this issue Feb 23, 2017 · 2 comments
Labels
Committed The team has roadmapped this issue Domain: JSDoc Relates to JSDoc parsing and type generation Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Milestone

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Feb 23, 2017

From: microsoft/vscode#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

@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Feb 23, 2017
@mjbvz
Copy link
Contributor Author

mjbvz commented Feb 24, 2017

Also, the param name and param description from the jsdoc should override those from the *.d.ts file. For example, if the code were :

/** 
 * @function
 * @param {number} myNewParamName Description of param
 * @returns {number} result
 */
const thisDoesNot = func(1);

For signature help on thisDoesNot, we'd want to show the information provided by the jsdoc for myNewParamName

@mhegazy mhegazy changed the title JSDoc Should Override type from d.ts in JavaScript files Support JSDoc @function May 16, 2017
@mhegazy mhegazy added Domain: JSDoc Relates to JSDoc parsing and type generation Suggestion An idea for TypeScript labels May 16, 2017
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.2 milestone Aug 15, 2018
@RyanCavanaugh RyanCavanaugh added the Committed The team has roadmapped this issue label Aug 15, 2018
@sandersn sandersn modified the milestones: TypeScript 3.4.0, Backlog Mar 12, 2019
@sandersn sandersn removed their assignment Jan 7, 2020
@sandersn
Copy link
Member

sandersn commented Aug 25, 2020

We should actually treat any @param/@return on a variable declaration as a type annotation. If we do that, I don't think that @function needs any special support.

#36633 requests this behaviour, and #31313 implies that it wants this behaviour for @class and several other tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Domain: JSDoc Relates to JSDoc parsing and type generation Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants