Skip to content

Commit 89399a8

Browse files
committed
fix(TS): improve typescript types for MDX component
1 parent ad0bdd6 commit 89399a8

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/client.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import * as React from 'react'
22

3+
interface ComponentMap {
4+
[name: string]: React.ComponentType | string | ComponentMap
5+
}
6+
7+
interface MDXContentProps {
8+
[props: string]: unknown
9+
components?: ComponentMap
10+
}
11+
312
function getMDXComponent(
413
code: string,
514
globals?: Record<string, unknown>,
6-
): React.FunctionComponent<{
7-
components?: Record<
8-
string,
9-
React.FunctionComponent | React.Component | string
10-
>
11-
}> {
15+
): React.FunctionComponent<MDXContentProps> {
1216
const scope = {React, ...globals}
1317
// eslint-disable-next-line
1418
const fn = new Function(...Object.keys(scope), code)

0 commit comments

Comments
 (0)