Skip to content

Commit cffa30d

Browse files
committed
fix(react): restore styled intrinsic typing
1 parent a8a55a6 commit cffa30d

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linaria/react": patch
3+
---
4+
5+
Fix `styled.<tag>` typings in environments where only the React JSX runtime types are available (e.g. `jsx: react-jsx`).

packages/react/src/styled.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,16 @@ declare global {
116116

117117
let idx = 0;
118118

119-
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
120-
type ReactIntrinsicElements = typeof import('react') extends {
121-
JSX: { IntrinsicElements: infer T };
119+
type GlobalJSXIntrinsicElements = JSX.IntrinsicElements;
120+
121+
declare module 'react' {
122+
// eslint-disable-next-line @typescript-eslint/no-namespace
123+
namespace JSX {
124+
interface IntrinsicElements extends GlobalJSXIntrinsicElements {}
125+
}
122126
}
123-
? T
124-
: never;
125127

126-
type IntrinsicElements = [ReactIntrinsicElements] extends [never]
127-
? JSX.IntrinsicElements
128-
: ReactIntrinsicElements;
128+
type IntrinsicElements = React.JSX.IntrinsicElements;
129129

130130
// Components with props are not allowed
131131
function styled(

0 commit comments

Comments
 (0)