Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5567,6 +5567,9 @@ namespace ts {
if (isJSDocNonNullableType(node)) {
return visitNode(node.type, visitExistingNodeTreeSymbols);
}
if (isJSDocVariadicType(node)) {
return createArrayTypeNode(visitNode((node as JSDocVariadicType).type, visitExistingNodeTreeSymbols));
}
if (isTypeReferenceNode(node) && isIdentifier(node.typeName) && node.typeName.escapedText === "") {
return setOriginalNode(createKeywordTypeNode(SyntaxKind.AnyKeyword), node);
}
Expand All @@ -5593,8 +5596,8 @@ namespace ts {
mapDefined(node.parameters, (p, i) => p.name && isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode = p.type, undefined) : createParameter(
/*decorators*/ undefined,
/*modifiers*/ undefined,
p.dotDotDotToken,
p.name || p.dotDotDotToken ? `args` : `arg${i}`,
getEffectiveDotDotDotForParameter(p),
p.name || getEffectiveDotDotDotForParameter(p) ? `args` : `arg${i}`,
p.questionToken,
visitNode(p.type, visitExistingNodeTreeSymbols),
/*initializer*/ undefined
Expand All @@ -5608,8 +5611,8 @@ namespace ts {
map(node.parameters, (p, i) => createParameter(
/*decorators*/ undefined,
/*modifiers*/ undefined,
p.dotDotDotToken,
p.name || p.dotDotDotToken ? `args` : `arg${i}`,
getEffectiveDotDotDotForParameter(p),
p.name || getEffectiveDotDotDotForParameter(p) ? `args` : `arg${i}`,
p.questionToken,
visitNode(p.type, visitExistingNodeTreeSymbols),
/*initializer*/ undefined
Expand Down Expand Up @@ -5653,6 +5656,10 @@ namespace ts {

return visitEachChild(node, visitExistingNodeTreeSymbols, nullTransformationContext);

function getEffectiveDotDotDotForParameter(p: ParameterDeclaration) {
return p.dotDotDotToken || (p.type && isJSDocVariadicType(p.type) ? createToken(SyntaxKind.DotDotDotToken) : undefined);
}

function rewriteModuleSpecifier(parent: ImportTypeNode, lit: StringLiteral) {
if (bundled) {
if (context.tracker && context.tracker.moduleResolverHost) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, ...args) {
>apply : (func: Function, thisArg: any, ...args: ...*) => any
>apply : (func: Function, thisArg: any, ...args: any[]) => any
>func : Function
>thisArg : any
>args : any[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// from bcryptjs
/** @param {function(...[*])} callback */
function g(callback) {
>g : (callback: (arg0: ...[*]) => ) => void
>g : (callback: (...args: [any][]) => ) => void
>callback : (...arg0: [any][]) => any

callback([1], [2], [3])
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/jsdocParseStarEquals.types
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/** @param {...*=} args
@return {*=} */
function f(...args) {
>f : (...args: ...*=) => any | undefined
>f : (...args: (any | undefined)[]) => any | undefined
>args : any[]

return null
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/jsdocPrefixPostfixParsing.types
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @param {...number?[]!} k - (number[] | null)[]
*/
function f(x, y, z, a, b, c, e, f, g, h, i, j, k) {
>f : (x: number[], y: number[], z: (number[]), a: (number | null)[], b: number[] | null, c: (number[]) | null, e: ...?number, f: ...?number, g: ...?!number, h: ...!?number, i: ...number[], j: ...?!number[], k: ...!?number[]) => void
>f : (x: number[], y: number[], z: (number[]), a: (number | null)[], b: number[] | null, c: (number[]) | null, e: (number | null)[], f: (number | null)[], g: (number | null)[], h: (number | null)[], i: number[][], j: (number[] | null)[], k: (number | null)[][]) => void
>x : number[]
>y : number[]
>z : number[]
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/jsdocRestParameter_es6.types
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
=== /a.js ===
/** @param {...number} a */
function f(...a) {
>f : (...a: ...number) => void
>f : (...a: number[]) => void
>a : number[]

a; // number[]
Expand Down