Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function parameter default value wrongly emmited by Printer #14507

Closed
Busyrev opened this issue Mar 7, 2017 · 1 comment
Closed

Function parameter default value wrongly emmited by Printer #14507

Busyrev opened this issue Mar 7, 2017 · 1 comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@Busyrev
Copy link
Contributor

Busyrev commented Mar 7, 2017

TypeScript Version: typescript@2.3.0-dev.20170307

Code
Function parameter default value wrongly emmited by Printer

// this written in file:
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }

// I'm processing this file this way:
let program = ts.createProgram(fileNames, options);
let files = program.getSourceFiles();
let logNode: ts.SourceFile = files[1];
let printer = ts.createPrinter();
let printResult = printer.printNode(ts.EmitHint.Unspecified, logNode, logNode);
console.log(printResult);

Expected behavior:

function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }

Actual behavior:

function functionWithDefaultArgValue(argument = "defaultValue": string): void { }

This bug in this line https://github.com/Microsoft/TypeScript/blob/eb34f0ca0301f15f4011f06b019f0949dd2ce483/src/compiler/emitter.ts#L822

822 and 823 must be in different order.

I have added tests for this issue and already fixed it. I'll send PR soon.

@Busyrev
Copy link
Contributor Author

Busyrev commented Mar 7, 2017

this bug related to #13761

@mhegazy mhegazy added the Bug A bug in TypeScript label Mar 7, 2017
mhegazy added a commit that referenced this issue Mar 7, 2017
…-value

FIX: #14507 Function parameter default value wrongly emmited by Printer
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Mar 7, 2017
@mhegazy mhegazy added this to the TypeScript 2.3 milestone Mar 7, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants