ngx-echarts icon indicating copy to clipboard operation
ngx-echarts copied to clipboard

Using typedefs from echarts failing due to paths in tsconfig

Open itslenny opened this issue 5 years ago • 3 comments

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"],
  }
}

itslenny avatar Nov 26 '18 04:11 itslenny

@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.

xieziyu avatar Nov 26 '18 06:11 xieziyu

@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...

smnbbrv avatar Dec 08 '18 22:12 smnbbrv

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

xieziyu avatar Dec 10 '18 07:12 xieziyu