mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
13 lines
345 B
TypeScript
13 lines
345 B
TypeScript
import weightedRandomObject from 'weighted-random-object';
|
|
|
|
interface MyObject {
|
|
data: string;
|
|
weight: number;
|
|
}
|
|
|
|
const objs: MyObject[] = [{ data: 'a', weight: 7 }, { data: 'b', weight: 5 }];
|
|
|
|
weightedRandomObject(objs); // $ExpectType MyObject
|
|
|
|
weightedRandomObject([{ f: 5, weight: 1 }, { f: 9, weight: 2 }]).f; // $ExpectType number
|