我将混合移动项目从JS迁移到Typescript,并且在编译期间我在控制台中出错
错误TS2339:属性'ChildBrowser'在类型'{pushNotification:PushNotification; }
这是我的代码
window.plugins.ChildBrowser.showWebPage(text,
{ showLocationBar: true, showAddress: true, showNavigationBar: true });
}
但是WebStorm没有突出显示此行中的任何错误。
我创建了自己的d.ts文件,其中包含此代码(下图)并将此文件包含在我的ts文件中
interface Window {
plugins: Plugins;
pushNotification: PushNotification;
}
interface PushNotification{
emailComposer: EmailComposer;
ChildBrowser: ChildBrowser;
socialsharing: Socialsharing;
}
interface ChildBrowser{
showWebPage: any;
}
interface Socialsharing {
}
interface EmailComposer{
showEmailComposerWithCallback(fu: any, ... fu2: any[]): any;
}
interface Plugins {
emailComposer: EmailComposer;
ChildBrowser: ChildBrowser;
socialsharing: Socialsharing;
}
不幸的是我仍然收到此消息
8种不防止发射型警告
仅键入错误。TypeScript编译完成:23个TypeScript文件的3.98s。
完成,没有错误。
处理完成,退出代码为0
拜托,有人可以帮帮我吗? 此致