Skip to content

Commit

Permalink
fix: Added explicit undefined type to support exactOptionalPropertyTy…
Browse files Browse the repository at this point in the history
…pes option
  • Loading branch information
totto2727 committed Apr 24, 2023
1 parent 3e7240b commit 1b9f84d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/class-variance-authority/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ export const cx = <T extends CxOptions>(...classes: T): CxReturn =>
type ConfigSchema = Record<string, Record<string, ClassValue>>;

type ConfigVariants<T extends ConfigSchema> = {
[Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null;
[Variant in keyof T]?: StringToBoolean<keyof T[Variant]> | null | undefined;
};
type ConfigVariantsMulti<T extends ConfigSchema> = {
[Variant in keyof T]?:
| StringToBoolean<keyof T[Variant]>
| StringToBoolean<keyof T[Variant]>[];
| StringToBoolean<keyof T[Variant]>[]
| undefined;
};

type Config<T> = T extends ConfigSchema
Expand Down
8 changes: 6 additions & 2 deletions packages/cva/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ export const cx = <T extends CxOptions>(...classes: T): CxReturn =>
type VariantShape = Record<string, Record<string, ClassValue>>;

type VariantSchema<V extends VariantShape> = {
[Variant in keyof V]?: StringToBoolean<keyof V[Variant]> | "unset";
[Variant in keyof V]?:
| StringToBoolean<keyof V[Variant]>
| "unset"
| undefined;
};

type VariantSchemaMultiple<V extends VariantShape> = {
[Variant in keyof V]?:
| StringToBoolean<keyof V[Variant]>
| StringToBoolean<keyof V[Variant]>[];
| StringToBoolean<keyof V[Variant]>[]
| undefined;
};

type ConfigBase = { base?: ClassValue };
Expand Down

0 comments on commit 1b9f84d

Please # to comment.