Skip to content

Commit

Permalink
Merge pull request stitchesjs#689 from modulz/jn.roadmap-1-0-0
Browse files Browse the repository at this point in the history
Resolve TS issues in canary
  • Loading branch information
jonathantneal authored Jul 29, 2021
2 parents b0ff0f2 + 34ada2e commit f290b9d
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 46 deletions.
2 changes: 1 addition & 1 deletion packages/core/types/create-css.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type CreateCss = {
ThemeMap extends InterfaceOfThemeMap<ThemeMap, Theme>,
Utils extends InterfaceOfUtils<Utils>
>(
config: {
config?: {
prefix?: Prefix
media?: Media
theme?: Theme
Expand Down
19 changes: 1 addition & 18 deletions packages/core/types/css-util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,7 @@ export type CSS<
}
// unknown css declaration styles
& {
[K in string]: (
K extends Util.Prefixed<'@', keyof Media>
? unknown
: K extends keyof CSSProperties
? unknown
: K extends keyof Utils
? unknown
: K extends keyof ThemeMap
? unknown
: K extends keyof { variants: unknown; defaultVariants: unknown; compoundVariants: unknown }
? unknown
: (
| CSS<Media, Theme, ThemeMap, Utils>
| CSS.Globals
| Util.Index
| any[]
)
)
[K in string]: number | string | CSS<Media, Theme, ThemeMap, Utils> | {}
}
)

Expand Down
6 changes: 6 additions & 0 deletions packages/core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type Sheet from './sheet'

import type * as CSSUtil from './css-util'
import type * as Default from './default'
import type * as StyledComponent from './styled-component'

export type { CreateCss, Sheet }

Expand All @@ -15,6 +16,11 @@ export type CSS<
theme?: {}
themeMap?: {}
utils?: {}
} = {
media: {},
theme: {},
themeMap: {},
utils: {}
}
> = CSSUtil.CSS<
Config['media'],
Expand Down
13 changes: 11 additions & 2 deletions packages/core/types/styled-component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ export interface CssComponent<
TransformedProps = TransformProps<Props, Media>,
CSS = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
> {
(
<
Props extends {
css?: Props['css'] extends CSSUtil.CSS
? Props['css']
: CSS
}
>(
props?:
& Partial<TransformedProps>
& {
css?: CSS
css?: Props['css']
}
& {
[name in number | string]: any
Expand All @@ -28,6 +34,9 @@ export interface CssComponent<
props: object
}

className: string
selector: string

[$$StyledComponentType]: TagName
[$$StyledComponentProps]: Props
[$$StyledComponentMedia]: Media
Expand Down
19 changes: 1 addition & 18 deletions packages/react/types/css-util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,7 @@ export type CSS<
}
// unknown css declaration styles
& {
[K in string]: (
K extends Util.Prefixed<'@', keyof Media>
? unknown
: K extends keyof CSSProperties
? unknown
: K extends keyof Utils
? unknown
: K extends keyof ThemeMap
? unknown
: K extends keyof { variants: unknown; defaultVariants: unknown; compoundVariants: unknown }
? unknown
: (
| CSS<Media, Theme, ThemeMap, Utils>
| CSS.Globals
| Util.Index
| any[]
)
)
[K in string]: number | string | CSS<Media, Theme, ThemeMap, Utils> | {}
}
)

Expand Down
5 changes: 5 additions & 0 deletions packages/react/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export type CSS<
theme?: {}
themeMap?: {}
utils?: {}
} = {
media: {},
theme: {},
themeMap: {},
utils: {}
}
> = CSSUtil.CSS<
Config['media'],
Expand Down
29 changes: 23 additions & 6 deletions packages/react/types/styled-component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,24 @@ export interface StyledComponent<
TransformedProps = TransformProps<Props, Media>,
CSS = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
> extends ForwardRefExoticComponent<Type, TransformedProps> {
<As = Type>(
props:
<
As = Type,
Props extends {
css?: Props['css'] extends CSSUtil.CSS
? Props['css']
: CSS
}
>(
props: (
As extends keyof JSX.IntrinsicElements
? Util.Assign<JSX.IntrinsicElements[As], Partial<TransformedProps> & { as?: As, css?: CSS }>
? Util.Assign<JSX.IntrinsicElements[As], Partial<TransformedProps>>
: As extends React.ComponentType<infer P>
? Util.Assign<P, Partial<TransformedProps> & { as?: As, css?: CSS }>
? Util.Assign<P, Partial<TransformedProps>>
: never
) & {
as?: As,
css?: Props['css']
}
): React.ReactElement | null

[$$StyledComponentType]: Type
Expand All @@ -39,11 +50,17 @@ export interface CssComponent<
TransformedProps = TransformProps<Props, Media>,
CSS = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
> {
(
<
Props extends {
css?: Props['css'] extends CSSUtil.CSS
? Props['css']
: CSS
}
>(
props?:
& Partial<TransformedProps>
& {
css?: CSS
css?: Props['css']
}
& {
[name in number | string]: any
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"target": "es2021"
"target": "es2020"
},
"files": [
"packages/core/types/index.d.ts",
Expand Down

0 comments on commit f290b9d

Please sign in to comment.