diff --git a/.babelrc b/.babelrc index 6e6720bbf11..0ea353e6d0a 100644 --- a/.babelrc +++ b/.babelrc @@ -5,16 +5,16 @@ "@babel/preset-env", { "targets": { - "node": 10 + "node": 18 }, - "modules": "commonjs" + "modules": "commonjs", + "include": ["@babel/plugin-proposal-class-properties"] } ], - "@babel/preset-typescript" + ["@babel/preset-typescript", { "allowDeclareFields": true }] ], "plugins": [ "@babel/plugin-proposal-numeric-separator", - "@babel/plugin-proposal-class-properties", "@babel/plugin-proposal-object-rest-spread", "@babel/plugin-syntax-dynamic-import", "@babel/plugin-transform-runtime" diff --git a/src/crypto/algorithms/base.ts b/src/crypto/algorithms/base.ts index 647300948bd..c7d4ccdf150 100644 --- a/src/crypto/algorithms/base.ts +++ b/src/crypto/algorithms/base.ts @@ -19,10 +19,10 @@ limitations under the License. */ import type { IMegolmSessionData } from "../../@types/crypto"; +import type { IContent, MatrixEvent, RoomMember } from "../../matrix"; import { MatrixClient } from "../../client"; import { Room } from "../../models/room"; import { OlmDevice } from "../OlmDevice"; -import { IContent, MatrixEvent, RoomMember } from "../../matrix"; import { Crypto, IEncryptedContent, IEventDecryptionResult, IncomingRoomKeyRequest } from ".."; import { DeviceInfo } from "../deviceinfo"; import { IRoomEncryption } from "../RoomList"; diff --git a/src/crypto/algorithms/megolm.ts b/src/crypto/algorithms/megolm.ts index 061e169e39b..2b3f48bbe96 100644 --- a/src/crypto/algorithms/megolm.ts +++ b/src/crypto/algorithms/megolm.ts @@ -245,7 +245,7 @@ export class MegolmEncryption extends EncryptionAlgorithm { cancel: () => void; }; - protected readonly roomId: string; + protected declare readonly roomId: string; private readonly prefixedLogger: PrefixedLogger; public constructor(params: IParams & Required>) { @@ -1290,7 +1290,7 @@ export class MegolmDecryption extends DecryptionAlgorithm { // this gets stubbed out by the unit tests. private olmlib = olmlib; - protected readonly roomId: string; + protected declare readonly roomId: string; private readonly prefixedLogger: PrefixedLogger; public constructor(params: DecryptionClassParams>>) { diff --git a/src/crypto/index.ts b/src/crypto/index.ts index ab588afce9f..1475e68b3fd 100644 --- a/src/crypto/index.ts +++ b/src/crypto/index.ts @@ -38,7 +38,7 @@ import { SecretStorage as LegacySecretStorage } from "./SecretStorage"; import { CrossSigningKey, ICreateSecretStorageOpts, IEncryptedEventInfo, IRecoveryKey } from "./api"; import { OutgoingRoomKeyRequestManager } from "./OutgoingRoomKeyRequestManager"; import { IndexedDBCryptoStore } from "./store/indexeddb-crypto-store"; -import { VerificationBase } from "./verification/Base"; +import type { VerificationBase } from "./verification/Base"; import { ReciprocateQRCode, SCAN_QR_CODE_METHOD, SHOW_QR_CODE_METHOD } from "./verification/QRCode"; import { SAS as SASVerification } from "./verification/SAS"; import { keyFromPassphrase } from "./key_passphrase"; diff --git a/src/crypto/verification/request/Channel.ts b/src/crypto/verification/request/Channel.ts index 48415f977e1..1ab08331fbc 100644 --- a/src/crypto/verification/request/Channel.ts +++ b/src/crypto/verification/request/Channel.ts @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { MatrixEvent } from "../../../models/event"; -import { VerificationRequest } from "./VerificationRequest"; +import type { MatrixEvent } from "../../../models/event"; +import type { VerificationRequest } from "./VerificationRequest"; export interface IVerificationChannel { request?: VerificationRequest; diff --git a/src/models/room-member.ts b/src/models/room-member.ts index e8fcfa60620..8312fc82d56 100644 --- a/src/models/room-member.ts +++ b/src/models/room-member.ts @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ +import type { MatrixEvent } from "./event"; import { getHttpUriForMxc } from "../content-repo"; import { removeDirectionOverrideChars, removeHiddenChars } from "../utils"; import { User } from "./user"; -import { MatrixEvent } from "./event"; import { RoomState } from "./room-state"; import { logger } from "../logger"; import { TypedEventEmitter } from "./typed-event-emitter"; diff --git a/src/models/user.ts b/src/models/user.ts index 054a17438f2..79c9fb0023e 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { MatrixEvent } from "./event"; +import type { MatrixEvent } from "./event"; import { TypedEventEmitter } from "./typed-event-emitter"; export enum UserEvent { diff --git a/src/utils.ts b/src/utils.ts index 1dba236c9c5..a40c8e7722d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -22,7 +22,7 @@ import unhomoglyph from "unhomoglyph"; import promiseRetry from "p-retry"; import { Optional } from "matrix-events-sdk"; -import { IEvent, MatrixEvent } from "./models/event"; +import type { IEvent, MatrixEvent } from "./models/event"; import { M_TIMESTAMP } from "./@types/location"; import { ReceiptType } from "./@types/read_receipts"; diff --git a/tsconfig.json b/tsconfig.json index 13fed86c47b..6dc306e67a2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "useDefineForClassFields": true, "target": "es2016", "experimentalDecorators": true, "esModuleInterop": true,