Reference javascript file inside typescript

后端 未结 4 2179
心在旅途
心在旅途 2020-12-14 15:10

I would like to use a javascript function inside a typescript file. How can I reference the javascript file containing that function inside typescript file?

I tried

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 15:42

    You just have to tell the compiler that the method exists outside typescript:

    declare function myJavaScriptFunction(param1: number, param2: JQuery): void;
    

    Be sure that the website loads all files needed, the normal js files and the js files that the typescript compiler generated

提交回复
热议问题