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

Codegen may fail if noEmitOnError: true is set on tsconfig.json #615

Open
tobz1000 opened this issue Jan 17, 2022 · 0 comments
Open

Codegen may fail if noEmitOnError: true is set on tsconfig.json #615

tobz1000 opened this issue Jan 17, 2022 · 0 comments

Comments

@tobz1000
Copy link

tobz1000 commented Jan 17, 2022

I can only speculate as to exactly why this is, but here is my best guess based on experimenting:

  1. Some initial compilation occurs to generate the .d.ts in the cache location
  2. This initial compilation reports ts errors, maybe because of hard-coded paths, or circular dependencies between the generated types and the user's code. Either way, errors are expected before the generated types are correct location.
  3. With noEmitOnError: true set, the .d.ts is never emitted and cannot be copied to @types/graphql-let/__generated__. The final type-check by graphql-let subsequently fails.

My workaround for this is the TSConfigFile config option (thank you for that!):

.graphql-let.yml:

TSConfigFile: ./tsconfig.graphql-let.json

tsconfig.graphql-let.json:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "noEmitOnError": false
  }
}

It would be neater if the noEmitOnError option was set to false before performing ts compilation (essentially ignoring this option in the user's tsconfig). Or, this edge case could be added to the readme, describing the workaround above. This took me a couple of hours to figure out and might save someone else some pain :)

This would probably also apply to the noEmit option; maybe some others too.

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

No branches or pull requests

1 participant