From 99c8fcc889813479a454ca3b73aec35f53caec31 Mon Sep 17 00:00:00 2001 From: Roberts Slisans Date: Mon, 7 Aug 2017 17:56:08 +0300 Subject: [PATCH 1/4] =?UTF-8?q?Created=20definitions=20&=20tests=20for=20p?= =?UTF-8?q?ick-weight=20=F0=9F=8E=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/pick-weight/index.d.ts | 13 +++++++++++++ types/pick-weight/pick-weight-tests.ts | 6 ++++++ types/pick-weight/tsconfig.json | 22 ++++++++++++++++++++++ types/pick-weight/tslint.json | 1 + 4 files changed, 42 insertions(+) create mode 100644 types/pick-weight/index.d.ts create mode 100644 types/pick-weight/pick-weight-tests.ts create mode 100644 types/pick-weight/tsconfig.json create mode 100644 types/pick-weight/tslint.json diff --git a/types/pick-weight/index.d.ts b/types/pick-weight/index.d.ts new file mode 100644 index 0000000000..9320cde537 --- /dev/null +++ b/types/pick-weight/index.d.ts @@ -0,0 +1,13 @@ +// 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 + +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(arr: T[], weights: number[]): T; + // Let allows typescript to still use ES2015 style imports + 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" } From c490fb9147cc37c5bd9aea69f034f3fc3781007c Mon Sep 17 00:00:00 2001 From: Roberts Slisans Date: Mon, 7 Aug 2017 18:07:49 +0300 Subject: [PATCH 2/4] Fix no-single-module --- types/pick-weight/index.d.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/types/pick-weight/index.d.ts b/types/pick-weight/index.d.ts index 9320cde537..f91da7ee72 100644 --- a/types/pick-weight/index.d.ts +++ b/types/pick-weight/index.d.ts @@ -3,11 +3,9 @@ // Definitions by: Roberts Slisans // 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(arr: T[], weights: number[]): T; - // Let allows typescript to still use ES2015 style imports - let y: typeof weighted; - export = y; -} +// 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; From 6fb2d868017a0a216340ab4df5c915af5371ac58 Mon Sep 17 00:00:00 2001 From: Roberts Slisans Date: Wed, 9 Aug 2017 12:05:17 +0300 Subject: [PATCH 3/4] Added uniqid definition --- types/uniqid/index.d.ts | 13 +++++++++++++ types/uniqid/tsconfig.json | 22 ++++++++++++++++++++++ types/uniqid/tslint.json | 1 + types/uniqid/uniqid-tests.ts | 7 +++++++ 4 files changed, 43 insertions(+) create mode 100644 types/uniqid/index.d.ts create mode 100644 types/uniqid/tsconfig.json create mode 100644 types/uniqid/tslint.json create mode 100644 types/uniqid/uniqid-tests.ts diff --git a/types/uniqid/index.d.ts b/types/uniqid/index.d.ts new file mode 100644 index 0000000000..e3853a64a3 --- /dev/null +++ b/types/uniqid/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for uniqid 4.1 +// Project: http://github.com/adamhalasz/diet-uniqid/ +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Commmon function signature +declare function f(prefix: string): string; + +// let x -> Workaround for ES6 imports +// Combined type because of assigning to function object in original module +declare let x: typeof f & { process: typeof f } & { time: typeof f }; + +export = x; diff --git a/types/uniqid/tsconfig.json b/types/uniqid/tsconfig.json new file mode 100644 index 0000000000..437a215958 --- /dev/null +++ b/types/uniqid/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", + "uniqid-tests.ts" + ] +} diff --git a/types/uniqid/tslint.json b/types/uniqid/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/uniqid/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/uniqid/uniqid-tests.ts b/types/uniqid/uniqid-tests.ts new file mode 100644 index 0000000000..f0f56aa2fd --- /dev/null +++ b/types/uniqid/uniqid-tests.ts @@ -0,0 +1,7 @@ +import * as uniqid from "uniqid"; + +const uniqueID = uniqid("123"); +const processString = uniqid.process("123"); +const timeString = uniqid.time("123"); + +if (uniqueID === "" && processString === "" && timeString === "") { /**/ } From 8cb51be625fbba0988cba5847363dc56eed3eeee Mon Sep 17 00:00:00 2001 From: Roberts Slisans Date: Wed, 23 Aug 2017 11:06:26 +0300 Subject: [PATCH 4/4] Fix for no documents found - make results optional --- types/mongoose-simple-random/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/mongoose-simple-random/index.d.ts b/types/mongoose-simple-random/index.d.ts index 16b1c21483..679ba1fbee 100644 --- a/types/mongoose-simple-random/index.d.ts +++ b/types/mongoose-simple-random/index.d.ts @@ -15,7 +15,7 @@ declare module 'mongoose-simple-random' { declare module "mongoose" { interface Model extends NodeJS.EventEmitter, ModelProperties { - findRandom(conditions: Object, projection?: Object | null, options?: Object | null, callback?: (err: any, res: T[]) => void) + findRandom(conditions: Object, projection?: Object | null, options?: Object | null, callback?: (err: any, res?: T[]) => void) : void; } }