I was attempting to write a D.TS file for a third party JQuery UI element I found. However, I can't quite seem to wrap my head around it.
After looking at other definition files, they all seem to work for items that are more akin to standalone libraries, but not plugins per-say.
The plugin I'm working with can be found here. But I've yet to find any typings for it. Has anyone worked with something similar?
The definition file for the jQuery Transit plugin is a good example of what you're looking for.
For plugins, first the jQuery definition from Definitely Typed should be referenced:
/// <reference path="../jquery/jquery.d.ts"/>
Then the plugin can be defined on the existing JQuery interface. The plugin you linked would look something like this:
interface JQueryBootstrapToggleOptions {
on?: string;
// [...]
height?: number;
}
interface JQuery {
bootstrapToggle(options?: JQueryBootstrapToggleOptions): JQuery;
bootstrapToggle(method?: "destroy"): JQuery;
// [...]
bootstrapToggle(method?: "disable"): JQuery;
bootstrapToggle(method?: string): JQuery;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With