DefinitelyTyped/types/yargs-parser/yargs-parser-tests.ts
Miles Johnson e2f685d623 Add new @types/yargs-parser package (#29409)
* Add yargs-parser package.

* Add tests.

* More polish.

* Bump version.

* Switch to namespace.

* More work.

* Import yargs type.
2018-10-11 15:50:43 -07:00

48 lines
774 B
TypeScript

import parse, { Arguments } from 'yargs-parser';
parse('--foo -bar');
parse(['--foo', '-bar']);
parse(['--foo', '-bar'], {
boolean: ['b', 'a', 'r'],
});
// prettier-ignore
// $ExpectError
parse(['--foo', '-bar'], {
string: 123,
});
parse(['--foo', '-bar'], {
// $ExpectError
unknown: ['b', 'a', 'r'],
});
parse(['--foo', '-bar'], {
alias: { foo: 'foo', bar: ['bar'] },
'--': true,
});
parse(['--foo', '-bar'], {
configuration: {
'dot-notation': false,
},
});
parse(['--foo', '-bar'], {
envPrefix: 'YARG_',
configuration: {
// $ExpectError
'fake-key': true,
},
});
parse.detailed('--foo -bar');
parse.detailed(['--foo', '-bar']);
parse.detailed(['--foo'], {});
function test(args: Arguments) {}