Extend interface defined in .d.ts file

后端 未结 2 1908
逝去的感伤
逝去的感伤 2020-11-30 10:40

In my TypeScript project, I use DefinitelyTyped definitions for external js dependencies.

Sometimes it might happen that these definitions are outdated. It might als

2条回答
  •  有刺的猬
    2020-11-30 11:13

    I was able to accomplish this by following the directions at https://www.credera.com/blog/technology-solutions/typescript-adding-custom-type-definitions-for-existing-libraries/. There they use the example of react.

    import 'react';
     
    declare module 'react' {
        interface OlHTMLAttributes {
            type?: "1" | "a" | "A" | "i" | "I";
        }
    }
    

    I found this works really well for winston too.

提交回复
热议问题