[dargs] add typings (#18889)

This commit is contained in:
Dimitri Benin
2017-08-14 19:13:00 +02:00
committed by Mohamed Hegazy
parent 8718d318ab
commit 6f61683fbf
4 changed files with 72 additions and 0 deletions

View File

@@ -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});

20
types/dargs/index.d.ts vendored Normal file
View File

@@ -0,0 +1,20 @@
// Type definitions for dargs 5.1
// Project: https://github.com/sindresorhus/dargs#readme
// Definitions by: BendingBender <https://github.com/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<string | RegExp>;
includes?: ReadonlyArray<string | RegExp>;
aliases?: { [key: string]: string };
useEquals?: boolean;
ignoreFalse?: boolean;
allowCamelCase?: boolean;
}
}

22
types/dargs/tsconfig.json Normal file
View File

@@ -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"
]
}

1
types/dargs/tslint.json Normal file
View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }