Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Private identifiers are only available when targeting ECMAScript 2015 and higher (Angular 9)

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"
}
like image 731
matchifang Avatar asked Nov 17 '25 14:11

matchifang


1 Answers

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!

like image 77
Sean Halls Avatar answered Nov 19 '25 09:11

Sean Halls



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!