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

Bug fix for "Expression produces a union type that is too complex to represent" error #112

Merged
merged 1 commit into from
Nov 25, 2021

Conversation

mdmitry01
Copy link
Contributor

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.

ttypescript replaces emit method

program.emit = function newEmit(
. The emit 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 the emit 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

  1. git clone https://github.com/mdmitry01/nestjs-boilerplate.git
  2. cd nestjs-boilerplate
  3. git checkout ttypescript-bug-demo
  4. npm i
  5. npm run demo

You should now see output like this:

argument true
argument true
argument undefined
argument undefined

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.

My environment

  1. Ubuntu 20.04
  2. Node v14.13.0

@patroza
Copy link

patroza commented Nov 25, 2021

Any word on getting this merged?

@cevek cevek merged commit 23b0fc5 into cevek:master Nov 25, 2021
@patroza
Copy link

patroza commented Nov 25, 2021

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants