Currently, I am utilizing bigint literals within my Angular project which are only available in ESNext. However, it seems that the null-coalescing operator mentioned here is not accessible when targeting ESNext.
this._id = id ?? Util.makeGuid()
This line of code is generating an error TS1109 : Expression expected
during compilation and a red squiggly line appears under the second question mark.
I find this perplexing. Isn't ESNext supposed to target the latest version of JavaScript? Why aren't these new features available?
As an illustration, you can test this code in the TypeScript playground, where it runs smoothly when set to V3.7.2 and targets ES2017.
class Foo {
name: string;
constructor(name?: string) {
this.name = name ?? "I am Foo";
}
}
let f = new Foo();
alert(f.name);
However, if you switch the "Config" tab to target ESNext, the code will fail with a syntax error in the console.
The version of Chrome I am using is:
Google Chrome is up to date
Version 79.0.3945.130 (Official Build) (64-bit)
For any skeptics, here are some screenshots:
https://i.sstatic.net/6SuXe.png