3

I'm creating a method in TypeScript that should receive a jQuery selector as a parameter and I want to make it strongly typed by using DefinitelyTyped. How should my method be like?

Example:

class Foo {
    constructor($el: jQuerySelector) {
    }
}

What should I replace jQuerySelector with?

1 Answer 1

5

e.g. $('div') in the DefinitelyTyped jquery.d.ts is named JQuery.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, my jQuerySelector should be just jQuery.
@AndréPena Note the capital J in JQuery instead of jQuery. This holds for all the other types defined in that file such as JQueryXHR and JQueryPromise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.