Skip to content

Commit 4610dc7

Browse files
authored
Merge pull request #14508 from Busyrev/fix-function-parameter-default-value
FIX: #14507 Function parameter default value wrongly emmited by Printer
2 parents b49859b + 1f46dd9 commit 4610dc7

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,8 +819,8 @@ namespace ts {
819819
writeIfPresent(node.dotDotDotToken, "...");
820820
emit(node.name);
821821
writeIfPresent(node.questionToken, "?");
822-
emitExpressionWithPrefix(" = ", node.initializer);
823822
emitWithPrefix(": ", node.type);
823+
emitExpressionWithPrefix(" = ", node.initializer);
824824
}
825825

826826
function emitDecorator(decorator: Decorator) {

src/harness/unittests/printer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ namespace ts {
4545
4646
// comment9
4747
console.log(1 + 2);
48+
49+
// comment10
50+
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }
4851
`, ScriptTarget.ES2015);
4952

5053
printsCorrectly("default", {}, printer => printer.printFile(sourceFile));

tests/baselines/reference/printerApi/printsFileCorrectly.default.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ const enum E2 {
2323
}
2424
// comment9
2525
console.log(1 + 2);
26+
// comment10
27+
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }

tests/baselines/reference/printerApi/printsFileCorrectly.removeComments.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ const enum E2 {
1515
second
1616
}
1717
console.log(1 + 2);
18+
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }

0 commit comments

Comments
 (0)