Reference javascript file inside typescript

后端 未结 4 2169
心在旅途
心在旅途 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条回答
  •  隐瞒了意图╮
    2020-12-14 15:42

    this brings an error while building like: Cannot resolve referenced file: ../libs/myjsfile.js

    Reference file tags are for TypeScript not JavaScript. You would load JavaScript using a script tag in your page (or something like requirejs).

    To use the JavaScript from TypeScript you would declare the API of the javascript you want to use for TypeScript consumption (as AKR pointed out).

提交回复
热议问题