Skip to content

Commit

Permalink
room.ts: Fix initialisation order
Browse files Browse the repository at this point in the history
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 committed Jun 21, 2024
1 parent 982b1fa commit e2362cb
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit e2362cb

Please sign in to comment.