Skip to content

Commit

Permalink
Improve TypeScript types (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
voxpelli authored Oct 11, 2022
1 parent c6db15a commit 6c57fc8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import {PackageJson} from 'type-fest';
import {
CamelCasedProperties,
PackageJson,
} from 'type-fest';

export type FlagType = 'string' | 'boolean' | 'number';

Expand Down Expand Up @@ -246,7 +249,7 @@ export interface Result<Flags extends AnyFlags> {
/**
Flags converted to camelCase excluding aliases.
*/
flags: TypedFlags<Flags> & Record<string, unknown>;
flags: CamelCasedProperties<TypedFlags<Flags>> & Record<string, unknown>;

/**
Flags converted camelCase including aliases.
Expand Down
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ expectType<PackageJson>(result.pkg);
expectType<string>(result.help);

expectType<boolean | undefined>(result.flags.foo);
expectType<unknown>(result.flags.fooBar);
expectType<number | undefined>(result.flags.fooBar);
expectType<string>(result.flags.bar);
expectType<string[] | undefined>(result.flags.abc);
expectType<boolean | undefined>(result.unnormalizedFlags.foo);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"read-pkg-up": "^8.0.0",
"redent": "^4.0.0",
"trim-newlines": "^4.0.2",
"type-fest": "^1.2.2",
"type-fest": "^3.1.0",
"yargs-parser": "^20.2.9"
},
"devDependencies": {
Expand Down

0 comments on commit 6c57fc8

Please # to comment.