From 6f61683fbf1607309aed9409ddcb60f0467a6965 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 14 Aug 2017 19:13:00 +0200 Subject: [PATCH] [dargs] add typings (#18889) --- types/dargs/dargs-tests.ts | 29 +++++++++++++++++++++++++++++ types/dargs/index.d.ts | 20 ++++++++++++++++++++ types/dargs/tsconfig.json | 22 ++++++++++++++++++++++ types/dargs/tslint.json | 1 + 4 files changed, 72 insertions(+) create mode 100644 types/dargs/dargs-tests.ts create mode 100644 types/dargs/index.d.ts create mode 100644 types/dargs/tsconfig.json create mode 100644 types/dargs/tslint.json diff --git a/types/dargs/dargs-tests.ts b/types/dargs/dargs-tests.ts new file mode 100644 index 0000000000..86ded8a0a8 --- /dev/null +++ b/types/dargs/dargs-tests.ts @@ -0,0 +1,29 @@ +import dargs = require('dargs'); + +const input = { + _: ['some', 'option'], + foo: 'bar', + hello: true, + cake: false, + camelCase: 5, + multiple: ['value', 'value2'], + pieKind: 'cherry', + sad: ':(' +}; + +const excludes = ['sad', /.*Kind$/]; +const includes = ['camelCase', 'multiple', 'sad', /^pie.*/]; +const aliases = {file: 'f'}; + +// $ExpectType string[] +dargs(input, {excludes}); +dargs(input, {excludes, includes}); +dargs(input, {includes}); +dargs({ + foo: 'bar', + hello: true, + file: 'baz' +}, {aliases}); +dargs({foo: 'bar'}, {useEquals: false}); +dargs({foo: 'bar'}, {ignoreFalse: true}); +dargs({fooBar: 'baz'}, {allowCamelCase: true}); diff --git a/types/dargs/index.d.ts b/types/dargs/index.d.ts new file mode 100644 index 0000000000..62ad42a9c1 --- /dev/null +++ b/types/dargs/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for dargs 5.1 +// Project: https://github.com/sindresorhus/dargs#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export = dargs; + +declare function dargs(input: object, options?: dargs.Options): string[]; + +declare namespace dargs { + interface Options { + excludes?: ReadonlyArray; + includes?: ReadonlyArray; + aliases?: { [key: string]: string }; + useEquals?: boolean; + ignoreFalse?: boolean; + allowCamelCase?: boolean; + } +} diff --git a/types/dargs/tsconfig.json b/types/dargs/tsconfig.json new file mode 100644 index 0000000000..fd5bee5051 --- /dev/null +++ b/types/dargs/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", + "dargs-tests.ts" + ] +} diff --git a/types/dargs/tslint.json b/types/dargs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/dargs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }