Manaus Manaus - 3 months ago 16
TypeScript Question

Aliasing a class method in definition

I'm trying to make a typing definition file for Mootools, namely the aliasing of

$('myid')
for
document.id('myid')
. I made a interface for
Document
, which is

interface Document {
id(el: string): Element;
...
}


In JQuery.d.ts
$
is aliasing the JQuery object, how can I alias an object method?

Thanks

Answer

The 'aliasing' is performed by the implementation.

In the definition, simply declare the function you want to expose, for example

declare/export function $(el: string): Element;