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

isomorphic-fetch & typescript - is the dom polyfill required to run on nodeJs? #167

Open
JakeSummers opened this issue Apr 2, 2018 · 1 comment

Comments

@JakeSummers
Copy link

Good Evening,

I am attempting to use iosmorphic-fetch on node 6.10 with typescript but am running into some issues. I am trying to remove the dom lib/polyfill from my tsconfig:

  "compilerOptions": {
    "target": "es2015", 
    "module": "commonjs",
    "lib": [
        "esnext",
       "dom"   // <-- would like to remove this
    ],

When I try to do this, I get the following error during my tsc (typescript compiler):

node_modules/@types/isomorphic-fetch/index.d.ts(8,30): error TS2552: Cannot find name 'fetch'. Did you mean '_fetch'?

Not sure if I have botched the setup somehow or whether this is a bug.

Package.json:

    "dependencies": {
        "es6-promise": "^4.2.4",
        "isomorphic-fetch": "^2.2.1",
        "node-fetch": "^2.1.1",
    },
    "devDependencies": {
        "@types/isomorphic-fetch": "0.0.34",

Thanks!

@smonusbonus
Copy link

Would assume this is because a global fetch method is only available in a browser environment, not in node.js. So you probably have to declare it manually, like so declare const fetch: any;

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

2 participants