mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-21 08:25:43 -05:00
Fix this-parameter emit for JSDocFunction types (#39814)
* Fix this parameter emit for JSDocFunction types Previously, parameters with names that were not `new` were treated like rest parameters. This is incorrect: parameters with the name `this` should emit a `this` parameter. Fixes #38550 * ❤️ quote style
This commit is contained in:
committed by
GitHub
parent
f2d1531768
commit
9b2d487392
@@ -5777,7 +5777,7 @@ namespace ts {
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
getEffectiveDotDotDotForParameter(p),
|
||||
p.name || getEffectiveDotDotDotForParameter(p) ? `args` : `arg${i}`,
|
||||
getNameForJSDocFunctionParameter(p, i),
|
||||
p.questionToken,
|
||||
visitNode(p.type, visitExistingNodeTreeSymbols),
|
||||
/*initializer*/ undefined
|
||||
@@ -5792,7 +5792,7 @@ namespace ts {
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
getEffectiveDotDotDotForParameter(p),
|
||||
p.name || getEffectiveDotDotDotForParameter(p) ? `args` : `arg${i}`,
|
||||
getNameForJSDocFunctionParameter(p, i),
|
||||
p.questionToken,
|
||||
visitNode(p.type, visitExistingNodeTreeSymbols),
|
||||
/*initializer*/ undefined
|
||||
@@ -5847,6 +5847,13 @@ namespace ts {
|
||||
return p.dotDotDotToken || (p.type && isJSDocVariadicType(p.type) ? factory.createToken(SyntaxKind.DotDotDotToken) : undefined);
|
||||
}
|
||||
|
||||
/** Note that `new:T` parameters are not handled, but should be before calling this function. */
|
||||
function getNameForJSDocFunctionParameter(p: ParameterDeclaration, index: number) {
|
||||
return p.name && isIdentifier(p.name) && p.name.escapedText === "this" ? "this"
|
||||
: getEffectiveDotDotDotForParameter(p) ? `args`
|
||||
: `arg${index}`;
|
||||
}
|
||||
|
||||
function rewriteModuleSpecifier(parent: ImportTypeNode, lit: StringLiteral) {
|
||||
if (bundled) {
|
||||
if (context.tracker && context.tracker.moduleResolverHost) {
|
||||
|
||||
Reference in New Issue
Block a user