diff --git a/types/mri/index.d.ts b/types/mri/index.d.ts new file mode 100644 index 0000000000..6e9eb44235 --- /dev/null +++ b/types/mri/index.d.ts @@ -0,0 +1,38 @@ +// Type definitions for mri 1.1 +// Project: https://github.com/lukeed/mri +// Definitions by: Brendan Forster , Jed Fox +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export = mri; + +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 new file mode 100644 index 0000000000..c766587db1 --- /dev/null +++ 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/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..bc2968ccad --- /dev/null +++ b/types/mri/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "strict-export-declare-modifiers": false, + "prefer-method-signature": false + } +}