Skip to content

Commit 273e395

Browse files
authored
fix(typings): fix massive type in createX (#173)
1 parent b4ef549 commit 273e395

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,8 @@
6161
"styled-components": "5.2.1",
6262
"tsdx": "^0.14.0",
6363
"typescript": "^4.1.3"
64+
},
65+
"resolutions": {
66+
"tsdx/typescript": "^4.1.3"
6467
}
6568
}

packages/emotion/src/createX.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
/* eslint-disable no-continue, no-loop-func, no-cond-assign */
2+
import * as React from 'react'
23
import { Theme } from '@emotion/react'
34
import styled, { StyledComponent } from '@emotion/styled'
45
import { compose, StyleGenerator } from '@xstyled/system'
56

67
type JSXElementKeys = keyof JSX.IntrinsicElements
78

8-
const tags = Object.keys(styled)
9-
10-
export const createX = <TProps extends object>(generator: StyleGenerator) => {
11-
type X<TProps extends object> = {
12-
extend<TExtendProps extends object>(
13-
...generators: StyleGenerator[]
14-
): X<TExtendProps>
15-
} & {
16-
[Key in JSXElementKeys]: StyledComponent<
17-
TProps & { as?: React.ElementType; theme?: Theme },
18-
JSX.IntrinsicElements[Key]
19-
>
20-
}
9+
type JSXElements<TProps> = {
10+
[Key in JSXElementKeys]: StyledComponent<
11+
TProps & { as?: React.ElementType; theme?: Theme },
12+
JSX.IntrinsicElements[Key]
13+
>
14+
}
15+
16+
type CreateX = <TProps extends object>(generator: StyleGenerator) => X<TProps>
17+
18+
export interface X<TProps extends object> extends JSXElements<TProps> {
19+
extend: CreateX
20+
}
21+
22+
const tags = Object.keys(styled) as JSXElementKeys[]
2123

24+
export const createX: CreateX = <TProps extends object>(
25+
generator: StyleGenerator,
26+
) => {
2227
// @ts-ignore
2328
const x: X<TProps> = {
2429
extend: (...generators) => createX(compose(generator, ...generators)),

yarn.lock

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19352,12 +19352,7 @@ typedarray@^0.0.6:
1935219352
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
1935319353
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
1935419354

19355-
typescript@^3.7.3:
19356-
version "3.9.7"
19357-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
19358-
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
19359-
19360-
typescript@^4.1.3:
19355+
typescript@^3.7.3, typescript@^4.1.3:
1936119356
version "4.1.3"
1936219357
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
1936319358
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==

0 commit comments

Comments
 (0)