Is the typescript definition exported correctly?
See original GitHub issueI’m having trouble with unfetch >= 3.1.1. The new TypeScript definition actually broke our build, and I’m not sure how to fix it.
The change was made in PR https://github.com/developit/unfetch/pull/89, in which the default export was removed from src/index.d.ts
. Was this intentional? The PR is named “Fix isomorphic-unfetch definition” but packages/isomorphic-unfetch/index.d.ts
is not changed, instead src/index.d.ts
was changed.
Since src/index.mjs
export default, shouldn’t src/index.d.ts
also export default?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Documentation - Modules - TypeScript
In TypeScript, just as in ECMAScript 2015, any file containing a top-level import or export is considered a module. Conversely, a file without...
Read more >Why does this custom type definition not properly export a ...
That package uses CommonJS module.exports syntax to export the function: module.exports = function (str) { ... };.
Read more >Example of TypeScript Export Function - eduCBA
In TypeScript we can almost export anything using the 'export' keyword. It is not a function rather it can be used to export...
Read more >How to export a Type in TypeScript | bobbyhadz
Use a named export to export a type in TypeScript, e.g. export type Person = {} . The exported type can be imported...
Read more >Usage With TypeScript - Redux
Define Slice State and Action Types. Each slice file should define a type for its initial state value, so that createSlice can correctly...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So if you do
import fetch from 'isomorphic-unfetch'
then the types work fine, but it fails to run, due toTypeError: 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 modulesAs such, I’ve done the following workaround for it:
Still getting this error. Is there a fix for it?