-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export JSX namespace from automatic runtime entries
- Loading branch information
Showing
6 changed files
with
56 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { EmotionJSX as JSX } from './jsx-namespace' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'react' | ||
import { Interpolation } from '@emotion/serialize' | ||
import { Theme } from './index' | ||
|
||
type WithConditionalCSSProp<P> = 'className' extends keyof P | ||
? (P extends { className?: string } ? P & { css?: Interpolation<Theme> } : P) | ||
: P | ||
|
||
// unpack all here to avoid infinite self-referencing when defining our own JSX namespace | ||
type ReactJSXElement = JSX.Element | ||
type ReactJSXElementClass = JSX.ElementClass | ||
type ReactJSXElementAttributesProperty = JSX.ElementAttributesProperty | ||
type ReactJSXElementChildrenAttribute = JSX.ElementChildrenAttribute | ||
type ReactJSXLibraryManagedAttributes<C, P> = JSX.LibraryManagedAttributes<C, P> | ||
type ReactJSXIntrinsicAttributes = JSX.IntrinsicAttributes | ||
type ReactJSXIntrinsicClassAttributes<T> = JSX.IntrinsicClassAttributes<T> | ||
type ReactJSXIntrinsicElements = JSX.IntrinsicElements | ||
|
||
export namespace EmotionJSX { | ||
interface Element extends ReactJSXElement {} | ||
interface ElementClass extends ReactJSXElementClass {} | ||
interface ElementAttributesProperty | ||
extends ReactJSXElementAttributesProperty {} | ||
interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {} | ||
|
||
type LibraryManagedAttributes<C, P> = WithConditionalCSSProp<P> & | ||
ReactJSXLibraryManagedAttributes<C, P> | ||
|
||
interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {} | ||
interface IntrinsicClassAttributes<T> | ||
extends ReactJSXIntrinsicClassAttributes<T> {} | ||
|
||
type IntrinsicElements = { | ||
[K in keyof ReactJSXIntrinsicElements]: ReactJSXIntrinsicElements[K] & { | ||
css?: Interpolation<Theme> | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { EmotionJSX as JSX } from './jsx-namespace' |