0

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)
  ...
2
  • Can you include how you used that module? Commented Jun 25, 2017 at 23:45
  • @E_net4 Added as EDIT2 Commented Jun 26, 2017 at 0:03

1 Answer 1

1

Since the library you use directly exports a function you can type it like this:

declare module 'd3-cloud' {
  let cloud: Function;
  export = cloud;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.