Skip to content

Commit

Permalink
test: merge typing suggestions from abdul
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathantneal committed Aug 12, 2021
1 parent f41aab6 commit 995f44c
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 100 deletions.
133 changes: 70 additions & 63 deletions packages/react/types/stitches.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,40 +123,43 @@ export default interface Stitches<
? Composers[K]
: Composers[K] extends Util.Function
? Composers[K]
: CSSUtil.CSS<Media, Theme, ThemeMap, Utils, true> & (
: CSSUtil.CSS<Media, Theme, ThemeMap, Utils, true> & {
/** The **variants** property sets variants.
*
* [Read Documentation](https://stitches.dev/docs/variants)
*/
variants?: {
[name: string]: {
[pair in number | string]: CSS
}
}
/** Compound variants. */
compoundVariants?: (
& (
'variants' extends keyof Composers[K]
? {
[Name in keyof Composers[K]['variants']]?: Util.Widen<keyof Composers[K]['variants'][Name]> | Util.String
} & Util.WideObject
: Util.WideObject
)
& {
/** The **variants** property sets variants.
*
* [Read Documentation](https://stitches.dev/docs/variants)
*/
variants?: {
[name: string]: {
[pair in number | string]: CSS
}
}
/** Compound variants. */
compoundVariants?: (
& (
'variants' extends keyof Composers[K]
? {
[Name in keyof Composers[K]['variants']]?: Util.Widen<keyof Composers[K]['variants'][Name]> | Util.String
} & Util.WideObject
: Util.WideObject
)
& {
css: CSS
}
)[]
defaultVariants?: (
'variants' extends keyof Composers[K]
? {
[Name in keyof Composers[K]['variants']]?: Util.Widen<keyof Composers[K]['variants'][Name]> | Util.String
}
: Util.WideObject
)
css: CSS
}

) & {[K2 in keyof Composers[K]]:K2 extends 'variants' | 'defaultVariants' | 'compoundVariants' ? unknown : K2 extends keyof CSS ? CSS[K2] : unknown}
)[]
defaultVariants?: (
'variants' extends keyof Composers[K]
? {
[Name in keyof Composers[K]['variants']]?: Util.Widen<keyof Composers[K]['variants'][Name]> | Util.String
}
: Util.WideObject
)
} & {
[K2 in keyof Composers[K]]: K2 extends 'variants' | 'defaultVariants' | 'compoundVariants'
? unknown
: K2 extends keyof CSS
? CSS[K2]
: unknown
}
)
}
): StyledComponent.CssComponent<
Expand Down Expand Up @@ -193,39 +196,43 @@ export default interface Stitches<
? Composers[K]
: Composers[K] extends Util.Function
? Composers[K]
: CSSUtil.CSS<Media, Theme, ThemeMap, Utils, true> & (
: CSSUtil.CSS<Media, Theme, ThemeMap, Utils, true> & {
/** The **variants** property sets variants.
*
* [Read Documentation](https://stitches.dev/docs/variants)
*/
variants?: {
[name: string]: {
[pair in number | string]: CSS
}
}
/** Compound variants. */
compoundVariants?: (
& (
'variants' extends keyof Composers[K]
? {
[Name in keyof Composers[K]['variants']]?: Util.Widen<keyof Composers[K]['variants'][Name]> | Util.String
} & Util.WideObject
: Util.WideObject
)
& {
/** The **variants** property sets variants.
*
* [Read Documentation](https://stitches.dev/docs/variants)
*/
variants?: {
[name: string]: {
[pair in number | string]: CSS
}
}
/** Compound variants. */
compoundVariants?: (
& (
'variants' extends keyof Composers[K]
? {
[Name in keyof Composers[K]['variants']]?: Util.Widen<keyof Composers[K]['variants'][Name]> | Util.String
} & Util.WideObject
: Util.WideObject
)
& {
css: CSS
}
)[]
defaultVariants?: (
'variants' extends keyof Composers[K]
? {
[Name in keyof Composers[K]['variants']]?: Util.Widen<keyof Composers[K]['variants'][Name]> | Util.String
}
: Util.WideObject
)
css: CSS
}
) & {[K2 in keyof Composers[K]]:K2 extends 'variants' | 'defaultVariants' | 'compoundVariants' ? unknown : K2 extends keyof CSS ? CSS[K2] : unknown}
)[]
defaultVariants?: (
'variants' extends keyof Composers[K]
? {
[Name in keyof Composers[K]['variants']]?: Util.Widen<keyof Composers[K]['variants'][Name]> | Util.String
}
: Util.WideObject
)
} & {
[K2 in keyof Composers[K]]: K2 extends 'variants' | 'defaultVariants' | 'compoundVariants'
? unknown
: K2 extends keyof CSS
? CSS[K2]
: unknown
}
)
}
): StyledComponent.StyledComponent<
Expand Down
3 changes: 1 addition & 2 deletions packages/test/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as Stitches from '@stitches/react'
import * as React from 'react'


const { css, config, styled } = Stitches.createStitches({
utils: {
/** util to do stuff */
Expand Down Expand Up @@ -32,4 +31,4 @@ export const Status: React.ForwardRefExoticComponent<React.ComponentProps<typeof

export default function Home() {
return <Status onClick={event => { }} />
}
}
36 changes: 1 addition & 35 deletions packages/test/package.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,24 @@
{
"name": "@stitches/test",
"version": "1.0.0-canary.7",
"description": "The modern CSS-in-JS library",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "types/index.d.ts",
"typesVersions": {
">= 4.1": {
"*": [
"types/index.d.ts"
]
}
},
"jsdelivr": "dist/index.global.js",
"unpkg": "dist/index.global.js",
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.mjs",
"types": "./types/index.d.ts"
},
"./global": "./dist/index.global.js"
},
"files": [
"dist/*.cjs",
"dist/*.js",
"dist/*.map",
"dist/*.mjs",
"types/*.d.ts"
],
"sideEffects": false,
"license": "MIT",
"repository": "modulz/stitches",
"homepage": "https://github.com/modulz/stitches#readme",
"bugs": "https://github.com/modulz/stitches/issues",
"contributors": [
"Pedro Duarte <pedro@modulz.app>",
"Abdulhadi Alhallak <abdulhadi@modulz.app>",
"Jonathan Neal <jonathan@modulz.app>"
],
"devDependencies": {
"@stitches/react": "^1.0.0-canary.7",
"react": "17.0.2"
},
"peerDependencies": {
"react": ">= 16.3.0"
},
"publishConfig": {
"access": "public"
},
"eslintConfig": {
"extends": [
"react-app"
]
}
"private": true
}

0 comments on commit 995f44c

Please sign in to comment.