[TypeScript] Type Definitions and Modules

For example you are building your own module, the same as Lodash:

my-lodash.d.ts

declare module "lodash" {
    declare interface FirstFunction {
        (data: any[]) :any;
    }

    declare interface Lodash {

         first: FirstFunction;
    }

    export const _: Lodash:
}

 

Normally you can install @types for popluar 3rd-party libs, if you have to build your own, you need to remember export type defination aas well for Typescript.

posted @ 2019-02-06 03:32  Zhentiw  阅读(313)  评论(0)    收藏  举报