Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit 4d90414

Browse files
author
Akim
authored
fix(js-client): Remove union with undefined of methods for getting random peer (#417)
Fix types
1 parent 5d7ae85 commit 4d90414

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/core/js-client/src/network.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,23 @@ export const kras: Relay[] = [
165165
},
166166
];
167167

168-
export const randomKras = () => {
168+
export const randomKras = (): Relay => {
169169
return randomItem(kras);
170170
};
171171

172-
export const randomTestNet = () => {
172+
export const randomTestNet = (): Relay => {
173173
return randomItem(testNet);
174174
};
175175

176-
export const randomStage = () => {
176+
export const randomStage = (): Relay => {
177177
return randomItem(stage);
178178
};
179179

180-
function randomItem(arr: Relay[]) {
180+
function randomItem(arr: Relay[]): Relay {
181181
const index = randomInt(0, arr.length);
182-
return arr[index];
182+
// This array access always defined
183+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
184+
return arr[index] as Relay;
183185
}
184186

185187
function randomInt(min: number, max: number) {

0 commit comments

Comments
 (0)