Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Added explicit undefined type to support exactOptionalPropertyTypes option #149

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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