2017-10-19 182 views
-2

在我Angular2项目中,我用2个模块:谷歌模块冲突

"@types/google.visualization": "0.0.40", 
"@types/googlemaps": "^3.29.1", 

它创建类似冲突:

ERROR in C:/.../ng-cli/src/app/app.component.ts (25,21): Namespace 'google' has no exported member 'visualization'. 
ERROR in C:/.../ng-cli/src/app/app.component.ts (52,12): Property 'charts' does not exist on type 'typeof google'. 
ERROR in C:/.../ng-cli/src/app/app.component.ts (145,30): Property 'visualization' does not exist on type 'typeof google'. 

的GoogleMaps声明命名空间google.maps。

google.visualization声明名称空间谷歌和内部图表和可视化。

如何正确解决?

+0

“app.component.ts”的第25行是什么? – Henry

+0

它是一个变量声明:chartData:google.visualization.DataTable; –

回答

0

所以,我通过删除google.visualization模块解决了它。来自index.d.ts的所有声明都被移到了src目录下的新文件中,并且这个新文件在tsconfig.json的“文件”部分(如“src/google-visualization.ts”)中进行了描述。现在这是很好的工作。