错误:类型“导航器"上不存在属性“通知"

错误:类型“导航器

问题描述:

我正在尝试使用离子插件 cordova-plugin-dialogs ,该插件正在工作,我可以调用 navigator.notification.alert()和创建一个本机警报提示,但是无论何时构建我的应用程序,我都会收到以下控制台错误:

I'm attempting to use the ionic plugin cordova-plugin-dialogs, the plugin is working and I am able to call navigator.notification.alert() and create a native alert prompt but whenever my app builds, I get the following console error:

错误TS2339:类型导航器"上不存在属性通知".

error TS2339: Property 'notification' does not exist on type 'Navigator'.

我在网上阅读到这可能与类型有关,但是我已经确认安装了此插件的类型.

I read online that this could be related to types but I have confirmed that the types for this plugin are installed.

我解决的方法是将其添加到我的types.json中:

The way I solved was to add this to my typings.json:

    "dialogs": "github:apache/cordova-plugin-dialogs/types/index.d.ts"

我的项目很旧,仍然使用打字.我使用grunt进行构建,所以我安装了打字.

My project is old and still use typings. I use grunt to build, so I instal the typings.