created: 2020-08-17T09:11:09.000Z

TypeScriptで外部スクリプトからロードされたグローバル変数のエラーを無視する

GoogleChartはnpmパッケージになっておらず、またローカルにファイルを置くことが許可されていない

Sorry; our terms of service do not allow you to download and save or host the google.charts.load or google.visualization code. However, if you don't need the interactivity of Google Charts, you can screenshot the charts and use them as you wish.

なのでこのように外部jsファイルとして読み込むことになっている

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 

これはTypeScriptでは知らないグローバル変数として怒られる

Cannot find name 'google'.ts(2304)

このエラーは以下の宣言で無視することができる

declare var google;

宿題

型定義もあるようなので、型定義をつかって解決する方がよい

古代ローマ人の24時間---よみがえる帝都ローマの民衆生活
[ad] 古代ローマ人の24時間---よみがえる帝都ローマの民衆生活
アルベルト・アンジェラ, 関口 英子 (単行本)