Skip to content

Commit ae1f657

Browse files
committed
updated type references to use React.JSX namespace and removed generic Element type
1 parent 34e4411 commit ae1f657

11 files changed

+25
-30
lines changed

README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ type EvaluateProps<TScope> = {
409409

410410
```typescript
411411
type EvaluateResult<TFrontmatter, TScope> = {
412-
content: JSX.Element;
412+
content: React.JSX.Element;
413413
mod: Record<string, unknown>;
414414
frontmatter: TFrontmatter;
415415
scope: TScope;
@@ -700,10 +700,10 @@ _Go to the [evaluate](#the-evaluate-function) function_
700700
The `MDXRemote` component is used for rendering the MDX content on the server side. It is a react server component.
701701

702702
```typescript
703-
async function MDXRemote(props: MDXRemoteProps): Promise<JSX.Element> {}
703+
async function MDXRemote(props: MDXRemoteProps): Promise<React.JSX.Element> {}
704704
```
705705

706-
The `MDXRemote` component takes `MDXRemoteProps` and returns `JSX.Element` as a promise.
706+
The `MDXRemote` component takes `MDXRemoteProps` and returns `React.JSX.Element` as a promise.
707707

708708
**Props of the `MDXRemote` component**
709709

@@ -1202,7 +1202,7 @@ The option `disableParentContext` is a feature of `@mdx-js/mdx`. If it is `false
12021202

12031203
```typescript
12041204
type HydrateResult = {
1205-
content: JSX.Element;
1205+
content: React.JSX.Element;
12061206
mod: Record<string, unknown>;
12071207
error?: Error;
12081208
};
@@ -1274,10 +1274,10 @@ import { MDXClient } from "next-mdx-remote-client/csr";
12741274
The `MDXClient` component is used for rendering the MDX content on the client side.
12751275

12761276
```typescript
1277-
function MDXClient(props: MDXClientProps): JSX.Element {}
1277+
function MDXClient(props: MDXClientProps): React.JSX.Element {}
12781278
```
12791279

1280-
The `MDXClient` component takes `MDXClientProps` and returns `JSX.Element`. The `MDXClient` has no "options" parameter like `hydrate`.
1280+
The `MDXClient` component takes `MDXClientProps` and returns `React.JSX.Element`. The `MDXClient` has no "options" parameter like `hydrate`.
12811281

12821282
**Props of the `MDXClient` component**
12831283

@@ -1543,7 +1543,6 @@ In addition, the package exports the types from `mdx/types` so that developers d
15431543
- `MDXContent`
15441544
- `MDXProps`
15451545
- `MDXModule`
1546-
- `Element`
15471546

15481547
## Compatibility
15491548

migration_guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ The `evaluate` returns `mod` object for the exports, `scope`, and `error` object
665665
const { content, mod, frontmatter, scope, error } = await evaluate<Frontmatter, Scope>({source, options, components});
666666

667667
type EvaluateResult<TFrontmatter, TScope> = {
668-
content: JSX.Element;
668+
content: React.JSX.Element;
669669
mod: Record<string, unknown>;
670670
frontmatter: TFrontmatter;
671671
scope: TScope;
@@ -817,7 +817,7 @@ type HydrateProps = {
817817
};
818818

819819
type HydrateResult = {
820-
content: JSX.Element;
820+
content: React.JSX.Element;
821821
mod: Record<string, unknown>;
822822
error?: Error;
823823
};

src/csr/MDXClient.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* SPDX-License-Identifier: MPL-2.0
44
*/
55

6-
import type { MDXClientProps, Element } from "./types.js";
6+
import type { MDXClientProps } from "./types.js";
77
import { hydrate } from "./hydrate.js";
88

99
/**
1010
* renders the content on the client side (csr), which is provided by the "hydrate" function.
1111
*/
12-
export function MDXClient(props: MDXClientProps): Element {
12+
export function MDXClient(props: MDXClientProps): React.JSX.Element {
1313
const { onError: ErrorComponent, ...rest } = props;
1414

1515
const { content, error } = hydrate(rest);

src/csr/MDXClientAsync.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: MPL-2.0
44
*/
55

6-
import type { MDXClientAsyncProps, Element } from "./types.js";
6+
import type { MDXClientAsyncProps } from "./types.js";
77
import { hydrateAsync } from "./hydrateAsync.js";
88

99
/**
@@ -13,7 +13,7 @@ import { hydrateAsync } from "./hydrateAsync.js";
1313
*
1414
* the content is going to be hydrated "asynchronously" in a useEffect hook.
1515
*/
16-
export function MDXClientAsync(props: MDXClientAsyncProps): Element {
16+
export function MDXClientAsync(props: MDXClientAsyncProps): React.JSX.Element {
1717
const { onError: ErrorComponent, ...rest } = props;
1818

1919
const { content, error } = hydrateAsync(rest);

src/csr/MDXClientLazy.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* SPDX-License-Identifier: MPL-2.0
44
*/
55

6-
import type { MDXClientProps, Element } from "./types.js";
6+
import type { MDXClientProps } from "./types.js";
77
import { hydrateLazy } from "./hydrateLazy.js";
88

99
/**
1010
* renders the content on the client side (csr), which is provided by the "hydrateLazy" function.
1111
*
1212
* the content is going to be hydrated "lazily".
1313
*/
14-
export function MDXClientLazy(props: MDXClientProps): Element {
14+
export function MDXClientLazy(props: MDXClientProps): React.JSX.Element {
1515
const { onError: ErrorComponent, ...rest } = props;
1616

1717
const { content, error } = hydrateLazy(rest);

src/csr/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ export type {
2626
export { MDXProvider, useMDXComponents } from "@mdx-js/react";
2727

2828
// for who needs to use them without installing the "mdx/types"
29-
export type { MDXComponents, MDXContent, MDXProps, MDXModule, Element } from "mdx/types";
29+
export type { MDXComponents, MDXContent, MDXProps, MDXModule } from "mdx/types";

src/csr/types.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ import type {
77
CompileOptions as OriginalCompileOptions,
88
RunOptions as OriginalRunOptions,
99
} from "@mdx-js/mdx";
10-
import type { MDXComponents, Element } from "mdx/types";
10+
import type { MDXComponents } from "mdx/types";
1111
import type { Compatible } from "vfile";
1212

1313
import type { VfileDataIntoScope } from "../lib/util.js";
1414

15-
export type { Element } from "mdx/types";
16-
1715
export type Prettify<T> = { [K in keyof T]: T[K] } & {};
1816

1917
export type SerializeProps<TScope extends Record<string, unknown> = Record<string, unknown>> = {
@@ -131,7 +129,7 @@ export type HydrateResult = {
131129
/**
132130
* React element that renders the MDX compiled source using the component names mapping object.
133131
*/
134-
content: Element;
132+
content: React.JSX.Element;
135133
/**
136134
* An object which holds any value that is exported from the MDX file.
137135
*/
@@ -157,7 +155,7 @@ export type HydrateAsyncProps = Prettify<
157155
/**
158156
* fallback loading component
159157
*/
160-
loading?: () => Element;
158+
loading?: () => React.JSX.Element;
161159
}
162160
>;
163161

src/rsc/MDXRemote.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
*/
55

66
import { evaluate } from "./evaluate.js";
7-
import type { MDXRemoteProps, Element } from "./types.js";
7+
import type { MDXRemoteProps } from "./types.js";
88

99
/**
1010
* renders the content as a react server component (rsc), which is provided by the "evaluate" function
1111
*/
12-
export async function MDXRemote(props: MDXRemoteProps): Promise<Element> {
12+
export async function MDXRemote(props: MDXRemoteProps): Promise<React.JSX.Element> {
1313
const { onError: ErrorComponent, ...rest } = props;
1414

1515
const { content, error } = await evaluate(rest);

src/rsc/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ export type {
1515
} from "./types.js";
1616

1717
// for who needs to use them without installing the "mdx/types"
18-
export type { MDXComponents, MDXContent, MDXProps, MDXModule, Element } from "mdx/types";
18+
export type { MDXComponents, MDXContent, MDXProps, MDXModule } from "mdx/types";

src/rsc/types.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
*/
55

66
import type { EvaluateOptions as OriginalEvaluateOptions } from "@mdx-js/mdx";
7-
import type { MDXComponents, Element } from "mdx/types";
7+
import type { MDXComponents } from "mdx/types";
88
import type { Compatible } from "vfile";
99

1010
import type { VfileDataIntoScope } from "../lib/util.js";
1111

12-
export type { Element } from "mdx/types";
13-
1412
export type Prettify<T> = { [K in keyof T]: T[K] } & {};
1513

1614
export type EvaluateProps<TScope extends Record<string, unknown> = Record<string, unknown>> = {
@@ -84,7 +82,7 @@ export type EvaluateResult<
8482
/**
8583
* React element that renders the MDX source using the component names mapping object.
8684
*/
87-
content: Element;
85+
content: React.JSX.Element;
8886
/**
8987
* An object which holds any value that is exported from the MDX file.
9088
*/

tests/context/components.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import React from "react";
44

55
/**
6-
* @param {Readonly<JSX.IntrinsicElements['span']>} props
6+
* @param {Readonly<React.JSX.IntrinsicElements['span']>} props
77
* Props
88
* @returns
99
* `span` element.
@@ -13,7 +13,7 @@ export function Pill(props) {
1313
}
1414

1515
/**
16-
* @param {Readonly<JSX.IntrinsicElements['div']>} props
16+
* @param {Readonly<React.JSX.IntrinsicElements['div']>} props
1717
* Props
1818
* @returns
1919
* `div` element.

0 commit comments

Comments
 (0)