user2952238
user2952238

Reputation: 787

What is the type of a jQuery object in TypeScript?

What type I should use for jQuery elements?

Without jQuery I go on like this:

export class Modal {
    constructor(protected element:HTMLElement) {
    }
}

But, lets say element will be a jQuery selector like $('.myDiv') for example. What type should element then have?

Upvotes: 26

Views: 15488

Answers (1)

Saravana
Saravana

Reputation: 40642

After installing the types needed (npm install --save-dev @types/jquery), you can type it as just JQuery:

constructor(protected element: JQuery) {

}

Upvotes: 33

Related Questions