Created definitions & tests for pick-weight 🎲

This commit is contained in:
Roberts Slisans
2017-08-07 17:56:08 +03:00
parent 02ff752907
commit 99c8fcc889
4 changed files with 42 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
// 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
declare module "pick-weight" {
// Dummy function allows to avoid hard to kill or fix tslint warning
// (exporting pluginFunc will make this a non-importable module)
function weighted<T>(arr: T[], weights: number[]): T;
// Let allows typescript to still use ES2015 style imports
let y: typeof weighted;
export = y;
}
+6
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";
+22
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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }