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
0
votes
1 answer

when running app.ts file i get the error EntityMetadataNotFoundError: No metadata for "user" was found

i have this project on expressjs and I use typeorm and typescript. the problem is when i run project on develop mode (with app.ts), with the first request i get the error: node_modules/src/data-source/DataSource.ts:427 if (!metadata) throw…
parisa rad
  • 11
  • 3
0
votes
1 answer

Destructure object into 2 separate objects in one call

is there a 1-step way to destructure object into 2 objects using some defined set of props. For example, having initial object const obj = { prop1: "Prop1", prop2: "Prop2", prop3: "Prop3", .... } i'd like to do smth like: const { firstObj: { prop1,…
Ross
  • 1,641
  • 3
  • 15
  • 16
0
votes
1 answer

Cant use BigInt in TS project regardless of es2020

I have simple TS project where this is my tsconfig.json { "compilerOptions": { "target": "es2020", "lib": ["es2020"], } } And I have one file, script.ts with following code inside BigInt(2); Unfortunatelly, when I execute tsc script.ts,…
Weeedooo
  • 501
  • 8
  • 25
0
votes
3 answers

Syntax error when using optional chaining (ES2020) in debug mode (VSCode) in node.js app

I get an "Uncaught SyntaxError: Unexpected token ." message when I try to use my express app in debug mode in VSCode (F5) if my code includes optional chaining (?.). I do not have this problem when I use the app with the command "npm start" which is…
0
votes
1 answer

Checking lots of variables for truthiness in a single pass

I have a large form with many fields and a special processing function Several variables of different types declared at the beginning of a function I would like to check that a user has set all variables before a function execution const a1 = true,…
0
votes
2 answers

best way to check element combination exist in array in typescript

I have array with some element that I want to check if some element combination exist in array that target element is following by any element of checkingSet, if yes, then return true otherwise, return false. For example, if inputArray is ['a', 'b',…
jacobcan118
  • 7,797
  • 12
  • 50
  • 95
0
votes
2 answers

Error Invalid shorthand property initializer in Javascript

let will_pokemon = { pikachu: { species: 'Mouse pokemon', height: 0.4, weight: 5 } } let samson_pokemon = { raichu = { species: 'Rare pokemon', height: 0.8, weight: 12 } } let…
frost21
  • 3
  • 2
0
votes
1 answer

Angular 9 fails to load pdfjs (v. 2.8.335) module with optional chaining

I'm trying to update pdfjs module to the next version (2.8.335) in my Angular application and got following error: ERROR in C:/project/node_modules/pdfjs-dist/build/pdf.js 2205:45 Module parse failed: Unexpected token (2205:45) You may need an…
Valentine
  • 506
  • 6
  • 23
0
votes
0 answers

fallback for dynamic object using bracket

const result = something[dynamicValue] Given the above code, I can get error of Cannot read property 'x' of null because something is undefined, how do I fallback check to void error? should I do something like this const result = something &&…
alice_morgan
  • 151
  • 7
0
votes
1 answer

How to add missing locale to Intl.DateTimeFormat (ES2020) if browser doesn't support required locale?

Unfortunately some browsers don't support some locales using Intl.DateTimeFormat. In my case 'kk' locale in Chrome (https://source.chromium.org/chromium/chromium/src/+/master:third_party/icu/scripts/chrome_ui_languages.list). You can test your…
Eazy
  • 3,212
  • 5
  • 24
  • 40
0
votes
1 answer

can someone explain me whether an expression within the for loops header is an expression statement or an expression

I read the ECMAScript Specification about the for loop's syntax and all. and now i need to know whether the Expressions within a for loop's header are ExpressionStatements or just Expressions im asking this because after every Expression we write a…
0
votes
0 answers

why the syntax of some javaScript constructs is not defined in the ECMAScript specification

Why the syntax of some javaScript contructs are not defined in ECMAScript specifications for example the syntax of the if-statement in ECMAScript is defined like 13.6 The if Statement Syntax IfStatement[Yield, Await, Return]: if (…
Kevin
  • 209
  • 2
  • 11
0
votes
1 answer

Is there an equivalent of optionalChaining in Javascript ES2020?

As we know, ES2020 supports optionalChaining. For example, we can write codes like: let x = {a:{b:'c'}}; console.log(x?.a?.b); and we will get 'c'. But in some cases, we may want to use the expression like x[a][b] rather than x.a.b. Can we use …
Dong
  • 269
  • 1
  • 3
  • 10
-1
votes
1 answer

What is the difference between 'bigint' (lowercase) and 'BigInt'?

So I am trying to update some typescript code that uses external library for big numbers to BigInt (ES2020) and linter is complaining a lot. I don't really understand what is going on here. It looks like there are two different types - 'bigint' and…
Hufsa
  • 19
  • 2
-1
votes
1 answer

validate object destructuring

Let's assume we have two functions /** * @typedef MyResponse * @property {Number} id - my awesome id * @property {Array} attributes - list of ids * */ /** * @return {Promise} * */ function request0() { return…
Alexey Sh.
  • 1,734
  • 2
  • 22
  • 34