Here is the situation:
I have an old third party javascript function and I want to use it in my typescript codes simply using ambient declaration:
old.js: (is loaded by <script> in my .aspx file)
function myFunc() {
return “Hello World”;
}
typing.d.ts:
export declare function myFunc(): string;
app.ts
import { myFunc } from “./typing”
let str: string = myFunc()
transpild app.js:
var str = typing_1.myFunc();
There is no issue in compile time but in runtime I get this error: ‘myFunc is not a function’
Any help will be appreciated