import { MDXComponents, MDXContent, MDXModule } from 'mdx/types'; import MyMDXComponent from './MyComponent.mdx'; import MyMDComponent from './MyComponent.md'; import MyMarkdownComponent from './MyComponent.markdown'; import MyMDownComponent from './MyComponent.mdown'; import MyMKDNComponent from './MyComponent.mkdn'; import MyMKDComponent from './MyComponent.mkd'; import MyMKDownComponent from './MyComponent.mkdown'; import MyRonComponent from './MyComponent.ron'; // Test setup — A minimal JSX framework. interface TestElementType { type: string; props: unknown; children: TestElementType[]; } interface AnchorProps { className?: string; } interface DivProps { className?: string; } interface ImgProps { className?: string; src?: string; } interface H1Props { className?: string; } interface SpanProps { className?: string; } interface VideoProps { controls?: boolean; } // A JSX implementation stub declare function jsx(): TestElementType; // A JSX test implementation type declare global { namespace JSX { type Element = TestElementType; interface IntrinsicElements { a: AnchorProps; div: DivProps; img: ImgProps; h1: H1Props; span: SpanProps; video: VideoProps; } interface ElementClass { render(): Element; } } } // Test setup — User code class CustomImageComponent { constructor(props: ImgProps) {} render() { return
; } } // Tests — The `mdx` imports. function MyMDXPage(props: MDXModule) { // $ExpectType MDXContent const Content = props.default; // $ExpectType unknown props.title; return (

