Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-styled-jsx-intrinsics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linaria/react": patch
---

Fix `styled.<tag>` typings in environments where only the React JSX runtime types are available (e.g. `jsx: react-jsx`).
16 changes: 8 additions & 8 deletions packages/react/src/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ declare global {

let idx = 0;

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
type ReactIntrinsicElements = typeof import('react') extends {
JSX: { IntrinsicElements: infer T };
type GlobalJSXIntrinsicElements = JSX.IntrinsicElements;

declare module 'react' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements extends GlobalJSXIntrinsicElements {}
}
}
? T
: never;

type IntrinsicElements = [ReactIntrinsicElements] extends [never]
? JSX.IntrinsicElements
: ReactIntrinsicElements;
type IntrinsicElements = React.JSX.IntrinsicElements;

// Components with props are not allowed
function styled(
Expand Down