microsoft / microsoft/TypeScript
JSDoc: Typescript is interpreting varargs in function signature as required argument if jsdoc function notation is used in typedef.
Open
Nobody has claimed this yet.
Awaiting More Feedback
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: typescript@3.4.0-dev.20190308
Search Terms: jsdoc, varargs, typedef,
Code
// if I want to use typescript format
// this format is not supported by WebStorm
/** @typedef {(...a2:Array<string>) => void} A */
/** @type {A} */
let a;
a(); // but this works fine with typescript
// if I want to use JSDoc format
// this format is supported by WebStorm
/** @typedef {function(...string):void} B */
/** @type {B} */
let b;
b(); // but this not work, TS2555: Expected at least 1 arguments, but got 0
Expected behavior:
Both formats should be interpreted in same way.
Actual behavior:
test.js:13:1 - error TS2555: Expected at least 1 arguments, but got 0.
13 b(); // but this not work, TS2555: Expected at least 1 arguments, but got 0
~~~
test.js:10:24
10 /** @typedef {function(...string):void} B */
~~~~~~~~~
An argument for '0' was not provided.
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 minimal JavaScript reproduction in the issue and compare TypeScript's handling of the two JSDoc typedef forms, focusing on the varargs parameter and the TS2555 diagnostic. Done means both forms allow calling the resulting function without an argument, with tests covering the equivalent behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100