Skip to content

Commit a92eb63

Browse files
committed
Optimize typing
1 parent 75cf638 commit a92eb63

3 files changed

Lines changed: 12 additions & 16 deletions

File tree

packages/react/src/types/props/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ export type DevupCommonProps = Merge<
3131
DevupShortcutsProps
3232
>
3333

34-
export interface DevupProps
35-
extends DevupCommonProps,
36-
DevupSelectorProps,
34+
export interface DevupProps extends DevupCommonProps, DevupSelectorProps {}
35+
36+
export interface DevupPropsWithTheme
37+
extends DevupProps,
3738
DevupThemeSelectorProps {}
3839

3940
export interface DevupComponentProps<T extends React.ElementType>
40-
extends DevupProps {
41+
extends DevupPropsWithTheme {
4142
as?: T
4243
styleVars?: Record<string, string | undefined>
4344
}

packages/react/src/types/props/selector/index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Pseudos } from 'csstype'
22

33
import type { ResponsiveValue } from '../../responsive-value'
44
import type { DevupTheme } from '../../theme'
5-
import type { DevupCommonProps } from '../index'
5+
import type { DevupProps } from '../index'
66

77
type CamelCase<S extends string> =
88
S extends Lowercase<S>
@@ -13,18 +13,13 @@ type CamelCase<S extends string> =
1313

1414
type PascalCase<S extends string> = Capitalize<CamelCase<S>>
1515

16+
type SelectorProps = ResponsiveValue<DevupProps | string | false>
1617
export type DevupThemeSelectorProps = keyof DevupTheme extends undefined
17-
? Record<`_theme${string}`, DevupCommonProps & DevupSelectorProps>
18+
? Record<`_theme${string}`, SelectorProps>
1819
: {
19-
[K in keyof DevupTheme as `_theme${PascalCase<K>}`]?: DevupCommonProps &
20-
DevupSelectorProps
20+
[K in keyof DevupTheme as `_theme${PascalCase<K>}`]?: SelectorProps
2121
}
2222

23-
type SelectorProps = ResponsiveValue<
24-
| (DevupCommonProps & DevupSelectorProps & DevupThemeSelectorProps)
25-
| string
26-
| false
27-
>
2823
type NormalSelector = Exclude<
2924
Pseudos,
3025
`:-${string}` | `::-${string}` | `${string}()`

packages/react/src/utils/css.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import type { DevupProps } from '../types/props'
1+
import type { DevupPropsWithTheme } from '../types/props'
22

3-
export function css(props: DevupProps): string
3+
export function css(props: DevupPropsWithTheme): string
44
export function css(strings: TemplateStringsArray): string
55
export function css(): string
66

77
export function css(
88
// eslint-disable-next-line @typescript-eslint/no-unused-vars
9-
strings?: TemplateStringsArray | DevupProps,
9+
strings?: TemplateStringsArray | DevupPropsWithTheme,
1010
): string {
1111
throw new Error('Cannot run on the runtime')
1212
}

0 commit comments

Comments
 (0)