Added pick-weight (#18693)

* Created definitions & tests for pick-weight 🎲

* Fix no-single-module
This commit is contained in:
Roberts Slisans
2017-08-09 00:22:46 +03:00
committed by Mohamed Hegazy
parent 26223f00d7
commit 4bcdebd32e
4 changed files with 40 additions and 0 deletions

11
types/pick-weight/index.d.ts vendored Normal file
View 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;

View 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";

View 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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }