microsoft / microsoft/TypeScript
Named function arguments not supported in JSDOC
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
Does this issue occur when all extensions are disabled?: Yes
Version: 1.84.2 (user setup)
Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
Date: 2023-11-09T10:51:52.184Z
Electron: 25.9.2
ElectronBuildId: 24603566
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.22621
While defining a function type in JSDOC, if a name if provided for the argument, TypeScript fails to recognize it.
Steps to Reproduce:
This is a snippet of sample code that works and does not work.
The first typedef does not include an argument name, IntelliSense refers to the argument as arg0.
The second typedef does include an argument name, and TypeScript flags it as an error.
/**
* @typedef {function(string ): Promise<string>} IdoRequestFunction
*/
/** @type IdoRequestFunction */
export default async function request(idoRequest) {
return idoRequest;
}
/**
* @typedef {function(idoRequest:string ): Promise<string>} IdoRequestFunctionX
*/
/** @type IdoRequestFunction */
export async function requestX(idoRequest) {
return idoRequest;
}
Thank you for your assistance.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied JavaScript/JSDoc reproduction and trace how TypeScript parses and checks function types with named parameters. Done means the named argument is accepted without an error and IntelliSense uses that name instead of arg0.
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
- 45/100