I'm upgrading from Angular 8.2 to 9.1 and I'm trying to change private fields to be #fieldName: any as allowed by TS 3.8 instead of private fieldName: any. And I get the compiler error saying
Private identifiers are only available when targeting ECMAScript 2015 and higher.
tsconfig.json:
{
"compilerOptions": {
"module": "esnext"
"target": "es2015",
}
}
package.json:
"devDependencies": {
"typescript": "3.8.3"
}
Found this on Reddit, and it was the thing that worked for me:
https://www.reddit.com/r/typescript/comments/1chkjfp/beginner_with_typescript_error_private/
Here are the relevant parts:
"What command are you using to build your project?"
"I am using the command tsc pdfCreation.ts . Though it still seems to compile the file but also gives me errors."
"When you pass a filename on the CLI you're not compiling a project (just a single file) so your tsconfig.json is not used. This is a common mistake (though it's explained in tsc --help).
Instead you should run tsc without filename arguments and use include or files in tsconfig.json to tell TypeScript what to compile."
Worked like a charm!
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