Reputation: 15582
Given this CommonJS module:
// cjs.js
module.exports = () => console.log("hi");
What can I put in my .d.ts
// cjs.d.ts
export ????
So that I can do a star import like this from a TypeScript file and pick up the correct types:
// main.ts
import * as log from "./cjs"
log()
Upvotes: 1
Views: 284
Reputation: 250226
You can use export assignment, but you need to declare an intermediary const
that will be typed as the function:
declare const def: () => void
export = def;
Upvotes: 1