다음 예제가 컴파일되지 않는 이유는 무엇입니까? 기본적으로 비동기 iterable 클로저를 올바르게 선언하는 방법이 문제입니다.Typescript : Async * iterator 클로저가 컴파일되지 않음
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의 내용을 표시해 주시겠습니까? –