mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-14 09:02:40 +08:00
getopts: add library definitions.
This commit is contained in:
20
types/getopts/getopts-tests.ts
Normal file
20
types/getopts/getopts-tests.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import getopts = require('getopts');
|
||||
|
||||
getopts([]); // $ExpectType ParsedOptions
|
||||
getopts(['one', 'two']); // $ExpectType ParsedOptions
|
||||
getopts(['one', 'two'], { alias: { h: 'help' } }); // $ExpectType ParsedOptions
|
||||
getopts(['one', 'two'], { alias: { verbose: ['v', '--v'] } }); // $ExpectType ParsedOptions
|
||||
getopts(['one', 'two'], { boolean: ['verbose'] }); // $ExpectType ParsedOptions
|
||||
getopts(['one', 'two'], { default: { a: 1, b: 'c', d: true } }); // $ExpectType ParsedOptions
|
||||
getopts(['one', 'two'], { unknown: (name) => name === 'name' }); // $ExpectType ParsedOptions
|
||||
|
||||
// $ExpectType ParsedOptions
|
||||
getopts(
|
||||
['one', 'two'],
|
||||
{
|
||||
alias: { h: 'help' },
|
||||
boolean: ['verbose'],
|
||||
default: { a: 1, b: 'c', d: true },
|
||||
unknown: (name) => name === 'name'
|
||||
}
|
||||
);
|
||||
20
types/getopts/index.d.ts
vendored
Normal file
20
types/getopts/index.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Type definitions for getopts 2.0
|
||||
// Project: https://github.com/getopts/getopts#readme
|
||||
// Definitions by: Aleh Zasypkin <https://github.com/azasypkin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface ParsedOptions {
|
||||
_: string[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
alias?: { [key: string]: string | string[] };
|
||||
boolean?: string[];
|
||||
default?: { [key: string]: any };
|
||||
unknown?: (optionName: string) => boolean;
|
||||
}
|
||||
|
||||
declare function getopts(argv: string[], options?: Options): ParsedOptions;
|
||||
|
||||
export = getopts;
|
||||
23
types/getopts/tsconfig.json
Normal file
23
types/getopts/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"getopts-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/getopts/tslint.json
Normal file
1
types/getopts/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user