Typescript image import

后端 未结 1 565
死守一世寂寞
死守一世寂寞 2020-11-29 08:16

I found a solution here: Webpack & Typescript image import

But i am getting error for this:

[ts]
Types of property \'src\' are incompatible.
  T         


        
相关标签:
1条回答
  • 2020-11-29 09:06

    One of the ways to get rid of that error is by modifying d.ts file as follows:

    declare module "*.png"
    

    remove

    {
      const value: string;
      export default value;
    }
    

    or alternatively you can do:

    declare module "*.png" {
      const value: any;
      export default value;
    }
    

    Update

    The best solution with type-checking is:

    declare module "*.png" {
       const value: any;
       export = value;
    }
    
    0 讨论(0)
提交回复
热议问题