I'm attempting to switch the target property in the tsconfig.json file from es2015 to es2022, but I am encountering an error while running tests that seem to only use tsc without babel:
Chrome Headless 110.0.5481.177 (Mac OS 10.15.7) TypeError: Cannot read properties of undefined (reading 'getSomeValue')
This is the code snippet causing the issue:
export class MyService {
private xyz$ = this.otherService.getSomeValue().pipe(...
constructor(private readonly otherService: SettingsService) {}
}
I suspect the error may be related to the new class fields features introduced in es2022, but I am unsure why it would be a problem in this scenario. It was working fine with es2021.
I'm not certain if modifying the tsconfig.json will help?
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2022",
"module": "es2022",
"resolveJsonModule": true
}
}