Skip to content

Commit

Permalink
Remove local use of JSX
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Feb 25, 2025
1 parent 33c31e7 commit 21b47b9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 30 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ coverage/
node_modules/
react-markdown.min.js
yarn.lock
!/test-types.d.ts
3 changes: 0 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,6 @@ function post(tree, options) {

return toJsxRuntime(tree, {
Fragment,
// @ts-expect-error
// React components are allowed to return numbers,
// but not according to the types in hast-util-to-jsx-runtime
components,
ignoreInvalidStyle: true,
jsx,
Expand Down
23 changes: 9 additions & 14 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ see [`MarkdownAsync`][api-markdown-async] or

###### Returns

React element (`JSX.Element`).
React element (`ReactElement`).

### `MarkdownAsync`

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

###### Returns

Promise to a React element (`Promise<JSX.Element>`).
Promise to a React element (`Promise<ReactElement>`).

### `MarkdownHooks`

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

###### Returns

React element (`JSX.Element`).
React element (`ReactElement`).

### `defaultUrlTransform(url)`

Expand Down Expand Up @@ -266,17 +266,12 @@ Map tag names to components (TypeScript type).
###### Type

```ts
import type {Element} from 'hast'

type Components = Partial<{
[TagName in keyof JSX.IntrinsicElements]:
// Class component:
| (new (props: JSX.IntrinsicElements[TagName] & ExtraProps) => JSX.ElementClass)
// Function component:
| ((props: JSX.IntrinsicElements[TagName] & ExtraProps) => JSX.Element | string | null | undefined)
// Tag name:
| keyof JSX.IntrinsicElements
}>
import type {ExtraProps} from 'react-markdown'
import type {ComponentProps, ElementType} from 'react'

type Components = {
[Key in Extract<ElementType, string>]?: ElementType<ComponentProps<Key> & ExtraProps>
}
```
### `ExtraProps`
Expand Down
9 changes: 0 additions & 9 deletions test-types.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions test-types.js

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"target": "es2022"
},
"exclude": ["coverage/", "node_modules/"],
"include": ["**/*.js", "**/*.jsx", "test-types.d.ts"]
"include": ["**/*.js", "**/*.jsx"]
}

0 comments on commit 21b47b9

Please sign in to comment.