1+ import type { MDXComponents } from 'mdx/types'
12// NOTE use ESM/CommonJS compat import here until resolved: https://github.com/facebook/react/issues/11503
23import React from 'react'
34// NOTE use ESM/CommonJS compat import here until resolved: https://github.com/facebook/react/issues/11503
@@ -13,12 +14,17 @@ import { _jsx_runtime } from './jsx-runtime.cjs'
1314// See https://github.com/contentlayerdev/contentlayer/issues/162
1415// import * as _jsx_runtime from 'react/jsx-runtime'
1516
16- const getMDXComponent = ( code : string , globals : Record < string , unknown > = { } ) : React . ComponentType < any > => {
17+ type MDXContentProps = {
18+ [ props : string ] : unknown
19+ components ?: MDXComponents
20+ }
21+
22+ const getMDXComponent = ( code : string , globals : Record < string , unknown > = { } ) : React . ComponentType < MDXContentProps > => {
1723 const scope = { React, ReactDOM, _jsx_runtime, ...globals }
1824 const fn = new Function ( ...Object . keys ( scope ) , code )
1925 return fn ( ...Object . values ( scope ) ) . default
2026}
2127
22- export const useMDXComponent = ( code : string , globals : Record < string , unknown > = { } ) : React . ComponentType < any > => {
28+ export const useMDXComponent = ( code : string , globals : Record < string , unknown > = { } ) => {
2329 return React . useMemo ( ( ) => getMDXComponent ( code , globals ) , [ code , globals ] )
2430}
0 commit comments