-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesHelp WantedYou can do thisYou can do this
Milestone
Description
TypeScript Version: 3.9.0-dev.20200328
Search Terms: JSDoc
A required parameter cannot follow an optional parameter.
Code
/**
* @param {string} password Passphrase
* @param {string} [targetRoomId] Room ID to target a specific room.
* Restores all rooms if omitted.
* @param {object} opts Optional params such as callbacks
*/
function x(password, targetRoomId, opts) {}
x()
Expected behavior:
Generate declaration file:
function x(password: string, targetRoomId?: string, opts?: object): void
Actual behavior:
Generate declaration file:
function x(password: string, targetRoomId?: string, opts: object): void
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ Notice the question mark `?` has gone
// error TS1016: A required parameter cannot follow an optional parameter.
Hover the mouse on the function x
, you can see it's signature is inferred as function x(password: string, targetRoomId?: string, opts: object): void
which is wrong.
sirreal and alshakero
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesHelp WantedYou can do thisYou can do this