http-link-dataloader
http-link-dataloader copied to clipboard
error TS2304: Cannot find name 'RequestInit'.
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.
$
I was also having this problem and adding "dom" to "lib" in tsconfig fixed it!
@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".
Temporary fix and not add "dom" to tsconfig:
http-link-dataloader.d.ts
declare type RequestInit = any
Any update on this?