Skip to content

Commit

Permalink
Merge pull request #14508 from Busyrev/fix-function-parameter-default…
Browse files Browse the repository at this point in the history
…-value

FIX: #14507 Function parameter default value wrongly emmited by Printer
  • Loading branch information
mhegazy authored Mar 7, 2017
2 parents b49859b + 1f46dd9 commit 4610dc7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,8 @@ namespace ts {
writeIfPresent(node.dotDotDotToken, "...");
emit(node.name);
writeIfPresent(node.questionToken, "?");
emitExpressionWithPrefix(" = ", node.initializer);
emitWithPrefix(": ", node.type);
emitExpressionWithPrefix(" = ", node.initializer);
}

function emitDecorator(decorator: Decorator) {
Expand Down
3 changes: 3 additions & 0 deletions src/harness/unittests/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ namespace ts {
// comment9
console.log(1 + 2);
// comment10
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }
`, ScriptTarget.ES2015);

printsCorrectly("default", {}, printer => printer.printFile(sourceFile));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ const enum E2 {
}
// comment9
console.log(1 + 2);
// comment10
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ const enum E2 {
second
}
console.log(1 + 2);
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }

0 comments on commit 4610dc7

Please sign in to comment.