Skip to content

Commit

Permalink
fix: css property typing / remove implicit @ALL
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathantneal committed Aug 10, 2021
1 parent 7846c3d commit 5e07cc4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 24 deletions.
3 changes: 1 addition & 2 deletions packages/core/src/createStitches.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { defaultMedia } from './default/defaultMedia.js'
import { defaultThemeMap } from './default/defaultThemeMap.js'

import { createMemo } from './utility/createMemo.js'
Expand All @@ -22,7 +21,7 @@ export const createStitches = (config) => {

// internal configuration
const prefix = 'prefix' in initConfig ? String(initConfig.prefix) : ''
const media = { ...defaultMedia, ...(typeof initConfig.media === 'object' && initConfig.media || {}) }
const media = typeof initConfig.media === 'object' && initConfig.media || {}
const root = typeof initConfig.root === 'object' ? initConfig.root || null : globalThis.document || null
const theme = typeof initConfig.theme === 'object' && initConfig.theme || {}
const themeMap = typeof initConfig.themeMap === 'object' && initConfig.themeMap || { ...defaultThemeMap }
Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/default/defaultMedia.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/core/types/default.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export type Prefix = ''

/** Default Media configuration. */
export type Media = { all: string }
export type Media = {}

/** Default Theme. */
export type Theme = {
Expand Down
5 changes: 3 additions & 2 deletions packages/core/types/styled-component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import type * as Util from './util'
export interface CssComponent<
Type = 'span',
Props = {},
Media = Default.Media
Media = Default.Media,
TransformedProps = TransformProps<Omit<Props, 'css'>, Media> & { css?: Props['css'] }
> {
(
props?:
& Props
& TransformedProps
& {
[name in number | string]: any
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/types/default.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export type Prefix = ''

/** Default Media configuration. */
export type Media = { all: string }
export type Media = {}

/** Default Theme. */
export type Theme = {
Expand Down
25 changes: 11 additions & 14 deletions packages/react/types/styled-component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface StyledComponent<
Type = 'span',
Props = {},
Media = Default.Media,
TransformedProps = TransformProps<Props, Media>
TransformedProps = TransformProps<Omit<Props, 'css'>, Media> & { css?: Props['css'] }
> extends React.ForwardRefExoticComponent<
Util.Assign<
Type extends React.ElementType
Expand Down Expand Up @@ -40,7 +40,7 @@ export interface CssComponent<
Type = 'span',
Props = {},
Media = Default.Media,
TransformedProps = TransformProps<Props, Media>
TransformedProps = TransformProps<Omit<Props, 'css'>, Media> & { css?: Props['css'] }
> {
(
props?:
Expand All @@ -64,18 +64,15 @@ export interface CssComponent<

export type TransformProps<Props, Media> = {
[K in keyof Props]:
K extends 'css'
? unknown
:
| Props[K]
| (
& {
[KMedia in Util.Prefixed<'@', 'initial' | keyof Media>]?: Props[K]
}
& {
[KMedia in string]: Props[K]
}
)
| Props[K]
| (
& {
[KMedia in Util.Prefixed<'@', 'initial' | keyof Media>]?: Props[K]
}
& {
[KMedia in string]: Props[K]
}
)
}

/** Unique symbol used to reference the type of a Styled Component. */
Expand Down

0 comments on commit 5e07cc4

Please sign in to comment.