2

I have a typescript repo that fails to build on my machine with the error...

$ tsc --pretty -p tsconfig.json
../../../../../../node_modules/@types/graphql/subscription/subscribe.d.ts:17:12 - error TS2304: Cannot find name 'AsyncIterator'.

17 ): Promise<AsyncIterator<ExecutionResult> | ExecutionResult>;
              ~~~~~~~~~~~~~


../../../../../../node_modules/@types/graphql/subscription/subscribe.d.ts:29:12 - error TS2304: Cannot find name 'AsyncIterable'.

29 ): Promise<AsyncIterable<any>>;
              ~~~~~~~~~~~~~


error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I can't find any mention of @types/graphql when I grep through the node_modules. I do find AsyncIterator in the typescript module however...

when I run the build in a docker container in ubuntu, it passes ok, but on my local OSSierra machine I am getting this error. I have found fixes online that say to add "esnext" to the libs in tsconfig.json, and this does appear to work, but this repo is not under my control and I still have no explanation for why this is happening. Any ideas?

3
  • If you had resolved this issue please share the fix here I am encountering the same error Commented Aug 3, 2018 at 10:32
  • 1
    My issue was cause by an errant node_modules dir that snuck into my home dir at some point. It was traversing upwards until it was found and it was full of junk. I deleted it and the problem was fixed Commented Aug 3, 2018 at 12:04
  • We have the same problem, but with a different error, 2 developer machines has around 20 TS2322, but I dont get them no matter what, neither does CI/the docker container Commented Mar 2, 2022 at 10:31

1 Answer 1

2

We solved it by removing a rogue node_modules folder from a parent directory (in our case the home directory).

Apparantly typescript/node's module resolution looks in parent directories for more "information", maybe someone else has a better explanation :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.