Skip to content

Commit b00aea5

Browse files
author
Arthur Ozga
committed
Parameter improvements
1 parent 965b98f commit b00aea5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/compiler/checker.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,16 +2812,26 @@ namespace ts {
28122812
const parameterType = getTypeOfSymbol(parameterSymbol);
28132813
const parameterTypeNode = typeToTypeNodeHelper(parameterType, context);
28142814
const name = getDeepSynthesizedClone(parameterDeclaration.name);
2815+
2816+
let questionToken: Token<SyntaxKind.QuestionToken> | undefined;
2817+
let initializer: Expression | undefined;
2818+
if (isOptionalParameter(parameterDeclaration)) {
2819+
questionToken = createToken(SyntaxKind.QuestionToken);
2820+
}
2821+
else {
28152822
// TODO(aozgaa): In the future, check initializer accessibility.
2823+
initializer = parameterDeclaration.initializer;
2824+
}
28162825
const parameterNode = createParameter(
28172826
parameterDeclaration.decorators,
28182827
parameterDeclaration.modifiers,
2819-
parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken),
2820-
// Clone name to remove trivia.
2828+
(parameterDeclaration ? isRestParameter(parameterDeclaration) : isTransientSymbol(parameterSymbol) && parameterSymbol.isRestParameter) ?
2829+
createToken(SyntaxKind.DotDotDotToken) :
2830+
undefined,
28212831
name,
2822-
parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken),
2832+
questionToken,
28232833
parameterTypeNode,
2824-
parameterDeclaration.initializer);
2834+
initializer);
28252835
return parameterNode;
28262836
}
28272837

0 commit comments

Comments
 (0)