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

error TS2304: Cannot find name 'RequestInit'. #18

Open
samuela opened this issue Nov 12, 2018 · 4 comments
Open

error TS2304: Cannot find name 'RequestInit'. #18

samuela opened this issue Nov 12, 2018 · 4 comments

Comments

@samuela
Copy link

samuela commented Nov 12, 2018

It seems that this library requires adding dom to the tsconfig.json compilerOptions.lib list, which doesn't make sense when running on node. Fine, perhaps this library is only intending for frontend applications... but this library is also a dependency of prisma-client-lib which is necessary for server-side prisma applications. I'm kinda stumped as to how we're supposed to write prisma graphql servers in TypeScript with this setup...

Here's the compile output in an end-user project that depends on prisma-client-lib:

$ yarn && yarn tsc --noEmit
yarn install v1.10.1
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.24s.
yarn run v1.10.1
$ /Users/skainswo/dev/kumo/node-api/node_modules/.bin/tsc --noEmit
node_modules/http-link-dataloader/dist/src/types.d.ts:5:14 - error TS2304: Cannot find name 'RequestInit'.

5     method?: RequestInit['method'];
               ~~~~~~~~~~~

node_modules/http-link-dataloader/dist/src/types.d.ts:9:12 - error TS2304: Cannot find name 'RequestInit'.

9     mode?: RequestInit['mode'];
             ~~~~~~~~~~~

node_modules/http-link-dataloader/dist/src/types.d.ts:10:19 - error TS2304: Cannot find name 'RequestInit'.

10     credentials?: RequestInit['credentials'];
                     ~~~~~~~~~~~

node_modules/http-link-dataloader/dist/src/types.d.ts:11:13 - error TS2304: Cannot find name 'RequestInit'.

11     cache?: RequestInit['cache'];
               ~~~~~~~~~~~

node_modules/http-link-dataloader/dist/src/types.d.ts:12:16 - error TS2304: Cannot find name 'RequestInit'.

12     redirect?: RequestInit['redirect'];
                  ~~~~~~~~~~~

node_modules/http-link-dataloader/dist/src/types.d.ts:13:16 - error TS2304: Cannot find name 'RequestInit'.

13     referrer?: RequestInit['referrer'];
                  ~~~~~~~~~~~

node_modules/http-link-dataloader/dist/src/types.d.ts:14:22 - error TS2304: Cannot find name 'RequestInit'.

14     referrerPolicy?: RequestInit['referrerPolicy'];
                        ~~~~~~~~~~~

node_modules/http-link-dataloader/dist/src/types.d.ts:15:17 - error TS2304: Cannot find name 'RequestInit'.

15     integrity?: RequestInit['integrity'];
                   ~~~~~~~~~~~

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$
@csvenke
Copy link

csvenke commented Nov 22, 2018

I was also having this problem and adding "dom" to "lib" in tsconfig fixed it!

@samuela
Copy link
Author

samuela commented Nov 22, 2018

@csvenke That's definitely a solution client-side, but I'm trying to use this on node so I'd like to avoid adding a dependency on "dom".

@NateScarlet
Copy link

Temporary fix and not add "dom" to tsconfig:

http-link-dataloader.d.ts

declare type RequestInit = any

@NikxDa
Copy link

NikxDa commented Mar 9, 2019

Any update on this?

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

4 participants