Skip to content

Commit 21b47b9

Browse files
committed
Remove local use of JSX
1 parent 33c31e7 commit 21b47b9

File tree

6 files changed

+10
-30
lines changed

6 files changed

+10
-30
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ coverage/
77
node_modules/
88
react-markdown.min.js
99
yarn.lock
10-
!/test-types.d.ts

lib/index.js

-3
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,6 @@ function post(tree, options) {
325325

326326
return toJsxRuntime(tree, {
327327
Fragment,
328-
// @ts-expect-error
329-
// React components are allowed to return numbers,
330-
// but not according to the types in hast-util-to-jsx-runtime
331328
components,
332329
ignoreInvalidStyle: true,
333330
jsx,

readme.md

+9-14
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ see [`MarkdownAsync`][api-markdown-async] or
191191

192192
###### Returns
193193

194-
React element (`JSX.Element`).
194+
React element (`ReactElement`).
195195

196196
### `MarkdownAsync`
197197

@@ -209,7 +209,7 @@ see [`MarkdownHooks`][api-markdown-hooks].
209209

210210
###### Returns
211211

212-
Promise to a React element (`Promise<JSX.Element>`).
212+
Promise to a React element (`Promise<ReactElement>`).
213213

214214
### `MarkdownHooks`
215215

@@ -227,7 +227,7 @@ see [`MarkdownAsync`][api-markdown-async].
227227

228228
###### Returns
229229

230-
React element (`JSX.Element`).
230+
React element (`ReactElement`).
231231

232232
### `defaultUrlTransform(url)`
233233

@@ -266,17 +266,12 @@ Map tag names to components (TypeScript type).
266266
###### Type
267267

268268
```ts
269-
import type {Element} from 'hast'
270-
271-
type Components = Partial<{
272-
[TagName in keyof JSX.IntrinsicElements]:
273-
// Class component:
274-
| (new (props: JSX.IntrinsicElements[TagName] & ExtraProps) => JSX.ElementClass)
275-
// Function component:
276-
| ((props: JSX.IntrinsicElements[TagName] & ExtraProps) => JSX.Element | string | null | undefined)
277-
// Tag name:
278-
| keyof JSX.IntrinsicElements
279-
}>
269+
import type {ExtraProps} from 'react-markdown'
270+
import type {ComponentProps, ElementType} from 'react'
271+
272+
type Components = {
273+
[Key in Extract<ElementType, string>]?: ElementType<ComponentProps<Key> & ExtraProps>
274+
}
280275
```
281276
282277
### `ExtraProps`

test-types.d.ts

-9
This file was deleted.

test-types.js

-2
This file was deleted.

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"target": "es2022"
1414
},
1515
"exclude": ["coverage/", "node_modules/"],
16-
"include": ["**/*.js", "**/*.jsx", "test-types.d.ts"]
16+
"include": ["**/*.js", "**/*.jsx"]
1717
}

0 commit comments

Comments
 (0)