Skip to content

Commit

Permalink
fix(TS): improve typescript types for MDX component
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Mar 16, 2021
1 parent ad0bdd6 commit 89399a8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import * as React from 'react'

interface ComponentMap {
[name: string]: React.ComponentType | string | ComponentMap
}

interface MDXContentProps {
[props: string]: unknown
components?: ComponentMap
}

function getMDXComponent(
code: string,
globals?: Record<string, unknown>,
): React.FunctionComponent<{
components?: Record<
string,
React.FunctionComponent | React.Component | string
>
}> {
): React.FunctionComponent<MDXContentProps> {
const scope = {React, ...globals}
// eslint-disable-next-line
const fn = new Function(...Object.keys(scope), code)
Expand Down

0 comments on commit 89399a8

Please sign in to comment.