Skip to content

Commit 1c438e4

Browse files
authored
Update types for scripts.lib(): sample, pick, get_security_level (#226)
* Improve types for scripts.lib * Fix broken type
1 parent 43deef2 commit 1c438e4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

env.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
189189

190190
/** @returns A random element from `array`, selected with a random number generated using `rng`
191191
* (defaults to `Math.random`). */
192-
sample: (array: any[], rng?: ()=>number) => any
192+
sample: <T>(array: T[], rng?: ()=>number) => T
193193

194194
/** @returns Whether two MongoDB `ObjectId`s are equivalent. */ are_ids_eq: (id1: any, id2: any) => boolean
195195
/** Convert a MongoDB `ObjectId` to a string. */ id_to_str: (id: string | {$oid: string}) => any
@@ -270,7 +270,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
270270
map: <T, U>(array: T[], callback: (index: number, value: T) => U) => U[]
271271

272272
/** @returns A new object derived from `obj` with only the keys specified in `keys`. */
273-
pick: (obj: object, keys: string[]) => any
273+
pick: <TObj extends object, TKeys extends keyof TObj>(obj: TObj, keys: TKeys[]) => { [K in TKeys]: TObj[K] }
274274

275275
/** @returns An array with the elements from `array` in a random order. */ shuffle: <T>(array: T[]) => T[]
276276

@@ -298,7 +298,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
298298
security_level_names: [ "NULLSEC", "LOWSEC", "MIDSEC", "HIGHSEC", "FULLSEC" ]
299299

300300
/** @returns The string name of a numeric security level. */
301-
get_security_level_name: (security_level: number) => any
301+
get_security_level_name: (security_level: number) => string
302302

303303
/** @param result The return value of a call to `$db.i()` or `$db.r()`.
304304
* @param nModified The expected value of `result.nModified`.

0 commit comments

Comments
 (0)