diff --git a/types/pick-weight/index.d.ts b/types/pick-weight/index.d.ts new file mode 100644 index 0000000000..f91da7ee72 --- /dev/null +++ b/types/pick-weight/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for pick-weight 1.0 +// Project: https://github.com/mock-end/pick-weight#readme +// Definitions by: Roberts Slisans +// 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(arr: T[], weights: number[]): T; +// Let allows typescript to still use ES2015 style imports +declare let y: typeof weighted; +export = y; diff --git a/types/pick-weight/pick-weight-tests.ts b/types/pick-weight/pick-weight-tests.ts new file mode 100644 index 0000000000..5707b1c598 --- /dev/null +++ b/types/pick-weight/pick-weight-tests.ts @@ -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"; diff --git a/types/pick-weight/tsconfig.json b/types/pick-weight/tsconfig.json new file mode 100644 index 0000000000..493177c8f6 --- /dev/null +++ b/types/pick-weight/tsconfig.json @@ -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" + ] +} diff --git a/types/pick-weight/tslint.json b/types/pick-weight/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/pick-weight/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }