なぜ次の例はコンパイルされませんか?基本的には、非同期の反復可能なクロージャを正しく宣言する方法が問題です。Typescript:Async * iterator closureがコンパイルされない
class Test {
async foo() {
const c = async() => {
};
await c();
}
async * bar() {
const c = async *() => {
};
yield * c();
}
}
エラーは以下のとおりです。
...: error TS1109: Expression expected.
...: error TS1005: ';' expected.
マイtsconfig.json:私は次のように例を変更した場合
{
"compilerOptions": {
"declaration": true,
"lib": [
"es2017",
"dom",
"esnext.asynciterable"
],
"module": "commonjs",
"target": "es2015",
"sourceMap": true,
"outDir": "out",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
},
"include": [
"src/**/*.ts"
]
}
、それが動作します。矢印構文の代わりに関数を使用します。
class Test {
async foo() {
const c = async() => {
};
await c();
}
async * bar() {
const c = async function *() {
};
yield * c();
}
}
どのようなエラーで失敗しますか? – Carcigenicate
tsconfig.jsonの内容を表示してください。 –