tomwanzek / d3-ng2-service

A D3 service for use with Angular.
MIT License
205 stars 42 forks source link

Unresolved variables and methods #113

Closed kristine-sl closed 6 years ago

kristine-sl commented 6 years ago

Hi! I'm using the package together with Angular 5 and the Angular CLI (v1.6.8) and while the package behaves like it should, I'm not getting the appropriate type hint information on the D3 object. I've tried temporarily upgrading to the most recent version of Angular CLI, but the error remained. For instance, in the following example:

this.d3.line()

The line method throws an IDE error with the following message: Unresolved method or function line(). I'm using PHPStorm as IDE and the code does, as mentioned above, work as expected.

The d3 object is initialised as per the documentation:

private d3: D3;

constructor(d3Service: D3Service) {
  this.d3 = d3Service.getD3();
}

Any ideas how to solve this?

tomwanzek commented 6 years ago

I can't reproduce this issue as such, i.e. if I take the latest published version of d3-ng2-demo and simply try and use this.d3.line(), IDE support is as expected. (Note that the demo uses Angular CLI ~1.7.3 and Angular 5.2, FYI I'm using VS Code.)

Could you provide a reference to a repo that provides a minimal reproduction? A couple of things, maybe it's a project setup issue or Angular CLI 1.6.8 issue. Or possibly an IDE issue, if it is the latter, then I guess ng start/ng build should work without error.

tomwanzek commented 6 years ago

@kristine-sl have you been able to resolve your question?

kristine-sl commented 6 years ago

I tested it with the d3-ng2-demo project, and got the same result. I also tried upgrading to Angular CLI 1.7.3, but had the same issue. I restarted the IDE between each test. I also tried deleting node_modules and my lockfile and running yarn install again.

See screenshots of the issue below.

screen shot 2018-03-21 at 15 00 58 screen shot 2018-03-21 at 15 00 47

ng-build works fine, though I am not usually getting any errors in the terminal or any javascript errors that seem to stem for this. So I suspect it is an IDE issue.

flugg commented 6 years ago

I'm also experiencing the same issues using PHPStorm on a fresh angular CLI project.

tomwanzek commented 6 years ago

I just tried to replicate the issue again just based on d3-ng2-demo. Repro steps:

First Take:

(1) Clone repo. Delete package-lock.json (2) Run npm install

Could not replicate issue with d3-ng2-service 2.0.0 using VSCode 1.21.1 on Windows 10.

Second Take:

(3) Update to d3-ng2-service 2.1.0

Same result, could not replicate the issue. See below with working IDE support on d3.line(): d3 line

So I suspect it's in fact a PHPStorm IDE issue, which I cannot unfortunately help with. I guess, filing an issue with them might be your next step, if there is not already an open issue/known solution.

kristine-sl commented 6 years ago

I downloaded VSCode to see it it had the same issue, and it did not. So I agree that it seems to be an PHPStorm issue, thank you for the help! I'll open an issue there.

tomwanzek commented 6 years ago

@kristine-sl Good luck and thanks for double-checking.