no code error reported when using D3.js version 4 but code is written in version 3

Hi,

I just started using WebStorm in order to port a javascript file using D3.js version 3 to D3.js version 4.
I have the two standard libraries 'HTML' and 'HTML5' activated. Moreover I added the external javascript library 'd3.js' (version 4.3) as neatly described by you in your help pages. However, the code parser does not report / highlight any functions, that are still in the D3.js version 3 syntax. This is surprising me, because I only added a library of D3.js version 4. Therefore the code parser should not be capable of seeing something like 'd3.svg.arc()' (in version 4 it is 'd3.arc()') as correct. It should report it as 'function unknown' or something like that.

Please help me out here,

All the best,
Simon

0
4 comments

Ctrl+click on a method that shouldn't be resolved - what file/method does it navigate to?

0
Avatar
Permanently deleted user

Ctrl+click on 'svg' leads to the namespace var of svg in the d3.js version 4 library file.
Ctrl+click on 'arc()': I can choose between different declarations for 'arc()':

  • CanvasRenderingContext2D HTML5
  • path D3.js_4.3
  • exports D3.js_4.3
  • circle D3.js_4.3
  • Circle D3.js_4.3

Then I land in the corresponding file. Removing the HTML5 lib does not solve the issue.

So both variables / methods are available in d3.js version 4 and can be traced back to the javascript source. However, since version 4, it is not possible anymore to write 'd3.svg.arc()'. It's 'd3.arc()' only. The WebStorm code parser does not check if the combination of these variables are allowed but only looks up if both of them exist in the javascript library. I was hoping that is does an exact checkup so I can easily identify the code I have to refactor in order to port from version 3 to version 4.
Maybe it's not just the way Javascript works. Or do you see any possibility to do so?
Else I will identify all the outdated code by hand :)

0
Avatar
Permanently deleted user

I just want to add the following:
If I run the Javascript with the unported code (still version d3.js version 3), it says in the Browser:
'TypeError: d3.svg is undefined'

So the Browser realizes, that 'd3.svg' is not possible with d3.js version 4 anymore, WebStorm is not able to detect (make the right 'connections'?) that. Or is it a handling error of mine?

0

Using TypeScript type definitions instead of actual .js library would help here, but unfortunately https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/d3/d3.d.ts seems to be created for d3 v.3 - at least arc there is still 'd3.svg.arc()':( So it seems that identifying code by hand is the only option:(

0

Please sign in to leave a comment.