Questions tagged [ecmascript-2020]

ECMAScript 2020 (ES2020) is the 11th version of the ECMAScript language. It adds many important new features, including dynamic imports, globalThis, optional chaining, arbitrary precision BigInts and Promise.allSettled. Only use this tag where the question specifically relates to new features or technical changes provided in ECMAScript 2020.

ECMAScript 2020 (ES2020) is the 11th version of the language.

The following proposals have been merged:

Links

62 questions
3
votes
2 answers

How to use ES2020 features in a Next.js app

I've been trying to use ES2020 features like optional chaining feature in next.js but it needs to a new loader, how do I fix this?
S. Hesam
  • 5,266
  • 3
  • 37
  • 59
2
votes
0 answers

dynamic module contains no exports

I have built a webpack project which has a single entry point that exports a default function. This project can be imported into other projects and the default function can be statically imported as follows: import myFunction from…
2
votes
1 answer

Angular app: es2020 migration from es2015

I have just updated my app to Angular 12 and am trying to use es2020. For some reason I am still getting errors when my app builds because it seems the app is still trying to use…
Jeremy Thomas
  • 6,240
  • 9
  • 47
  • 92
2
votes
2 answers

Why doesn't undefined?.fun() throw an error?

I was very surprised to see the following behavior in Node 14.18.0: > {}?.fun(); Uncaught TypeError: b?.fun is not a function > undefined?.fun(); undefined I understand why the first statement throws a TypeError. {}?.fun is undefined, which is not…
A. R.
  • 2,031
  • 13
  • 27
2
votes
1 answer

Is Ionic framework's compatible with tsconfig target ES2020

I am using mono repo with npm workspaces. Repo has 3 packages server - server code commons - common code shared between server and ionic-app ionic-app - ionic app Both server and commons app are configured with target of ‘ES2020’ as follows. { …
Pavan Kumar
  • 1,715
  • 1
  • 24
  • 48
2
votes
2 answers

How to tune Typescript StencilJS with Jest to support ES6 dynamic module imports

Many Similair questions here (...), but none that help me to get a pure Stencil configuration. The config-administration should be left to Stencil as much as possible IMO (...) My Stencil component works fine, I tried virtually everything, but Jest…
2
votes
2 answers

can someone explain me where in the ECMAScript specification operator precedence and operator associativity is mentioned

I was reading mdn docs about operator precedence and operator associativity "operator precedence and operator associativity(MDN)" and wanted to know more about it reading the ECMAScript specification. But i didn't find anything about operator…
2
votes
1 answer

Does Vue Cli 4.4.6 scaffold ES2020 into the project

If I run vue create my-new-app using the latest Vue Cli (currently version 4.4.6) will all the new ES2020 features be implemented? (I've tested "optional chaining" and seem to be able to use that) If so, how can I tell from the scaffolded code? I'm…
2
votes
0 answers

Problem with with ES2020 dynamic import()

I'm parsing all the modules in a directory, initialise them, and finally export them. The modules in question are knex models like this one: // schema/users.js import createModel from './common' const name = 'User' const tableName = 'users' const…
boojum
  • 669
  • 2
  • 9
  • 31
2
votes
1 answer

Difference between ?? and ||

I was going through the new proposed functionalities in ES2020 and I stumbled upon the ?? operator also known as the “nullish coalescing operator”. The explanation was vague and I still don't get how it is different from the logical OR operator (||)
Saksham
  • 9,037
  • 7
  • 45
  • 73
1
vote
1 answer

Typescript transpiled code "*.js" missing in imports

I have the following code (example): User.ts ... import { UserFavoriteRoom } from "./UserFavoriteRoom.js"; import { Room } from "./Room.js"; import { Reservation } from "./Reservation.js"; import { Message } from "./Message.js"; import { Review }…
Said Torres
  • 581
  • 3
  • 14
1
vote
0 answers

upgraded to latest nx workspace, test fail with transform

We are upgrading angular with nx workspace to latest The problem is when we run test, we got following errors feature-flag.mjs:93:20: ERROR: Transforming for-await loops to the configured target environment ("es2015") is not supported…
Zeo
  • 115
  • 1
  • 14
1
vote
0 answers

export 'catchError' was not found in 'rxjs' when tsconfig.json target is ES2020 in angular 14

I have updated my angular library project to angular 14 and while and building my app I am getting following Error Command ng build --base-href /home/ --configuration production ERROR: /node_modules/@rcis/common/fesm2020/rcis-common.mjs:2000:39-51…
1
vote
1 answer

Optional chaining doesn't work on Node 16.4

I have tried this syntax in VSCode and Coderpad (both use Node version 16.4). let x = {} x?.something.foo As far as my understanding goes, this code shouldn't throw an error now, but return undefined. The feature optional chaining should be…
SrdjaNo1
  • 755
  • 3
  • 8
  • 18
1
vote
1 answer

How to get Typescript to compile CommonJS imports?

I have written a TS file, that loads in a 3rd party package, using import XXX { YYY, ABC, 123 }from 'XXX'; It will compile to CommonJS no issue, and thats OK. But I'd like to compile it to an ESModule. I changed the target and module settings to…
Mr Pablo
  • 4,109
  • 8
  • 51
  • 104