avatar

ShinChven's Blog

Declare Module for JavaScript Module in TypeScript

TypeScript, JavaScript2022-08-19 07:16:46

Some JavaScript code doesn't come with type declarations. In order to use them in TypeScript project, we can declare the module ourselves in a <MODULE_NAME>.d.ts file.

declare module 'my-module' {
    export type MyType = string;
    const MyType: {
        show: () => void,
    }
    export default MyType;
}