Using a 3rd party js file with TypeScript

前端 未结 3 665
傲寒
傲寒 2021-01-14 12:56

I am new to typeScript and I want to be able to use a 3rd party library that does not have definition file. Does typescript allow you to use the external libraries?

<
3条回答
  •  -上瘾入骨i
    2021-01-14 13:13

    Another way to call external libraries in typescript without compiling error is to use the window"myglobalfunction" notation.

    For example:

    jQuery call: window["$"]
    fileSaver.js : window["saveAs"](blob, "hello world.txt");
    

    etc...

    These calls inside typescript don't generate compilation errors, but they are full functioning ways to call the same standard functions.

提交回复
热议问题