Javascript Typescript定义文件无法使方法实现对象接口
我想为pnotify生成一个定义文件Javascript Typescript定义文件无法使方法实现对象接口,javascript,typescript,Javascript,Typescript,我想为pnotify生成一个定义文件 /// <reference path="./jquery.d.ts"/> interface pnotifyDefaults { styling?: string; history?: boolean; } interface pnotifyInterface { defaults?: pnotifyDefaults } interface JQueryStatic { pnotify(options: a
/// <reference path="./jquery.d.ts"/>
interface pnotifyDefaults {
styling?: string;
history?: boolean;
}
interface pnotifyInterface {
defaults?: pnotifyDefaults
}
interface JQueryStatic {
pnotify(options: any): any;
pnotify: pnotifyInterface;
pnotify_remove_all(): void;
}
declare module 'jquery.pnotify' {
}
但是,我如何实现我想使用pnotify的js代码中的行为呢
$.pnotify(opts)
但也像这样:
$.pnotify.defaults.history = false;
您需要在
pnotifyInterface
上指定调用签名,并将定义更新为:
interface pnotifyDefaults {
styling?: string;
history?: boolean;
}
interface pnotifyInterface {
defaults?: pnotifyDefaults
(options: any): any;
}
interface JQueryStatic {
pnotify: pnotifyInterface;
pnotify_remove_all(): void;
}
declare module 'jquery.pnotify' {
}
您收到错误是因为您在JQueryStatic
界面上声明了两次pnotify
interface pnotifyDefaults {
styling?: string;
history?: boolean;
}
interface pnotifyInterface {
defaults?: pnotifyDefaults
(options: any): any;
}
interface JQueryStatic {
pnotify: pnotifyInterface;
pnotify_remove_all(): void;
}
declare module 'jquery.pnotify' {
}