You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Importing graphql-request adds DOM/browser types to the environment even if the code is not meant run where DOM is available, causing potential errors by allowing developers to use incorrect types.
This is caused by a dependency on cross-fetch which imports dom library via a triple-slash directive (/// <reference lib="dom" />).
import { GraphQLClient } from 'graphql-request';
let x: HTMLElement;
Commands to reproduce
npm init -y
npm i graphql-request typescript
npx tsc
Expected output
index.ts:3:8 - error TS2304: Cannot find name 'HTMLElement'.
3 let x: HTMLElement;
~~~~~~~~~~~
Actual output
*compiles successfully*
Suggested solution
Remove cross-fetch from dependencies and instead let the developer decide how to polyfill fetch if it's not available. fetch is officially supported in Node.js and all major browsers, therefore "polyfill-by-default" approach is not necessary.
The text was updated successfully, but these errors were encountered:
Description
Importing
graphql-request
adds DOM/browser types to the environment even if the code is not meant run where DOM is available, causing potential errors by allowing developers to use incorrect types.This is caused by a dependency on
cross-fetch
which importsdom
library via a triple-slash directive (/// <reference lib="dom" />
).Reproduction Steps/Repo Link
tsconfig.json
index.ts
Commands to reproduce
Expected output
Actual output
*compiles successfully*
Suggested solution
Remove
cross-fetch
from dependencies and instead let the developer decide how to polyfillfetch
if it's not available.fetch
is officially supported in Node.js and all major browsers, therefore "polyfill-by-default" approach is not necessary.The text was updated successfully, but these errors were encountered: