Merge pull request #14508 from Busyrev/fix-function-parameter-default-value

FIX: #14507 Function parameter default value wrongly emmited by Printer
This commit is contained in:
Mohamed Hegazy 2017-03-07 10:34:33 -08:00 committed by GitHub
commit 4610dc7e3b
4 changed files with 7 additions and 1 deletions

View file

@ -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) {

View file

@ -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));

View file

@ -23,3 +23,5 @@ const enum E2 {
}
// comment9
console.log(1 + 2);
// comment10
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }

View file

@ -15,3 +15,4 @@ const enum E2 {
second
}
console.log(1 + 2);
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }