Skip to content

Commit

Permalink
Update package lock
Browse files Browse the repository at this point in the history
`hast-util-to-jsx-runtime`, an internally used dependency,
fixed asignability of the React JSX runtime to it.
This commit also changes the docs to remove workarounds for
the old behavior.

Closes GH-2465.
  • Loading branch information
wooorm committed Oct 14, 2024
1 parent e8c625f commit 6819e55
Show file tree
Hide file tree
Showing 7 changed files with 615 additions and 812 deletions.
7 changes: 0 additions & 7 deletions docs/_asset/editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ function Playground() {
/** @type {MDXModule} */
const result = await run(String(file), {
Fragment,
// @ts-expect-error: to do: fix in `hast-util-to-jsx-runtime`.
jsx,
// @ts-expect-error: to do: fix in `hast-util-to-jsx-runtime`.
jsxs,
baseUrl: window.location.href
})
Expand All @@ -230,7 +228,6 @@ function Playground() {
JSON.stringify(ast, undefined, 2),
'source.json'
),
// @ts-expect-error: to do: fix in `hast-util-to-jsx-runtime`.
{Fragment, jsx, jsxs}
)}
</code>
Expand All @@ -244,9 +241,7 @@ function Playground() {
<code>
{toJsxRuntime(starryNight.highlight(String(file), 'source.js'), {
Fragment,
// @ts-expect-error: to do: fix in `hast-util-to-jsx-runtime`.
jsx,
// @ts-expect-error: to do: fix in `hast-util-to-jsx-runtime`.
jsxs
})}
</code>
Expand Down Expand Up @@ -339,9 +334,7 @@ function Playground() {
<div className="playground-draw">
{toJsxRuntime(starryNight.highlight(value, scope), {
Fragment,
// @ts-expect-error: to do: fix in `hast-util-to-jsx-runtime`.
jsx,
// @ts-expect-error: to do: fix in `hast-util-to-jsx-runtime`.
jsxs
})}
{/* Trailing whitespace in a `textarea` is shown, but not in a `div`
Expand Down
1 change: 0 additions & 1 deletion docs/_component/blog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export function BlogEntry(properties) {
</h3>
<div>
{meta.descriptionHast ? (
// @ts-expect-error: to do: fix in `hast-util-to-jsx-runtime`.
toJsxRuntime(meta.descriptionHast, {Fragment, jsx, jsxs})
) : description ? (
<p>{description}</p>
Expand Down
1 change: 0 additions & 1 deletion docs/_component/nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export function NavigationItem(properties) {
properties: {className: ['nav-description']},
children
},
// @ts-expect-error: to do: fix in `hast-util-to-jsx-runtime`.
{Fragment, jsx, jsxs}
)
} else {
Expand Down
2 changes: 0 additions & 2 deletions docs/guides/mdx-on-demand.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import * as runtime from 'react/jsx-runtime'

const code = '' // To do: get `code` from server somehow.

// @ts-expect-error: `runtime` types are currently broken.
const {default: Content} = await run(code, {...runtime, baseUrl: import.meta.url})
```
Expand Down Expand Up @@ -89,7 +88,6 @@ export default function Page({code}) {
useEffect(
function () {
;(async function () {
// @ts-expect-error: `runtime` types are currently broken.
setMdxModule(await run(code, {...runtime, baseUrl: import.meta.url}))
})()
},
Expand Down
6 changes: 1 addition & 5 deletions docs/migrating/v3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ If you use `react/jsx-runtime`, you might get a TypeScript error (such as
To remediate this, do:

```tsx
import {type Fragment, type Jsx, run} from '@mdx-js/mdx'
import * as runtime_ from 'react/jsx-runtime'

// @ts-expect-error: the automatic react runtime is untyped.
const runtime: {Fragment: Fragment; jsx: Jsx; jsxs: Jsx} = runtime_
import * as runtime from 'react/jsx-runtime'

const result = await run('# hi', {...runtime, baseUrl: import.meta.url})
```
Expand Down
Loading

0 comments on commit 6819e55

Please sign in to comment.