Saturday, 2 February 2019

Declare Interfaces in custom typings file for JavaScript

This is subsequent question to a question I previously asked, you can view the information regarding the project here.

I am using a .d.ts file to store all my global functions, constants and interfaces for JavaScript. Although I can easily get the functions and constants, I cannot get the Interfaces.

I have temporarily placed all interfaces in one namespace and created a new namespace filled with constants that implement the Interfaces. See the example below.

export namespace Interfaces {
    export interface Interface {
        property: string;
    }
}

export namespace Namespace {
    export const Interface: Interfaces.Interface;
}

I was wondering if there is a better way to go around the problem.



from Declare Interfaces in custom typings file for JavaScript

No comments:

Post a Comment