mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
Added pick-weight (#18693)
* Created definitions & tests for pick-weight 🎲
* Fix no-single-module
This commit is contained in:
committed by
Mohamed Hegazy
parent
26223f00d7
commit
4bcdebd32e
11
types/pick-weight/index.d.ts
vendored
Normal file
11
types/pick-weight/index.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Type definitions for pick-weight 1.0
|
||||
// Project: https://github.com/mock-end/pick-weight#readme
|
||||
// Definitions by: Roberts Slisans <https://github.com/rsxdalv>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Dummy function allows to avoid hard to kill or fix tslint warning
|
||||
// (exporting pluginFunc will make this a non-importable module)
|
||||
declare function weighted<T>(arr: T[], weights: number[]): T;
|
||||
// Let allows typescript to still use ES2015 style imports
|
||||
declare let y: typeof weighted;
|
||||
export = y;
|
||||
6
types/pick-weight/pick-weight-tests.ts
Normal file
6
types/pick-weight/pick-weight-tests.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import * as weight from "pick-weight";
|
||||
|
||||
const x = weight(["a", "b", "c"], [1, 2, 3]);
|
||||
|
||||
// Can only be applied since inferred type is string
|
||||
x === "string";
|
||||
22
types/pick-weight/tsconfig.json
Normal file
22
types/pick-weight/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"pick-weight-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/pick-weight/tslint.json
Normal file
1
types/pick-weight/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user