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;

宿題

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

アイリスオーヤマ ワイヤレス テレビ チューナー 地デジ/BS/CS 録画予約可能 LUCAステーション IST-BAUL201
[ad] アイリスオーヤマ ワイヤレス テレビ チューナー 地デジ/BS/CS 録画予約可能 LUCAステーション IST-BAUL201
アイリスオーヤマ(IRIS OHYAMA) (エレクトロニクス)