Skip to content

Commit

Permalink
fix: improve typings
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathantneal committed Aug 11, 2021
1 parent f07b1bf commit 5a66b10
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 86 deletions.
2 changes: 0 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@
},
"javascript.suggest.enabled": false,
"javascript.suggest.names": false,
"typescript.disableAutomaticTypeAcquisition": true,
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.tsserver.maxTsServerMemory": 8192
}
80 changes: 0 additions & 80 deletions packages/react/types/css-util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,86 +109,6 @@ export type CSS<
}
)


/** Returns a Style interface, leveraging the given media and style map. */
export type KnownCSS<
Media = Default.Media,
Theme = {},
ThemeMap = Default.ThemeMap,
Utils = {}
> = (
// nested at-rule css styles
& {
[K in Util.Prefixed<'@', keyof Media>]?: CSS<Media, Theme, ThemeMap, Utils>
}
// known property styles
& {
[K in keyof CSSProperties]?: (
| ValueByPropertyName<K>
| TokenByPropertyName<K, Theme, ThemeMap>
| CSS.Globals
| ThemeUtil.ScaleValue
)
}
// known utility styles
& {
[K in keyof Utils]?: (
K extends keyof CSSProperties
? unknown
: (
| (
Utils[K] extends (arg: infer P) => any
? P extends any[]
? (
$$PropertyValue extends keyof P[0]
? (
| ValueByPropertyName<P[0][$$PropertyValue]>
| TokenByPropertyName<P[0][$$PropertyValue], Theme, ThemeMap>
| CSS.Globals
| ThemeUtil.ScaleValue
)
: $$ScaleValue extends keyof P[0]
? (
| TokenByScaleName<P[0][$$ScaleValue], Theme>
| ThemeUtil.ScaleValue
)
: never
)[]
: $$PropertyValue extends keyof P
? (
| ValueByPropertyName<P[$$PropertyValue]>
| TokenByPropertyName<P[$$PropertyValue], Theme, ThemeMap>
| CSS.Globals
| ThemeUtil.ScaleValue
)
: $$ScaleValue extends keyof P
? (
| TokenByScaleName<P[$$ScaleValue], Theme>
| ThemeUtil.ScaleValue
)
: never
: never
)
)
)
}
// known theme styles
& {
[K in keyof ThemeMap]?: (
K extends keyof CSSProperties
? unknown
: K extends keyof CSSProperties
? unknown
: K extends keyof Utils
? unknown
: (
| CSS.Globals
| Util.Index
)
)
}
)

/** Unique symbol used to reference a property value. */
export declare const $$PropertyValue: unique symbol

Expand Down
7 changes: 3 additions & 4 deletions packages/react/types/stitches.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ export default interface Stitches<
Theme = {},
ThemeMap = Default.ThemeMap,
Utils = {},
CSS extends { [prelude: string]: unknown } = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>,
KnownCSS extends { [prelude: string]: unknown } = CSSUtil.KnownCSS<Media, Theme, ThemeMap, Utils>
CSS extends { [prelude: string]: unknown } = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
> {
config: {
prefix: Prefix
Expand Down Expand Up @@ -161,7 +160,7 @@ export default interface Stitches<
}
& {
[Prelude in keyof Composers[K]]:
Prelude extends keyof KnownCSS | 'compoundVariants' | 'defaultVariants' | 'variants'
Prelude extends keyof CSS | 'compoundVariants' | 'defaultVariants' | 'variants'
? unknown
: Composers[K][Prelude] extends Record<string, unknown>
? CSS
Expand Down Expand Up @@ -243,7 +242,7 @@ export default interface Stitches<
}
& {
[Prelude in keyof Composers[K]]:
Prelude extends keyof KnownCSS | 'compoundVariants' | 'defaultVariants' | 'variants'
Prelude extends keyof CSS | 'compoundVariants' | 'defaultVariants' | 'variants'
? unknown
: Composers[K][Prelude] extends Record<string, unknown>
? CSS
Expand Down

0 comments on commit 5a66b10

Please sign in to comment.