1

Newbie Question

I have a TypeScript file that uses an extension to jQuery:

function Something() {
     $.stuff.removeAll(); 
}

I am trying to write a definition file for stuff, but am stuck. I tried this:

declare namespace JQueryStuff {
  interface Stuff{
    removeAll(): void;
  }
}

interface JQueryStatic {
    stuff(): JQueryStuff.Stuff;
}

TypeScript intellisence in Visual Studio picks up "Stuff" but not removeAll()

2 Answers 2

1

The way I see it possible without digging too much is aliasing the stuff object with the JQueryStatic merged interface declaration.

interface JQueryStatic {
    stuff: JQueryStuff.Stuff;
}

Let me know if this covers your case.

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

Comments

0

Here's how - Complete answer

interface Stuff{
removeAll(): void;
add(options: {
    title: string;
    text: string;
    class_name: string;
    sticky: boolean;
   });
}


interface JQueryStatic {

   stuff: Stuff;

}

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.