{props.title as string}

); } const MyComponentAlias: MDXContent = MyMDXComponent; const MyComponentAliasAlias: typeof MyMDXComponent = MyComponentAlias; // Ensure custom components are valid JSX components. declare const customComponents: MDXComponents; const Div = customComponents.div!;
; // Tests — All mdx file exports. // $ExpectType TestElementType ; // $ExpectType TestElementType 'and'} everything={42} components={{ a(props) { // $ExpectType AnchorProps props; return null; }, div(props) { // $ExpectType DivProps props; return
; }, img: CustomImageComponent, // @ts-expect-error video: CustomImageComponent, wrapper(props) { // $ExpectType any props; return
; }, nested: { components: props => { // $ExpectType any props; return
; }, very: { deeply: props => { // $ExpectType any props; return
; }, to: { infinity: props => { // $ExpectType any props; return
; }, and: { beyond: props => { // $ExpectType any props; return
; }, span: 'div', }, }, }, }, // @ts-expect-error invalid: 'Not just any type is allowed though', // Aliasing is valid though span: 'div', }} />; // $ExpectType TestElementType ; // $ExpectType TestElementType 'and'} everything={42} components={{ a(props) { // $ExpectType AnchorProps props; return null; }, div(props) { // $ExpectType DivProps props; return
; }, img: CustomImageComponent, // @ts-expect-error video: CustomImageComponent, wrapper(props) { // $ExpectType any props; return
; }, nested: { components: props => { // $ExpectType any props; return
; }, very: { deeply: props => { // $ExpectType any props; return
; }, to: { infinity: props => { // $ExpectType any props; return
; }, and: { beyond: props => { // $ExpectType any props; return
; }, span: 'div', }, }, }, }, // @ts-expect-error invalid: 'Not just any type is allowed though', // Aliasing is valid though span: 'div', }} />; // $ExpectType TestElementType ; // $ExpectType TestElementType 'and'} everything={42} components={{ a(props) { // $ExpectType AnchorProps props; return null; }, div(props) { // $ExpectType DivProps props; return
; }, img: CustomImageComponent, // @ts-expect-error video: CustomImageComponent, wrapper(props) { // $ExpectType any props; return
; }, nested: { components: props => { // $ExpectType any props; return
; }, very: { deeply: props => { // $ExpectType any props; return
; }, to: { infinity: props => { // $ExpectType any props; return
; }, and: { beyond: props => { // $ExpectType any props; return
; }, span: 'div', }, }, }, }, // @ts-expect-error invalid: 'Not just any type is allowed though', // Aliasing is valid though span: 'div', }} />; // $ExpectType TestElementType ; // $ExpectType TestElementType 'and'} everything={42} components={{ a(props) { // $ExpectType AnchorProps props; return null; }, div(props) { // $ExpectType DivProps props; return
; }, img: CustomImageComponent, // @ts-expect-error video: CustomImageComponent, wrapper(props) { // $ExpectType any props; return
; }, nested: { components: props => { // $ExpectType any props; return
; }, very: { deeply: props => { // $ExpectType any props; return
; }, to: { infinity: props => { // $ExpectType any props; return
; }, and: { beyond: props => { // $ExpectType any props; return
; }, span: 'div', }, }, }, }, // @ts-expect-error invalid: 'Not just any type is allowed though', // Aliasing is valid though span: 'div', }} />; // $ExpectType TestElementType ; // $ExpectType TestElementType 'and'} everything={42} components={{ a(props) { // $ExpectType AnchorProps props; return null; }, div(props) { // $ExpectType DivProps props; return
; }, img: CustomImageComponent, // @ts-expect-error video: CustomImageComponent, wrapper(props) { // $ExpectType any props; return
; }, nested: { components: props => { // $ExpectType any props; return
; }, very: { deeply: props => { // $ExpectType any props; return
; }, to: { infinity: props => { // $ExpectType any props; return
; }, and: { beyond: props => { // $ExpectType any props; return
; }, span: 'div', }, }, }, }, // @ts-expect-error invalid: 'Not just any type is allowed though', // Aliasing is valid though span: 'div', }} />; // $ExpectType TestElementType ; // $ExpectType TestElementType 'and'} everything={42} components={{ a(props) { // $ExpectType AnchorProps props; return null; }, div(props) { // $ExpectType DivProps props; return
; }, img: CustomImageComponent, // @ts-expect-error video: CustomImageComponent, wrapper(props) { // $ExpectType any props; return
; }, nested: { components: props => { // $ExpectType any props; return
; }, very: { deeply: props => { // $ExpectType any props; return
; }, to: { infinity: props => { // $ExpectType any props; return
; }, and: { beyond: props => { // $ExpectType any props; return
; }, span: 'div', }, }, }, }, // @ts-expect-error invalid: 'Not just any type is allowed though', // Aliasing is valid though span: 'div', }} />; // $ExpectType TestElementType ; // $ExpectType TestElementType 'and'} everything={42} components={{ a(props) { // $ExpectType AnchorProps props; return null; }, div(props) { // $ExpectType DivProps props; return
; }, img: CustomImageComponent, // @ts-expect-error video: CustomImageComponent, wrapper(props) { // $ExpectType any props; return
; }, nested: { components: props => { // $ExpectType any props; return
; }, very: { deeply: props => { // $ExpectType any props; return
; }, to: { infinity: props => { // $ExpectType any props; return
; }, and: { beyond: props => { // $ExpectType any props; return
; }, span: 'div', }, }, }, }, // @ts-expect-error invalid: 'Not just any type is allowed though', // Aliasing is valid though span: 'div', }} />; // $ExpectType TestElementType ; // $ExpectType TestElementType 'and'} everything={42} components={{ a(props) { // $ExpectType AnchorProps props; return null; }, div(props) { // $ExpectType DivProps props; return
; }, img: CustomImageComponent, // @ts-expect-error video: CustomImageComponent, wrapper(props) { // $ExpectType any props; return
; }, nested: { components: props => { // $ExpectType any props; return
; }, very: { deeply: props => { // $ExpectType any props; return
; }, to: { infinity: props => { // $ExpectType any props; return
; }, and: { beyond: props => { // $ExpectType any props; return
; }, span: 'div', }, }, }, }, // @ts-expect-error invalid: 'Not just any type is allowed though', // Aliasing is valid though span: 'div', }} />;