Fix jsdoc variadic type nodes not being remapped to equivalent TS in output (#38276)
This commit is contained in:
parent
b57dd52afa
commit
5b0194b311
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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[]
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/** @param {...*=} args
|
||||
@return {*=} */
|
||||
function f(...args) {
|
||||
>f : (...args: ...*=) => any | undefined
|
||||
>f : (...args: (any | undefined)[]) => any | undefined
|
||||
>args : any[]
|
||||
|
||||
return null
|
||||
|
|
|
@ -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[]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
=== /a.js ===
|
||||
/** @param {...number} a */
|
||||
function f(...a) {
|
||||
>f : (...a: ...number) => void
|
||||
>f : (...a: number[]) => void
|
||||
>a : number[]
|
||||
|
||||
a; // number[]
|
||||
|
|
Loading…
Reference in a new issue