私はwebkitAudioContext
のようなウィンドウオブジェクトに新しいタイプを定義しようとしています。私は、私は以下のように定義ファイルをインポートしています別のモジュールからは、window.d.tsと呼ばれ、その内側に、私は以下のコードを追加しましたウィンドウのタイスクリプト定義を宣言する正しい方法
/// <reference path="./window.d.ts" />
let contextClass = window.AudioContext || window.webkitAudioContext;
let context = new contextClass();
を interface Window {
AudioContext: Constructable;
webkitAudioContext: Constructable;
}
interface Constructable {
new();
}
を別のファイルを作成しました
上記の2行はうまく動作します。
私はその後、それが働いていない、以下のように
declare module window {
export interface Window {
AudioContext: Constructable;
webkitAudioContext: Constructable;
}
interface Constructable {
new();
}
}
をdefintionファイルを変更した場合。定義をウィンドウに定義する正しい方法は何ですか?
ウィンドウ宣言を名前空間内に置くことはできませんが、デフォルトで提供されているWindow型の型とはもはや一致しません。 – toskv