I'm using typescript v 1.8.9 in VSCode, nodejs 5.9.1 i have my file app.ts that has these lines
import {XController} from "./XController";
var xContrller=new XController();
xContrller.CallAsyncMethod(some args");
and XController is a class having async methode CallAsyncMethod
like this
public async CallAsyncMethod(url: string) {
await this.request.post(url);
}
this translates to __awaiter(void,...) in javascript but it crashes saying that __awaiter is not defined ??? any clues why this is happening and how to fix it.
Thanks
your tsconfig.json
is most likely wrong. The following worked just fine:
tsconfig.json
:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": true
},
"exclude": [
"node_modules",
"typings/browser",
"typings/browser.d.ts"
],
"compileOnSave": true
}
ping.ts
:
export async function ping() {
for (var i = 0; i < 10; i++) {
await delay(300);
console.log("ping");
}
}
function delay(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms));
}
main.ts
:
import {ping} from "./ping"
async function main() {
await ping();
}
main();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With