Reputation: 48
I'm trying to do a word cloud using typescript, react, d3.
My console complains that d3-cloud from npm needs a declaration file, so I've come up with this: EDIT3: Declaration file now looks like this, the same error message is given:
declare module 'd3-cloud' {
export function cloud (): Function;
}
All I get now is this error:
TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof 'd3-cloud'' has no compatible call signatures.
Thanks for any help!
EDIT: I might add that once I reload the page there is a flash of the rendered word cloud, right before the error message takes over. So it sorta works, but... That AT-loader is really unhappy.
EDIT2: I used the npm module like this:
import * as d3Cloud from 'd3-cloud'
const layout = d3Cloud()
.size([width, height])
.font(font)
...
Upvotes: 0
Views: 200
Reputation: 40672
Since the library you use directly exports a function you can type it like this:
declare module 'd3-cloud' {
let cloud: Function;
export = cloud;
}
Upvotes: 1