带有typescript的Systemjs Transfile异步函数
我能够使用带有typescript的Systemjs Transfile异步函数,typescript,async-await,systemjs,transpiler,Typescript,Async Await,Systemjs,Transpiler,我能够使用tsc工具手动构建.ts文件。我看到为async/await关键字生成的包装器 但是我无法使用systemjs动态设置Transfile index.htm: <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/typescri
tsc
工具手动构建.ts
文件。我看到为async/await关键字生成的包装器
但是我无法使用systemjs动态设置Transfile
index.htm:
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/typescript/1.7.5/typescript.min.js"></script>
<script>
System.config({
transpiler: 'typescript',
typescriptOptions: {
target: 'es6'
},
packages: {
'': {
defaultJSExtensions: 'ts'
}
}
});
System.import('app').catch(console.error.bind(console));
</script>
开发人员控制台中的错误:
SyntaxError: missing ; before statement
请参见问题在于指定格式“esm”。或者在
.ts
文件中添加一些关键字,如import
,以便systemjs可以选择正确的加载程序
System.config({
transpiler: 'typescript',
meta: {
'app.ts': {
format: 'esm'
}
}
});
System.import('app.ts').catch(console.error.bind(console));
更新
现在它就像一个符咒
System.config({
transpiler: 'typescript',
meta: {
'app.ts': {
format: 'esm'
}
}
});
System.import('app.ts').catch(console.error.bind(console));