From 70abd1b5b1f43224fef98abeac2efadfb2ac6f87 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Fri, 21 Jun 2024 12:50:28 +0100 Subject: [PATCH] Bump ES target version to ES2022 (#4264) * Bump ES target version to ES2022 I want to be able to use `WeakRef`, and per https://github.com/element-hq/element-web/issues/24913#issuecomment-2182448007, I believe this should be safe. * room.ts: Fix initialisation order It seems that ES2022 causes typescript to change the initialization order of regular properties vs parameter properties (https://github.com/microsoft/TypeScript/issues/45995), so we need to rearrange the initializations to avoid an error. In practice, it might be fine because we have enabled `babel-plugin-transform-class-properties`, which moves the initialization back after the parameter property, but we shoudn't rely on that, and anyway it upsets the linter. --- src/models/room.ts | 6 +++++- tsconfig.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/models/room.ts b/src/models/room.ts index 7e1284b4e9b..f4d693bfdd5 100644 --- a/src/models/room.ts +++ b/src/models/room.ts @@ -398,7 +398,8 @@ export class Room extends ReadReceipt { * Use getLiveTimeline().getState(EventTimeline.FORWARDS) instead. */ public currentState!: RoomState; - public readonly relations = new RelationsContainer(this.client, this); + + public readonly relations; /** * A collection of events known by the client @@ -460,6 +461,7 @@ export class Room extends ReadReceipt { private readonly opts: IOpts = {}, ) { super(); + // In some cases, we add listeners for every displayed Matrix event, so it's // common to have quite a few more than the default limit. this.setMaxListeners(100); @@ -470,6 +472,8 @@ export class Room extends ReadReceipt { this.name = roomId; this.normalizedName = roomId; + this.relations = new RelationsContainer(this.client, this); + // Listen to our own receipt event as a more modular way of processing our own // receipts. No need to remove the listener: it's on ourself anyway. this.on(RoomEvent.Receipt, this.onReceipt); diff --git a/tsconfig.json b/tsconfig.json index c1c9d48b8e9..a7d2eeb4dd4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es2016", + "target": "es2022", "experimentalDecorators": true, "esModuleInterop": true, "module": "commonjs",