dotansimha / dotansimha/graphql-code-generator

TypeScript error when setting the `module` option to `esnext`

Open
#5,757 14 comments 0 reactions 0 assignees View on GitHub
core stage/1-reproduction stage/2-failing-test
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

**Describe the bug**

It appears that if you set the `compilerOptions.module` setting in a `tsconfig.json` to `esnext`, this causes `graphql-gen` to fail with the following error:

```
Unable to load from file "path/to/module.ts": Cannot use import statement outside a module
```

This would be useful for me, as I am working the TypeScript in a Next.js project and the framework automatically sets this option to `esnext` for me.

**To Reproduce**
Steps to reproduce the behavior:

[Here's a reproduction instead](https://codesandbox.io/s/hopeful-tdd-hlbfc?file=/tsconfig.json)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.