我正在尝试将 tsconfig.json 文件的目标属性从 es2015 更新到 es2022。 但是我在运行测试时遇到错误,我认为只使用 tsc 而没有 babel:
Chrome Headless 110.0.5481.177 (Mac OS 10.15.7) TypeError: Cannot 读取未定义的属性(读取“getSomeValue”)
导致这个问题的代码:
export class MyService {
private xyz$ = this.otherService.getSomeValue().pipe(...
constructor(private readonly otherService: SettingsService) {}
}
我猜错误与 es2022 中引入的新类字段功能有关?但我不明白为什么这里应该是个问题?它在 es2021 上运行良好。