Skip to content

Commit

Permalink
make options required
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell committed Jan 28, 2024
1 parent 36b34fe commit ac20f23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,10 @@ const cli = meow(`
foo(cli.input.at(0), cli.flags);
```
*/
export default function meow<Flags extends AnyFlags>(helpMessage: string, options?: Options<Flags>): Result<Flags>;
export default function meow<Flags extends AnyFlags>(options?: Options<Flags>): Result<Flags>;
// TODO: should these be optional? importMeta is always needed
export default function meow<Flags extends AnyFlags>(helpMessage: string, options: Options<Flags>): Result<Flags>;
export default function meow<Flags extends AnyFlags>(options: Options<Flags>): Result<Flags>;

export default function meow<Flags extends AnyFlags>(helpMessage?: string | Options<Flags>, options?: Options<Flags>): Result<Flags> {
export default function meow<Flags extends AnyFlags>(helpMessage: string | Options<Flags>, options?: Options<Flags>): Result<Flags> {
if (typeof helpMessage !== 'string') {
options = helpMessage;
helpMessage = '';
Expand Down
3 changes: 2 additions & 1 deletion test-d/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import meow from '../source/index.js';

const importMeta = import.meta;

expectType<Result<never>>(meow('Help text'));
expectError(meow('Help text'));
expectError(meow('Help text', {}));
expectType<Result<never>>(meow('Help text', {importMeta, hardRejection: false}));
expectAssignable<{flags: {foo: number}}>(
meow({importMeta: import.meta, flags: {foo: {type: 'number', isRequired: true}}}),
Expand Down

0 comments on commit ac20f23

Please sign in to comment.