Skip to content

Commit d51924e

Browse files
committed
Fix the use of JSX.Element in mdx index.d.ts
1 parent de6df32 commit d51924e

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

types/mdx/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
*/
5353
declare module "*.mdx" {
5454
// eslint-disable-next-line @definitelytyped/no-self-import
55-
import { MDXProps } from "mdx/types";
55+
import { Element, MDXProps } from "mdx/types";
5656

5757
/**
5858
* An function component which renders the MDX content using JSX.
@@ -61,7 +61,7 @@ declare module "*.mdx" {
6161
* @returns A JSX element. The meaning of this may depend on the project configuration. I.e. it
6262
* could be a React, Preact, or Vuex element.
6363
*/
64-
export default function MDXContent(props: MDXProps): JSX.Element;
64+
export default function MDXContent(props: MDXProps): Element;
6565
}
6666

6767
// Support markdown extensions from

types/mdx/types.d.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ type ClassElementType = Extract<ElementType, new(props: Record<string, any>) =>
2222
*/
2323
type StringComponent = Extract<keyof JSX.IntrinsicElements, ElementType extends never ? string : ElementType>;
2424

25+
/**
26+
* A JSX element returned by MDX content.
27+
*/
28+
export type Element = JSX.Element;
29+
2530
/**
2631
* A valid JSX function component.
2732
*/
2833
type FunctionComponent<Props> = ElementType extends never
2934
// If JSX.ElementType isn’t defined, the valid return type is JSX.Element
30-
? (props: Props) => JSX.Element | null
35+
? (props: Props) => Element | null
3136
: FunctionElementType extends never
3237
// If JSX.ElementType is defined, but doesn’t allow function components, function components are disallowed.
3338
? never
@@ -93,7 +98,7 @@ export interface MDXProps {
9398
/**
9499
* The type of the default export of an MDX module.
95100
*/
96-
export type MDXContent = (props: MDXProps) => JSX.Element;
101+
export type MDXContent = (props: MDXProps) => Element;
97102

98103
/**
99104
* A generic MDX module type.

0 commit comments

Comments
 (0)