-
Notifications
You must be signed in to change notification settings - Fork 13.3k
createSourceFile build wrong AST in some cases.Β #46933
Copy link
Copy link
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
π Version & Regression Information
- This is a parsing error on 4.5(maybe lower), 4.6-dev
β― Playground Link
π» Code
Parsed JS
!a
? (a = (function () {})())
: (function(a){})(a);import { createPrinter, createSourceFile, ScriptTarget } from "typescript";
const source = `!a
? (a = (function () {})())
: (function(a){return !0})(a);`
console.log(
createPrinter().printFile(
createSourceFile(`test.js`, source, ScriptTarget.Latest)
)
);π Actual behavior
Wrong JS/TS.
!a
? (a = (function () { })()): (function(: a):) => { } : ;
(a);Local tsc for example.ts code make
"use strict";
!a
? (a = (function () { })()) => { } : ;
(a);π Expected behavior
!a
? (a = (function () { })()): (function (a) { })(a); ;
(a);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue