File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -346,22 +346,35 @@ if (import.meta.vitest) {
346346
347347 describe . concurrent ( "css.with()" , ( ) => {
348348 it ( "css.with() with type restrictions" , ( ) => {
349- const myCss = css . with < {
349+ const myCss1 = css . with < {
350350 color : true ;
351351 background : "blue" | "grey" ;
352352 border : false ;
353353 } > ( ) ;
354354
355- myCss ( {
355+ myCss1 ( {
356356 color : "red" , // Allow all properties
357357 background : "blue" , // Only some properties are allowed
358358 // @ts -expect-error: border is not allowed
359359 border : "none"
360360 } ) ;
361- myCss ( {
361+ myCss1 ( {
362+ color : "red" ,
362363 // @ts -expect-error: background is allowed only "blue" or "grey"
363364 background : "red"
364365 } ) ;
366+ // @ts -expect-error: color is required
367+ myCss1 ( {
368+ background : "blue"
369+ } ) ;
370+ // @ts -expect-error: background is required
371+ myCss1 ( {
372+ color : "red"
373+ } ) ;
374+
375+ const myCss2 = css . with < { size : number ; radius ?: number } > ( ) ;
376+ // @ts -expect-error: size is required
377+ myCss2 . raw ( { radius : 10 } ) ;
365378 } ) ;
366379
367380 it ( "Basic callback transformation" , ( ) => {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ type IsRequired<T, K extends keyof T> =
99export type RestrictCSSRule < T extends CSSRule > = {
1010 [ K in keyof T as T [ K ] extends false ? never : K ] : T [ K ] extends true
1111 ? K extends keyof CSSRule
12- ? CSSRule [ K ]
12+ ? NonNullable < CSSRule [ K ] >
1313 : never
1414 : T [ K ] ;
1515} extends infer U
You can’t perform that action at this time.
0 commit comments