graphql-let icon indicating copy to clipboard operation
graphql-let copied to clipboard

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

Open tobz1000 opened this issue 2 years ago • 0 comments

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.

tobz1000 avatar Jan 17 '22 03:01 tobz1000