From cd0eff9476dbe391e5adb27ace4db369e615e27e Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 21 Aug 2017 11:50:25 +1000 Subject: [PATCH 1/3] scaffolding package for mri --- types/mri/index.d.ts | 13 +++++++++++++ types/mri/mri-tests.ts | 0 types/mri/tsconfig.json | 22 ++++++++++++++++++++++ types/mri/tslint.json | 1 + 4 files changed, 36 insertions(+) create mode 100644 types/mri/index.d.ts create mode 100644 types/mri/mri-tests.ts create mode 100644 types/mri/tsconfig.json create mode 100644 types/mri/tslint.json diff --git a/types/mri/index.d.ts b/types/mri/index.d.ts new file mode 100644 index 0000000000..d015594de1 --- /dev/null +++ b/types/mri/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for mri 1.1 +// Project: https://github.com/lukeed/mri +// Definitions by: Brendan Forster +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = mri; + +declare function mri(args: any, opts: any): any; + +declare namespace mri { + const prototype: { + }; +} diff --git a/types/mri/mri-tests.ts b/types/mri/mri-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/mri/tsconfig.json b/types/mri/tsconfig.json new file mode 100644 index 0000000000..8e11e720ae --- /dev/null +++ b/types/mri/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mri-tests.ts" + ] +} \ No newline at end of file diff --git a/types/mri/tslint.json b/types/mri/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mri/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 8308513f82ce09c135572487d325bcf287a8a6ce Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 21 Aug 2017 12:20:06 +1000 Subject: [PATCH 2/3] actually import the declaration --- types/mri/index.d.ts | 27 ++++++++++++++++++++++++++- types/mri/mri-tests.ts | 7 +++++++ types/mri/tslint.json | 8 +++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/types/mri/index.d.ts b/types/mri/index.d.ts index d015594de1..c1808211db 100644 --- a/types/mri/index.d.ts +++ b/types/mri/index.d.ts @@ -2,12 +2,37 @@ // Project: https://github.com/lukeed/mri // Definitions by: Brendan Forster // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 export = mri; -declare function mri(args: any, opts: any): any; +declare function mri(args: ReadonlyArray, options?: mri.Options): mri.Argv; declare namespace mri { const prototype: { }; + + /** A string or array of strings */ + type ArrayOrString = string | ReadonlyArray; + + /** An object with any keys whose values conform to a specific type */ + interface DictionaryObject { + [key: string]: T; + } + + interface Options { + /** Additional aliases for specific flags */ + alias?: DictionaryObject; + /** A flag or array of flags whose values are boolean */ + boolean?: ArrayOrString; + /** Default values for flags */ + default?: DictionaryObject; + string?: ArrayOrString; + unknown?: (flag: string) => void; + } + + interface Argv extends DictionaryObject { + /** anything after `--` or between options */ + _: ReadonlyArray; + } } diff --git a/types/mri/mri-tests.ts b/types/mri/mri-tests.ts index e69de29bb2..c766587db1 100644 --- a/types/mri/mri-tests.ts +++ b/types/mri/mri-tests.ts @@ -0,0 +1,7 @@ +import * as mri from 'mri'; + +const first = mri(['--foo', 'bar']); + +const second = mri(['--foo', 'bar'], { + default: { foo: true, baz: 'hello', bat: 42 } +}); diff --git a/types/mri/tslint.json b/types/mri/tslint.json index 3db14f85ea..bc2968ccad 100644 --- a/types/mri/tslint.json +++ b/types/mri/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "strict-export-declare-modifiers": false, + "prefer-method-signature": false + } +} From 460bc42e7523ee8140eeec38e98a2a2461f206df Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 21 Aug 2017 12:20:43 +1000 Subject: [PATCH 3/3] add another reviewer --- types/mri/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/mri/index.d.ts b/types/mri/index.d.ts index c1808211db..6e9eb44235 100644 --- a/types/mri/index.d.ts +++ b/types/mri/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for mri 1.1 // Project: https://github.com/lukeed/mri -// Definitions by: Brendan Forster +// Definitions by: Brendan Forster , Jed Fox // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4