admin管理员组文章数量:1435859
When trying to transpile the following TypeScript code containing async
and await
keywords
async function foo() {
await bar();
}
I get the following error
src/aa.ts(1,7): error TS1005: ';' expected.
src/aa.ts(2,11): error TS1005: ';' expected.
The result is a .js file with this content
async;
function foo() {
await;
bar();
}
I'm using these tsc options: -t es6 -m monjs
, following instructions on this MSDN blog. I have TypeScript 1.8.9 installed.
Any ideas?
When trying to transpile the following TypeScript code containing async
and await
keywords
async function foo() {
await bar();
}
I get the following error
src/aa.ts(1,7): error TS1005: ';' expected.
src/aa.ts(2,11): error TS1005: ';' expected.
The result is a .js file with this content
async;
function foo() {
await;
bar();
}
I'm using these tsc options: -t es6 -m monjs
, following instructions on this MSDN blog. I have TypeScript 1.8.9 installed.
Any ideas?
Share Improve this question asked Apr 5, 2016 at 10:20 PerspectivusPerspectivus 9901 gold badge9 silver badges24 bronze badges2 Answers
Reset to default 3For some reason the TypeScript piler did not recognize the async
and await
keywords. This happened even though the TypeScript piler version was of the correct version.
What I did to solve this is uninstall tsc and install typescript globally:
npm uninstall --global tsc
npm install --global typescript
I encountered a similar issue with an asynchronous arrow function:
async resource_type => some_value
// error TS1005: ',' expected.
Typescript was happy once I wrapped my function parameter in parenthesis:
async (resource_type) => some_value
本文标签: javascriptCannot transpile TypeScript containing async awaitStack Overflow
版权声明:本文标题:javascript - Cannot transpile TypeScript containing async await - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745630252a2667227.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论