xieziyu / ngx-echarts

An angular (ver >= 2.x) directive for ECharts (ver >= 3.x)
https://xieziyu.github.io/ngx-echarts/
MIT License
1.11k stars 197 forks source link

Using typedefs from echarts failing due to paths in tsconfig #153

Open itslenny opened 5 years ago

itslenny commented 5 years ago

I'm trying to import a typedef from echarts, but it's failing with the following error:

Could not find a declaration file for module 'echarts'. 'node_modules/echarts/dist/echarts.min.js' implicitly has an 'any' type. [7016]

The import is as follows:

import { EChartOption } from 'echarts';

I have @types/echarts installed, but I also added echarts to my paths in tsconfig.json (as directed in the ngx-echarts readme) which I think is what is causing the problem

{
  "paths": {
    "echarts": ["node_modules/echarts/dist/echarts.min.js"],
  }
}
xieziyu commented 5 years ago

@itslenny Yes, the path in tsconfig.json is conflicted. Please try to remove the echarts paths in tsconfig.json and add it back into angular.json:

"architect": {
  "build": {
    "options": {
      "scripts": [
+       "node_modules/echarts/dist/echarts.min.js"
      ]
    }
  }
}

Please let me know if this is working for your case.

smnbbrv commented 5 years ago

@xieziyu actually, speaking of that line...

With the newest versions of echarts@4 / angular@7 I removed this line and it works fine. No errors like it was before, so one can use everything as-is without remapping.

As the one who introduced this, I feel responsible now to ask you to adapt the README :) Probably angular@7 has less strict rules concerning echarts build specifics...

xieziyu commented 5 years ago

@smnbbrv Thank you for your updates. I will update the README later.