Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit c1d4199

Browse files
authored
Upgrade target to es2022 (#12852)
* Upgrade target to es2021 Signed-off-by: Michael Telatynski <[email protected]> * Upgrade to es2022 Signed-off-by: Michael Telatynski <[email protected]> * Fix babel config Signed-off-by: Michael Telatynski <[email protected]> * Fix React contexts Signed-off-by: Michael Telatynski <[email protected]> * Fix types Signed-off-by: Michael Telatynski <[email protected]> * Fix React state Signed-off-by: Michael Telatynski <[email protected]> * Iterate Signed-off-by: Michael Telatynski <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]>
1 parent 9cd0c24 commit c1d4199

File tree

68 files changed

+86
-148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+86
-148
lines changed

babel.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ module.exports = {
1010
"last 2 Safari versions",
1111
"last 2 Edge versions",
1212
],
13+
include: ["@babel/plugin-transform-class-properties"],
1314
},
1415
],
15-
"@babel/preset-typescript",
16+
["@babel/preset-typescript", { allowDeclareFields: true }],
1617
"@babel/preset-react",
1718
],
1819
plugins: [
1920
"@babel/plugin-proposal-export-default-from",
2021
"@babel/plugin-transform-numeric-separator",
21-
"@babel/plugin-transform-class-properties",
2222
"@babel/plugin-transform-object-rest-spread",
2323
"@babel/plugin-syntax-dynamic-import",
2424
"@babel/plugin-transform-runtime",

playwright/plugins/homeserver/dendrite/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const dendriteConfigFile = "dendrite.yaml";
2929

3030
// Surprisingly, Dendrite implements the same register user Admin API Synapse, so we can just extend it
3131
export class Dendrite extends Synapse implements Homeserver, HomeserverInstance {
32-
public config: HomeserverConfig & { serverId: string };
3332
protected image = "matrixdotorg/dendrite-monolith:main";
3433
protected entrypoint = "/usr/bin/dendrite";
3534

playwright/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
3-
"target": "es2018",
3+
"target": "es2022",
44
"jsx": "react",
5-
"lib": ["ESNext", "es2021", "dom", "dom.iterable"],
5+
"lib": ["ESNext", "es2022", "dom", "dom.iterable"],
66
"resolveJsonModule": true,
77
"esModuleInterop": true,
88
"moduleResolution": "node",

src/@types/global.d.ts

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -144,69 +144,14 @@ declare global {
144144
usageDetails?: { [key: string]: number };
145145
}
146146

147-
// https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas
148-
interface OffscreenCanvas {
149-
convertToBlob(opts?: { type?: string; quality?: number }): Promise<Blob>;
150-
}
151-
152-
interface HTMLAudioElement {
153-
type?: string;
154-
}
155-
156-
interface HTMLVideoElement {
157-
type?: string;
158-
}
159-
160-
// Add Chrome-specific `instant` ScrollBehaviour
161-
type _ScrollBehavior = ScrollBehavior | "instant";
162-
163-
interface _ScrollOptions {
164-
behavior?: _ScrollBehavior;
165-
}
166-
167-
interface _ScrollIntoViewOptions extends _ScrollOptions {
168-
block?: ScrollLogicalPosition;
169-
inline?: ScrollLogicalPosition;
170-
}
171-
172147
interface Element {
173148
// Safari & IE11 only have this prefixed: we used prefixed versions
174149
// previously so let's continue to support them for now
175150
webkitRequestFullScreen(options?: FullscreenOptions): Promise<void>;
176151
msRequestFullscreen(options?: FullscreenOptions): Promise<void>;
177-
scrollIntoView(arg?: boolean | _ScrollIntoViewOptions): void;
178-
}
179-
180-
interface Error {
181-
// Standard
182-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause
183-
cause?: unknown;
184-
185-
// Non-standard
186-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/fileName
187-
fileName?: string;
188-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/lineNumber
189-
lineNumber?: number;
190-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/columnNumber
191-
columnNumber?: number;
192-
}
193-
194-
// We can remove these pieces if we ever update to `target: "es2022"` in our
195-
// TypeScript config which supports the new `cause` property, see
196-
// https://github.com/vector-im/element-web/issues/24913
197-
interface ErrorOptions {
198-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause
199-
cause?: unknown;
200-
}
201-
202-
interface ErrorConstructor {
203-
new (message?: string, options?: ErrorOptions): Error;
204-
(message?: string, options?: ErrorOptions): Error;
152+
// scrollIntoView(arg?: boolean | _ScrollIntoViewOptions): void;
205153
}
206154

207-
// eslint-disable-next-line no-var
208-
var Error: ErrorConstructor;
209-
210155
// https://github.com/microsoft/TypeScript/issues/28308#issuecomment-650802278
211156
interface AudioWorkletProcessor {
212157
readonly port: MessagePort;

src/components/structures/EmbeddedPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ interface IState {
4545

4646
export default class EmbeddedPage extends React.PureComponent<IProps, IState> {
4747
public static contextType = MatrixClientContext;
48-
public context!: React.ContextType<typeof MatrixClientContext>;
48+
public declare context: React.ContextType<typeof MatrixClientContext>;
4949
private unmounted = false;
5050
private dispatcherRef: string | null = null;
5151

src/components/structures/FilePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ interface IState {
5959
*/
6060
class FilePanel extends React.Component<IProps, IState> {
6161
public static contextType = RoomContext;
62-
public context!: React.ContextType<typeof RoomContext>;
62+
public declare context: React.ContextType<typeof RoomContext>;
6363

6464
// This is used to track if a decrypted event was a live event and should be
6565
// added to the timeline.

src/components/structures/MessagePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ interface IReadReceiptForUser {
205205
*/
206206
export default class MessagePanel extends React.Component<IProps, IState> {
207207
public static contextType = RoomContext;
208-
public context!: React.ContextType<typeof RoomContext>;
208+
public declare context: React.ContextType<typeof RoomContext>;
209209

210210
public static defaultProps = {
211211
disableGrouping: false,

src/components/structures/NotificationPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interface IState {
4242
*/
4343
export default class NotificationPanel extends React.PureComponent<IProps, IState> {
4444
public static contextType = RoomContext;
45-
public context!: React.ContextType<typeof RoomContext>;
45+
public declare context: React.ContextType<typeof RoomContext>;
4646

4747
private card = React.createRef<HTMLDivElement>();
4848

src/components/structures/RightPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ interface IState {
7373

7474
export default class RightPanel extends React.Component<Props, IState> {
7575
public static contextType = MatrixClientContext;
76-
public context!: React.ContextType<typeof MatrixClientContext>;
76+
public declare context: React.ContextType<typeof MatrixClientContext>;
7777

7878
public constructor(props: Props, context: React.ContextType<typeof MatrixClientContext>) {
7979
super(props, context);

src/components/structures/RoomStatusBar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ interface IState {
9797
export default class RoomStatusBar extends React.PureComponent<IProps, IState> {
9898
private unmounted = false;
9999
public static contextType = MatrixClientContext;
100-
public context!: React.ContextType<typeof MatrixClientContext>;
100+
public declare context: React.ContextType<typeof MatrixClientContext>;
101101

102102
public constructor(props: IProps, context: React.ContextType<typeof MatrixClientContext>) {
103103
super(props, context);
104-
this.context = context; // XXX: workaround for lack of `declare` support on `public context!:` definition
105104

106105
this.state = {
107106
syncState: this.context.getSyncState(),

0 commit comments

Comments
 (0)