Skip to content

Commit c02c3bd

Browse files
committed
Convert helper.js to typescript
1 parent 9a9e467 commit c02c3bd

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

tests/helper.js renamed to tests/helper.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1-
const { DeviceLists, RequestType, KeysUploadRequest, KeysQueryRequest } = require("@matrix-org/matrix-sdk-crypto-wasm");
1+
/*
2+
Copyright 2022-2025 The Matrix.org Foundation C.I.C.
23
3-
function* zip(...arrays) {
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import { DeviceLists, RequestType, KeysUploadRequest, KeysQueryRequest } from "@matrix-org/matrix-sdk-crypto-wasm";
18+
19+
export function* zip(...arrays) {
420
const len = Math.min(...arrays.map((array) => array.length));
521

622
for (let nth = 0; nth < len; ++nth) {
@@ -10,7 +26,7 @@ function* zip(...arrays) {
1026

1127
// Add a machine to another machine, i.e. be sure a machine knows
1228
// another exists.
13-
async function addMachineToMachine(machineToAdd, machine) {
29+
export async function addMachineToMachine(machineToAdd: OlmMachine, machine: OlmMachine): Promise<void> {
1430
const toDeviceEvents = JSON.stringify([]);
1531
const changedDevices = new DeviceLists();
1632
const oneTimeKeyCounts = new Map();
@@ -88,8 +104,3 @@ async function addMachineToMachine(machineToAdd, machine) {
88104
expect(marked).toStrictEqual(true);
89105
}
90106
}
91-
92-
module.exports = {
93-
zip,
94-
addMachineToMachine,
95-
};

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"extends": "@tsconfig/node18/tsconfig.json",
33
"compilerOptions": {
44
"lib": ["DOM"],
5-
"allowJs": true
5+
"allowJs": true,
6+
// Allow .ts file extensions in `import`, otherwise Jest can't find `helper.ts`.
7+
"allowImportingTsExtensions": true
68
},
79
"typedocOptions": {
810
"entryPoints": ["index.d.ts"],

0 commit comments

Comments
 (0)