Skip to content

Commit

Permalink
Bump ES target version to ES2022 (matrix-org#4264)
Browse files Browse the repository at this point in the history
* Bump ES target version to ES2022

I want to be able to use `WeakRef`, and per
element-hq/element-web#24913 (comment),
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
(microsoft/TypeScript#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.
  • Loading branch information
richvdh authored Jun 21, 2024
1 parent 6a15e8f commit 9f1aebb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/models/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
* 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
Expand Down Expand Up @@ -460,6 +461,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
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);
Expand All @@ -470,6 +472,8 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
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);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es2016",
"target": "es2022",
"experimentalDecorators": true,
"esModuleInterop": true,
"module": "commonjs",
Expand Down

0 comments on commit 9f1aebb

Please sign in to comment.