Skip to content

Commit

Permalink
fix: Default createStyles vars to empty object (#2488)
Browse files Browse the repository at this point in the history
Allow booleans on modifiers in Stencils. We need to default the `vars` config in Stencils to allow the `MaybeBoolean` type to work. Otherwise we'll get `vars` defaulting to `Record<string, string> | Record<Record<string, string>` which won't be compatible if `modifiers` have a `boolean` type. This won't work: `<Record<string, string> & { someKey?: boolean }`. `Record<string, string>` is too overly permissive and we need to default `vars` to an empty object to avoid widening the type.

[category:Components]
  • Loading branch information
NicholasBoll authored Dec 21, 2023
1 parent 190a7cf commit fdfe9e0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/styling/lib/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ type VariableValuesStencil<
*/
export function createStencil<
M extends StencilModifierConfig<V>,
V extends Record<string, string> | Record<string, Record<string, string>>,
V extends Record<string, string> | Record<string, Record<string, string>> = {},
ID extends string = never
>(config: StencilConfig<M, V, ID>, id?: ID): Stencil<M, V, ID> {
const {vars, base, modifiers, compound, defaultModifiers} = config;
Expand Down

0 comments on commit fdfe9e0

Please sign in to comment.