私はChromeアプリケーションを構築しています。アプリは活字体(Angular2)と書かれています。活字体とChrome通知
私はプッシュ通知をしたいと思います。ここでは、コードがあります:
import {Injectable} from 'angular2/core';
@Injectable()
export class NotificationService {
constructor() {
if(Notification.permission !== 'granted') {
Notification.requestPermission();
}
}
}
ゴクゴクアプリをビルドすると、それは言う:
src/scripts/stream/notification.service.ts(6) Cannot find name 'Notification'.
私は内部の私のクラスをラップしてみました:
/* tslint:disable */
... the code
/* tslint:enable */
しかし、それは何も変わりません。
tslint.jsonファイルで、これがグローバル変数であることをTypescriptに伝える方法はありますか?あなたがChromeのタイピングの定義が欠落しているように見えます
"globals": {
"Notification": false
}
あなたはタイプ定義が見つからないようです。あなたのプロジェクトにchrome.d.tsが含まれていますか? – toskv
私はtypescriptとtslintを使い慣れました。私はchrome.d.tsが何であるか分かりません! – Maxime
ここにファイルがあります:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/chrome/chrome.d.tsどうすればいいですか? – Maxime