mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for knuth-shuffle (#41259)
* Add types for knuth-shuffle This adds types for the [`knuth-shuffle`](https://www.npmjs.com/package/knuth-shuffle) package. * Correct return type to be same as passed array This corrects the return type for the `knuthShuffle` function, as it returns an array of the same type (specifically, the same array!), rather than `void`. * Correct tests
This commit is contained in:
parent
fe47c041d5
commit
809c9fe482
6
types/knuth-shuffle/index.d.ts
vendored
Normal file
6
types/knuth-shuffle/index.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
// Type definitions for knuth-shuffle 1.0
|
||||
// Project: https://git.coolaj86.com/coolaj86/knuth-shuffle.js
|
||||
// Definitions by: Chris Atkin <https://github.com/atkinchris>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function knuthShuffle<T>(array: T[]): T[];
|
||||
4
types/knuth-shuffle/knuth-shuffle-tests.ts
Normal file
4
types/knuth-shuffle/knuth-shuffle-tests.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { knuthShuffle } from "knuth-shuffle";
|
||||
|
||||
knuthShuffle([4, 8, 15, 16, 23, 42]); // $ExpectType number[]
|
||||
knuthShuffle(['a', 'b', 'c', 'd']); // $ExpectType string[]
|
||||
23
types/knuth-shuffle/tsconfig.json
Normal file
23
types/knuth-shuffle/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"knuth-shuffle-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/knuth-shuffle/tslint.json
Normal file
1
types/knuth-shuffle/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user