Google visualization 如何使用Angular5中的DefinitelyTyped?

Google visualization 如何使用Angular5中的DefinitelyTyped?,google-visualization,angular5,definitelytyped,Google Visualization,Angular5,Definitelytyped,如果我是正确的,DefinitelyTyped具有多个库的TypeScript定义。在我的例子中,我想使用可用的谷歌图表定义。 我已经使用 npm install --save-dev @types/node npm install --save-dev @types/google-apps-script 但我不知道如何将它们导入到我的项目中。我试过使用 import { Google } from '@types/google-apps-script'; 但是VisualStudio代码抛

如果我是正确的,DefinitelyTyped具有多个库的TypeScript定义。在我的例子中,我想使用可用的谷歌图表定义。 我已经使用

npm install --save-dev @types/node
npm install --save-dev @types/google-apps-script
但我不知道如何将它们导入到我的项目中。我试过使用

import { Google } from '@types/google-apps-script';
但是VisualStudio代码抛出了一个错误,它不是一个模块,我的declare const google仍然是:any,这是我想要避免的


任何帮助或提示都将不胜感激。

为了让Google Charts在我的Angular 5项目中工作,我使用了这些定义类型的类型,而这些类型仅适用于Google Charts JavaScript库

@types/google.visualization

下面是我如何将这些类型导入@Injectable服务类的。此语句没有引发错误,因为它不是一个模块,就像我尝试使用*导入时一样

import { } from 'google.visualization';
在构造函数中,您可以只加载一次图表库,然后创建图表函数,将数据和配置选项传递给回调函数(setOnLoadCallback)

我在index.html中添加了一个script元素来加载“”,但也许有更好的方法来包含这样的外部库

google.charts.load('current', {'packages':['corechart']});