ngx-echarts
ngx-echarts copied to clipboard
Using typedefs from echarts failing due to paths in tsconfig
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
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 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 Thank you for your updates. I will update the README later.