Angular 9 project suddenly throws compilation errors when using safe null accessing and null coalescing?

613 Views Asked by At

So this is the weirdest thing I've had happen as this project was working perfectly fine yesterday, in fact i even had 'ng serve' still running as i finished my work the day before and everything was fine.

Come today, with no changes, I can no longer compile the app due to typescript 3.7.2 features although i'm running on 3.7.3 globally and 3.8.3 locally with the angular project. I'm also getting a weird warning with async/await use in zone.js although i'm not using async await anywhere in my project yet -- haven't had an issue using async/await in past angular projects though.

The errors:

WARNING: Zone.js does not support native async/await in ES2017.

and

Module parse failed: Unexpected token (17:38)
>             const address = !!company?.address;
>             if (company?.address) {

and it goes on pointing similar stuff throughout the app. Now this app has been generated just weeks ago using angular cli 9 with my tsconfig untouched using:

        "module": "esnext",
        "moduleResolution": "node",
        "target": "esnext",
        "lib": ["es2018", "dom"]

I'm pretty sure this is not about anything i'm doing within the project itself but how the project gets compiled but sadly I have no idea where to look anymore or what I'm missing so any help/suggestions are really appreciated.

Edit:

Deleted local project, copied back from git, updated to angular 10 using TS 3.9.5 and same issues.

1

There are 1 best solutions below

0
Sierrodc On

"exnext" contains features 'not' in ES. Features are here: github.com/Microsoft/TypeScript/tree/master/lib. I think that, for standard projects, you should use es20** module and target. i.e: target="es2015" and module="es2020" (default of angular10)