Allow implicit any only for definition files

后端 未结 2 641
遥遥无期
遥遥无期 2020-12-11 14:32

I am using TypeScript with the \"noImplicitAny\": true option set in my tsconfig.json.

I am using typings to manage type definition files a

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-11 15:36

    if you need to allow implicit any on a single import line you can use //@ts-ignore attribute right before the untyped module import it will ignore the implicit any (as well as all the others possible error of the following line, so it is up to you to make it right) but it is dead easy and solves me a lot of headache in no time

    for example for font awesome 5 i've

    //@ts-ignore
    import fontawesome from '@fortawesome/fontawesome';
    //@ts-ignore
    import regular from '@fortawesome/fontawesome-free-regular';
    
    fontawesome.library.add(regular);
    

    plus, it works fine with webpack

提交回复
热议问题