File tree Expand file tree Collapse file tree 4 files changed +34
-7
lines changed
Expand file tree Collapse file tree 4 files changed +34
-7
lines changed Original file line number Diff line number Diff line change 1919 "version" : " 1.0.12" ,
2020 "type" : " module" ,
2121 "scripts" : {
22- "lint" : " eslint" ,
22+ "lint" : " eslint && tsc --noEmit " ,
2323 "build" : " tsc && vite build"
2424 },
2525 "publishConfig" : {
Original file line number Diff line number Diff line change 1- import type { DevupCommonProps , DevupComponentProps } from '..'
1+ import { Property } from 'csstype'
2+
3+ import type { ResponsiveValue } from '../../responsive-value'
4+ import type { DevupCommonProps , DevupComponentProps , DevupProps } from '..'
5+ import type { Selectors } from '../selector'
26
37describe ( 'index' , ( ) => {
48 it ( 'DevupCommonProps' , ( ) => {
@@ -8,6 +12,16 @@ describe('index', () => {
812 } )
913 } )
1014
15+ it ( 'DevupProps' , ( ) => {
16+ expectTypeOf < DevupProps > ( )
17+ . toHaveProperty ( 'bg' )
18+ . toEqualTypeOf < ResponsiveValue < Property . Background > > ( )
19+ } )
20+
21+ it ( 'Selectors' , ( ) => {
22+ expectTypeOf < Selectors > ( ) . toHaveProperty ( '&:hover' )
23+ } )
24+
1125 it ( 'DevupCommonProps _selector' , ( ) => {
1226 assertType < DevupComponentProps < 'div' > > ( {
1327 _hover : {
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ type CamelCase<S extends string> =
1313
1414type PascalCase < S extends string > = Capitalize < CamelCase < S > >
1515
16- type SelectorProps = ResponsiveValue < DevupProps | string | false >
16+ export type SelectorProps < T = DevupProps > = ResponsiveValue < T | string | false >
1717export type DevupThemeSelectorProps = keyof DevupTheme extends undefined
1818 ? Record < `_theme${string } `, SelectorProps >
1919 : {
@@ -24,22 +24,29 @@ type NormalSelector = Exclude<
2424 Pseudos ,
2525 `:-${string } ` | `::-${string } ` | `${string } ()`
2626>
27- type ExtractSelector < T > = T extends `::${infer R } `
27+ type ExtractSelector < T = NormalSelector > = T extends `::${infer R } `
2828 ? R
2929 : T extends `:${infer R } `
3030 ? R
3131 : never
3232export type CommonSelectorProps = {
33- [ K in ExtractSelector < NormalSelector > as
33+ [ K in ExtractSelector as
3434 | `_${CamelCase < K > } `
3535 | `_group${PascalCase < K > } `] ?: SelectorProps
3636}
3737
38+ export type Selectors = Partial <
39+ Record <
40+ ( string & { } ) | `&${NormalSelector } ` | `_${CamelCase < ExtractSelector > } `,
41+ SelectorProps
42+ >
43+ >
44+
3845export interface DevupSelectorProps extends CommonSelectorProps {
3946 // media query
4047 _print ?: SelectorProps
4148
42- selectors ?: Record < string , SelectorProps >
49+ selectors ?: Selectors
4350
4451 styleOrder ?: number
4552}
Original file line number Diff line number Diff line change @@ -6,6 +6,12 @@ describe('css', () => {
66 expect ( ( ) => css ( 'class name' as any ) ) . toThrowError (
77 'Cannot run on the runtime' ,
88 )
9- expect ( ( ) => css ( ) ) . toThrowError ( 'Cannot run on the runtime' )
9+ expect ( ( ) =>
10+ css ( {
11+ selectors : {
12+ '&::after' : { } ,
13+ } ,
14+ } ) ,
15+ ) . toThrowError ( 'Cannot run on the runtime' )
1016 } )
1117} )
You can’t perform that action at this time.
0 commit comments