Skip to content

Commit

Permalink
Fix r18 JSX namespace types (#1617)
Browse files Browse the repository at this point in the history
* fix: fixes r18 types

* chore: changeset
  • Loading branch information
itsdouges authored Jan 23, 2024
1 parent fd6dc70 commit 541ab19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-readers-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@compiled/react': patch
---

Add `ElementType` to the Compiled JSX namespace. This is needed to ensure types are the same in the Compiled JSX namspace and the default React one, such as returning `undefined`, `string`, and other freshly valid types.
4 changes: 4 additions & 0 deletions packages/react/src/jsx/jsx-local-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ type WithConditionalCSSProp<TProps> = 'className' extends keyof TProps
{};

// Unpack all here to avoid infinite self-referencing when defining our own JSX namespace
// Based on the code from @types/[email protected] / @emotion-js
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3197efc097d522c4bf02b94e1a0766d007d6cdeb/types/react/index.d.ts#LL3204C13-L3204C13
type ReactJSXElementType = string | React.JSXElementConstructor<any>;
type ReactJSXElement = JSX.Element;
type ReactJSXElementClass = JSX.ElementClass;
type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty;
Expand All @@ -59,6 +62,7 @@ type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T>;
type ReactJSXIntrinsicElements = JSX.IntrinsicElements;

export namespace CompiledJSX {
export type ElementType = ReactJSXElementType;
export type Element = ReactJSXElement;
export type ElementClass = ReactJSXElementClass;
export type ElementAttributesProperty = ReactJSXElementAttributesProperty;
Expand Down

0 comments on commit 541ab19

Please sign in to comment.