There are many threads for similar issues, but as far as I can tell this one is unique.
I'm using jQuery Address plugin in my app and would like to use it in a TypeScript file. Unfortunately there is no DefinitelyTyped script available for the library. When I try to use jQuery.address, I get:
The property 'address' does not exist on value of type 'jQueryStatic'
Per this thread, I've tried to define address
inside of jquery.d.ts
:
interface JQueryStatic {
address(options): any;
...
}
And I think this seems to work for $.address(); but not for any of address' methods. I've also tried to create my own .d.ts file per this thread, but still no luck. And I tried using declare
in a .d.ts file. No luck.
The only method that I need to use is the parameter
method...
$.address.parameter('param', 1);
In which case I get:
The property 'parameter' does not exist on value of type 'address'
Any ideas on how I can resolve this?
edit: I'm working in a Visual Studio C# .net environment, if that helps.
You should not need to edit jquery.d.ts
itself; put these definitions in their own file so they can be maintained properly. Something minimal would be like this:
// For methods on e.g. $('a')
interface JQuery {
address(callback?: () => void): JQuery;
}
// For methods on $
interface JQueryStatic {
address: JQueryAddressStatic;
}
interface JQueryAddressStatic {
(): JQuery;
parameter(name: string): string;
parameter(name: string, value: string, append?: boolean): 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