I am curious about how to import a JavaScript module in TypeScript.
Project
- The module is "amd."
- Utilize the outFile option for a single file.
- Manage internal modules using
///<reference path=''/>
Code
app.js
export function func(a, b) {
return a+b;
}
MainApp.ts
import Stats from "../app";
class MainApp {
foo() {
const f = func(1, 2); // not defined (runtime error)
}
}
Error
SyntaxError: Unexpected token export
ReferenceError: define is not defined
Main.js:6667
at d:\...\Main.js:6667:2
ReferenceError: MainApp is not defined
at window.onload (d:\...\index.html:18:24)
Define not found.