0

I am trying to import the masked input jQuery plu gin and be able to view the intellisense within our typescript files. From my understanding, all I need to is create a definition file and reference the said definition file with my typescript file.

Right now, I just want a single method where I can do the following:

$("#date").mask("99/99/9999");

Accordingly, I created a maskedinput.d.ts file as such:

declare interface maskedInput extends JQuery{
    mask(string) : void;
 };

however, this doesn't seem to do the trick. In my ts file, when I start typing

$('#some-id').

I get no intellisense for the method mask. What am I missing here?

1
  • 1
    As Ryan said. Basically $ has the interface type of JQuery. Creating a new interface does not change that. Commented Apr 19, 2013 at 6:22

1 Answer 1

3

Do this instead (interfaces are open):

interface JQuery {
    mask(string): void;
}

TypeScript doesn't automatically change the type of a $('...') expression to maskedInput just because there's some interface out there that happens to extend JQuery.

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

Comments

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.