Skip to content

Commit

Permalink
Fix to allow assigning react runtime to types
Browse files Browse the repository at this point in the history
Related-to: mdx-js/mdx#2465.
  • Loading branch information
wooorm committed Oct 14, 2024
1 parent b0e5702 commit e093df5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ type FunctionComponent<ComponentProps> = (
* Create a production element.
*/
export type Jsx = (
type: unknown,
// `any` because runtimes often have complex framework-specific types here.
// type-coverage:ignore-next-line
type: any,
props: Props,
key?: string | undefined
) => JSX.Element
Expand All @@ -150,7 +152,9 @@ export type Jsx = (
* Create a development element.
*/
export type JsxDev = (
type: unknown,
// `any` because runtimes often have complex framework-specific types here.
// type-coverage:ignore-next-line
type: any,
props: Props,
key: string | undefined,
isStaticChildren: boolean,
Expand Down
9 changes: 9 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ test('properties', async function (t) {
}),
{
...production,
/**
* @param {unknown} type
*/
jsx(type, props) {
foundProps = props
return production.jsx(type, {})
Expand Down Expand Up @@ -671,6 +674,9 @@ test('react specific: `align` to `style`', async function (t) {
renderToStaticMarkup(
toJsxRuntime(h('td', {align: 'center'}), {
...production,
/**
* @param {unknown} type
*/
jsx(type, props) {
foundProps = props
return production.jsx(type, {})
Expand All @@ -695,6 +701,9 @@ test('react specific: `align` to `style`', async function (t) {
renderToStaticMarkup(
toJsxRuntime(h('td', {align: 'center'}), {
...production,
/**
* @param {unknown} type
*/
jsx(type, props) {
foundProps = props
return production.jsx(type, {})
Expand Down

0 comments on commit e093df5

Please sign in to comment.