Skip to content

Cannot use "cross-undici-fetch" with TypeScript #18

Closed
@pitgrap

Description

@pitgrap

Describe the bug

If I add import { fetch } from "cross-undici-fetch"; to my .ts file, I get the following compile error:

> tsc -v && tsc --build && babel ./src --out-dir ./dist --extensions ".ts,.js"

Version 4.5.5
../../node_modules/.pnpm/[email protected]/node_modules/cross-undici-fetch/dist/index.d.ts:12:23 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

12 declare const _Blob = Blob;
                         ~~~~

../../node_modules/.pnpm/[email protected]/node_modules/cross-undici-fetch/dist/index.d.ts:13:23 - error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

13 declare const _File = File;

I'm stick to this package, because @graphql-tools/url-loader 7.7.1 has a dependecy to this package. If I want to use cross-fetch instead, it's not working, becauseof error TS2451: Cannot redeclare block-scoped variable '_fetch'. etc.

Environment:

  • OS: Linux (WSL)
  • package-name...: "cross-undici-fetch": "^0.1.23",
  • NodeJS: 16
  • Typescript 4.5.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions