Comments (8)
So if you do import fetch from 'isomorphic-unfetch'
then the types work fine, but it fails to run, due to TypeError: isomorphic_unfetch_1.default is not a function
Searching that error, returns the recommendation of doing the following for commonjs modules import fetch = require('isomorphic-unfetch')
however, then typescript complains there are no types, as the type definition is done with esmodules in mind, not commonjs modules
As such, I've done the following workaround for it:
import * as fetchImport from 'isomorphic-unfetch'
const fetch = (fetchImport.default || fetchImport) as typeof fetchImport.default
from unfetch.
Still getting this error. Is there a fix for it?
from unfetch.
Same problem with [email protected]
([email protected]
, [email protected]
, [email protected]
):
error TS7016: Could not find a declaration file for module 'unfetch'. '/home/user/Edge/Demo/node_modules/unfetch/dist/unfetch.js' implicitly has an 'any' type.
from unfetch.
@egasimus I don't think that is the same issue. Typescript definitions were added in [email protected], so that is probably why the declaration file can't be found in your case.
Some more info on my issue:
import * as fetch from 'unfetch';
console.log(fetch); // { default: f(), __esModule: true }
import fetch from 'unfetch';
// error TS1192: Module '"node_modules/unfetch/src/index"' has no default export
The last example works if I enable allowSyntheticDefaultImports, but that was not required before.
from unfetch.
Yep, just updated to v4 and have same issue. Definitions are definitely incorrect.
from unfetch.
I believe this is due to TypeScript not respecting the .mjs
extension.
from unfetch.
Not true, just .d.ts is incorrect.
from unfetch.
if you do import fetch from 'isomorphic-unfetch' then the types work fine
What am i missing here? there are no types but just a typeof fetch
which resolves to any
from unfetch.
Related Issues (20)
- Type is no longer compatible with fetch HOT 7
- fetching files renders invalid blob HOT 2
- XMLHttpRequest is not defined HOT 1
- The second alternative to AbortController support (#54, #68, #137)
- ReferenceError: self is not defined (snowpack) HOT 8
- what could cause a blank body to be returned? (isomorphic-unfetch) HOT 1
- Support for [email protected]
- Vulnerability in Node-Fetch HOT 3
- supabase V2.0.0 after update on Nuxt 3 problem cross-fetch HOT 1
- createClient - No fetch function in the code
- [email protected] published package might be missing files HOT 2
- Package.json conditional exports points to non-existent files HOT 1
- Can I use unfetch.com for my startup? HOT 1
- Help, wanted! Country ntl-tel-input plugin is not working :( HOT 1
- Module not found: Error: Can't resolve 'unfetch' in 'C:\Users\ranaa\Desktop\demo\demo\src\my-app\src' HOT 1
- Published package.json has workspace declared
- Module not found: Can't resolve 'unfetch' HOT 2
- [Bug]: use of isomorphic-unfetch breaks storybook-next build
- upload progress
- isomorphic-unfetch: broken webpack build when migrated from 3.1.0 to 4.0.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unfetch.