Hi! I use ttypescript package in a private project. When I compile the project using tsc, I have no compilation errors. But when I use ttsc (note the double t in the name), I get a strange error: Expression produces a union type that is too complex to represent . I found out that the cause of this error is in this library.
I added a console.log to node_modules/ttypescript/lib/patchCreateProgram.js (this file modification is applied automatically by patch-package). Please open the node_modules/ttypescript/lib/patchCreateProgram.js file and look at the line 67. As you can see, I added one more argument to the newEmit function.
Hi! I use
ttypescript
package in a private project. When I compile the project usingtsc
, I have no compilation errors. But when I usettsc
(note the doublet
in the name), I get a strange error:Expression produces a union type that is too complex to represent
. I found out that the cause of this error is in this library.ttypescript
replacesemit
method https://github.com/cevek/ttypescript/blob/505e3aa95e26b90dd30efa2d2d6612a6882a2baa/packages/ttypescript/src/patchCreateProgram.ts#L82 . Theemit
method has the following declaration: https://github.com/microsoft/TypeScript/blob/bfc55b5762443c37ecdef08a3b5a4e057b4d1e85/src/compiler/builderPublic.ts#L101 . The declaration specifies 5 arguments, but it's not true. Sometimes theemit
method takes 6 arguments. And it's the reason for the error "Expression produces a union type that is too complex to represent".It's hard to reproduce, but I created a branch in my other project to demonstrate the issue.
Steps to reproduce
git clone https://github.com/mdmitry01/nestjs-boilerplate.git
cd nestjs-boilerplate
git checkout ttypescript-bug-demo
npm i
npm run demo
You should now see output like this:
I added a
console.log
tonode_modules/ttypescript/lib/patchCreateProgram.js
(this file modification is applied automatically by patch-package). Please open thenode_modules/ttypescript/lib/patchCreateProgram.js
file and look at the line67
. As you can see, I added one more argument to thenewEmit
function.My environment