Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript definition for a class within a namespace

Tags:

typescript

how can I create a typescript definition file "*.d.ts" for a class inside a namespace with constructor arguments (existing javascript library). I tried several combinations of a module with a nested interface, but nothing worked so far.

Example:

var instance = new Namespace.TargetClass(arg1, arg2);
instance.someFunc(arg3);
like image 686
Fionn Avatar asked Feb 13 '26 01:02

Fionn


1 Answers

declare module Namespace {
    class TargetClass {
        constructor(arg1: string, arg2: number);
        someFunc(arg3: any): void;
    }   
}
like image 52
Ryan Cavanaugh Avatar answered Feb 15 '26 14:02

Ryan Cavanaugh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!