Я перепробовал все ответы, но у меня есть ошибки типа
main.js: 2 Uncaught ReferenceError: экспорт не определен
при использовании компиляции вes5 в качестве цели
и
Uncaught SyntaxError: Неожиданный токен {
при использовании compile to es6 в качестве цели
main.ts
import {MyLib} from './mylib';
let myLib = new MyLib("Anonymous", "Someone");
console.warn(myLib);
mylib.ts
export class MyLib {
constructor(public a: String, public b: String) {
}
toString() {
return "library tostring: " + this.a + " " + this.b;
}
}
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"sourceMap": true
},
"exclude": [
"node_modules"
]
}
index.html
<html>
<head>
<title>
ts-demo !!
</title>
<script type="module" src="./require.js"></script>
<script type="module" src="./system.min.js"></script>
<script src="./tsdemo/main.js"></script>
</head>
<body>
</body>
</html>