fix(js-client): Remove union with undefined of methods for getting random peer (#417)

Fix types
This commit is contained in:
Akim 2024-01-11 22:20:08 +07:00 committed by GitHub
parent 5d7ae85e58
commit 4d90414190
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -165,21 +165,23 @@ export const kras: Relay[] = [
},
];
export const randomKras = () => {
export const randomKras = (): Relay => {
return randomItem(kras);
};
export const randomTestNet = () => {
export const randomTestNet = (): Relay => {
return randomItem(testNet);
};
export const randomStage = () => {
export const randomStage = (): Relay => {
return randomItem(stage);
};
function randomItem(arr: Relay[]) {
function randomItem(arr: Relay[]): Relay {
const index = randomInt(0, arr.length);
return arr[index];
// This array access always defined
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
return arr[index] as Relay;
}
function randomInt(min: number, max: number) {