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 (#149)
  • Loading branch information
totto2727 authored Apr 26, 2023
1 parent f3dd56e commit c88e3ec
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

6 comments on commit c88e3ec

@vercel
Copy link

@vercel vercel bot commented on c88e3ec Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

example-react-with-css-modules – ./examples/react-with-css-modules

cva-react-with-css-modules.vercel.app
example-react-with-css-modules-class-variance-authority.vercel.app
example-react-with-css-modu-git-936303-class-variance-authority.vercel.app

@vercel
Copy link

@vercel vercel bot commented on c88e3ec Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on c88e3ec Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

example-astro-with-tailwindcss – ./examples/astro-with-tailwindcss

example-astro-with-tailwind-git-ecbae6-class-variance-authority.vercel.app
example-astro-with-tailwindcss-class-variance-authority.vercel.app
cva-astro-with-tailwindcss.vercel.app

@vercel
Copy link

@vercel vercel bot commented on c88e3ec Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on c88e3ec Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on c88e3ec Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

example-react-with-tailwindcss – ./examples/react-with-tailwindcss

cva-react-with-tailwindcss.vercel.app
example-react-with-tailwind-git-27bf08-class-variance-authority.vercel.app
example-react-with-tailwindcss-class-variance-authority.vercel.app

Please # to comment.