I'm attempting to write a typing definition for pouch-redux-middleware, which exports a single function:
import PouchMiddleware from 'pouch-redux-middleware'
PouchMiddleware({...})
Here is the typings definition I have:
interface PouchMiddleware {
(a: any): any;
}
declare var PouchMiddleware: PouchMiddleware;
declare module "pouch-redux-middleware" {
export = PouchMiddleware;
}
This results in the error:
Module '"pouch-redux-middleware"' has no default export.
What is the correct way to declare this?
For transpiling to commonjs modules, you might just have to change the definition file to:
declare function PouchMiddleware(a: any): any;
declare module "pouch-redux-middleware" {
export = PouchMiddleware;
}
Then import it like so:
import PouchMiddleware = require("pouch-redux-middleware");
Kind of sucks though. Someone might come along with a better answer.
I believe my previous answer here only works for targeting ES6 and setting the module as "ES2015":
You will need to compile with
--allowSyntheticDefaultImports
in order to get it to work and then change the interface in the definition file to a function:declare function PouchMiddleware(a: any): any; declare module "pouch-redux-middleware" { export = PouchMiddleware; }
A similar thing happens with the react library. Read more here...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With