fast-shuffle: returns type based on argument (#38544)

This commit is contained in:
Piotr Roszatycki 2019-09-23 20:08:38 +02:00 committed by Ben Lichtman
parent 8238de91cf
commit 35362243fe
2 changed files with 5 additions and 5 deletions

View File

@ -2,8 +2,8 @@ import shuffle from 'fast-shuffle';
{
const d1 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
const d2 = shuffle(d1);
const d3 = shuffle(d1, () => 0.42);
const d2: string[] = shuffle(d1);
const d3: string[] = shuffle(d1, () => 0.42);
}
{
@ -12,6 +12,6 @@ import shuffle from 'fast-shuffle';
{ name: 'Betty', money: 20 },
{ name: 'Cindy', money: 15 }
];
const d2 = shuffle(d1);
const d3 = shuffle(d1, () => 0.42);
const d2: Array<{ name: string, money: number }> = shuffle(d1);
const d3: Array<{ name: string, money: number }> = shuffle(d1, () => 0.42);
}

View File

@ -3,4 +3,4 @@
// Definitions by: Piotr Roszatycki <https://github.com/dex4er>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export default function shuffle(deck: ReadonlyArray<any>, random?: () => number): any[];
export default function shuffle<T>(deck: ReadonlyArray<T>, random?: () => number): T[];