Reputation: 7705
I want to generate a definition file for pnotify.
/// <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' {
}
This accutally does not compile and the compiler complains:
Duplicate identifier 'pnotify'. Additional locations: jquery.pnotify.d.ts(15,5)
But how can I achieve that behaviour as in my js code I want to use pnotify like:
$.pnotify(opts)
But also like that:
$.pnotify.defaults.history = false;
Upvotes: 1
Views: 137
Reputation: 19738
You need to specify a call signature on pnotifyInterface
, update your definitions to:
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' {
}
You were receiving the error because you were declaring pnotify
twice on the JQueryStatic
interface.
Upvotes: 1