TypeScript Version: 2.4.2
Code
import * as ts from "typescript";
let sourceCode = "let a = /regexp/";
let tsSourceFile = ts.createSourceFile(
"script.js",
sourceCode,
ts.ScriptTarget.Latest
);
console.log(
ts.createPrinter().printFile(tsSourceFile)
);
Expected behavior:
The script should output let a = /regexp/;
Actual behavior:
The script crashes with the following stack trace:
.../node_modules/typescript/lib/typescript.js:3495
throw e;
^
Error: Debug Failure.
at Object.getLiteralText (/Users/work/GitHub/sample-js-selfparsing/node_modules/typescript/lib/typescript.js:7077:18)
at getLiteralTextOfNode (/Users/work/GitHub/sample-js-selfparsing/node_modules/typescript/lib/typescript.js:68597:23)
at emitLiteral (/Users/work/GitHub/sample-js-selfparsing/node_modules/typescript/lib/typescript.js:66918:24)
at pipelineEmitExpression (/Users/work/GitHub/sample-js-selfparsing/node_modules/typescript/lib/typescript.js:66816:28)
at pipelineEmitWithHint (/Users/work/GitHub/sample-js-selfparsing/node_modules/typescript/lib/typescript.js:66565:49)
at pipelineEmitWithSourceMap (/Users/work/GitHub/sample-js-selfparsing/node_modules/typescript/lib/typescript.js:66558:17)
at emitNodeWithNestedComments (/Users/work/GitHub/sample-js-selfparsing/node_modules/typescript/lib/typescript.js:64324:17)
at emitNodeWithSynthesizedComments (/Users/work/GitHub/sample-js-selfparsing/node_modules/typescript/lib/typescript.js:64274:13)
at emitNodeWithComments (/Users/work/GitHub/sample-js-selfparsing/node_modules/typescript/lib/typescript.js:64244:21)
at pipelineEmitWithComments (/Users/work/GitHub/sample-js-selfparsing/node_modules/typescript/lib/typescript.js:66547:17)
error Command failed with exit code 1.
Proposed fix:
fwouts@884cadf
Where would be a good place to add tests for this?
TypeScript Version: 2.4.2
Code
Expected behavior:
The script should output
let a = /regexp/;Actual behavior:
The script crashes with the following stack trace:
Proposed fix:
fwouts@884cadf
Where would be a good place to add tests for this?