2

I'm designing a web application using Node.js with Angular, Typescript, and d3.js (among other things). The application is up and running with library functionality working as expected. However, I'm unable to properly compile my Typescript files, as I'm running into errors with the type definitions for d3 (see below).

Error:(182, 27) TS2339:Property 'time' does not exist on type 'typeof 
  "C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(187, 27) TS2339:Property 'scale' does not exist on type 'typeof 
  "C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(193, 28) TS2339:Property 'svg' does not exist on type 'typeof 
  "C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(195, 47) TS2339:Property 'time' does not exist on type 'typeof 
  "C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(258, 28) TS2339:Property 'svg' does not exist on type 'typeof 
  "C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(915, 23) TS2339:Property 'svg' does not exist on type 'typeof 
  "C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(970, 25) TS2339:Property 'svg' does not exist on type 'typeof 
  "C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.
Error:(1147, 21) TS2339:Property 'svg' does not exist on type 'typeof 
  "C:/Users/my.user/project/workspace/node_modules/@types/d3/index"'.

These properties seem to be working fine, but the typescript compiler doesn't recognize them, indicating that there's something wrong with my @types/d3 dependency.

The version of d3.js that I'm using is 3.4.8, and the version for @types/d3 is 4.3.0.

I'm sure these two versions don't match, but I still need to find a pair of version numbers that match, and also offer the properties that Typescript isn't recognizing.

Can anybody recommend a combination for these libraries that would work given the properties I need to access? I'm assuming that my typings for d3 are behind in some way, so perhaps an older version would be suitable? If somebody has an answer, or even a systematic way to find out what version I would need, that would be extremely helpful.

1 Answer 1

1

I know this question has been posted some months before but it still need to be answered.

First check your d3 and @types version in package.json file. As you have said,

  • You are using d3 v3.4.8 so you should use @types/[email protected].
  • you are using @types/4.3.0 which would be compatible with d3 v4.3.0.

Note : Always take d3 and types same version.

For searching types go to microsoft official site.

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.