Fix TypeScript regex (#1527)

Turns out n.value is NaN for regexes in typescript, go figure. Just moving the two if statements is working to fix the issue.

Fixes #1526
master
Christopher Chedeau 2017-05-05 21:39:11 -07:00 committed by GitHub
parent b9a7549e47
commit c8984f392a
2 changed files with 4 additions and 4 deletions

View File

@ -1016,12 +1016,12 @@ function genericPrintNoParens(path, options, print, args) {
// Babel 6 Literal split // Babel 6 Literal split
case "StringLiteral": case "StringLiteral":
case "Literal": case "Literal":
if (typeof n.value === "number") {
return printNumber(n.raw);
}
if (n.regex) { if (n.regex) {
return printRegex(n.regex); return printRegex(n.regex);
} }
if (typeof n.value === "number") {
return printNumber(n.raw);
}
if (typeof n.value !== "string") { if (typeof n.value !== "string") {
return "" + n.value; return "" + n.value;
} }

View File

@ -1 +1 @@
run_spec(__dirname, null, ["babylon"]); run_spec(__dirname, null, ["babylon", "typescript"]);