mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-13 22:53:33 -05:00
Correctly transform jsdoc parameter types
And give a better name for rest params
This commit is contained in:
@@ -578,10 +578,10 @@ namespace ts {
|
||||
return emitLiteralType(<LiteralTypeNode>node);
|
||||
case SyntaxKind.JSDocAllType:
|
||||
write("*");
|
||||
break;
|
||||
return;
|
||||
case SyntaxKind.JSDocUnknownType:
|
||||
write("?");
|
||||
break;
|
||||
return;
|
||||
case SyntaxKind.JSDocNullableType:
|
||||
return emitJSDocNullableType(node as JSDocNullableType);
|
||||
case SyntaxKind.JSDocNonNullableType:
|
||||
|
||||
@@ -189,8 +189,11 @@ namespace ts.refactor.annotateWithTypeFromJSDoc {
|
||||
}
|
||||
|
||||
function visitJSDocParameter(node: ParameterDeclaration) {
|
||||
const name = node.name || "arg" + node.parent.parameters.indexOf(node);
|
||||
return createParameter(node.decorators, node.modifiers, node.dotDotDotToken, name, node.questionToken, node.type, node.initializer);
|
||||
const index = node.parent.parameters.indexOf(node);
|
||||
const isRest = node.type.kind === SyntaxKind.JSDocVariadicType && index === node.parent.parameters.length - 1;
|
||||
const name = node.name || (isRest ? "rest" : "arg" + index);
|
||||
const dotdotdot = isRest ? createToken(SyntaxKind.DotDotDotToken) : node.dotDotDotToken;
|
||||
return createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, visitNode(node.type, transformJSDocType), node.initializer);
|
||||
}
|
||||
|
||||
function visitJSDocTypeReference(node: TypeReferenceNode) {
|
||||
|
||||
Reference in New Issue
Block a user