Skip to content

Commit 67fb1d0

Browse files
authored
Remove unneeded JSX type casting in docs, tests
It used to cause errors. Now it doesn’t anymore. Closes GH-2604. Reviewed-by: Christian Murphy <[email protected]> Reviewed-by: Titus Wormer <[email protected]>
1 parent 913659c commit 67fb1d0

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

docs/migrating/v3.mdx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ You will get a runtime error if these features are used in MDX without
5252
If you passed the `useDynamicImport` option before, remove it, the behavior
5353
is now the default.
5454

55-
If you use `react/jsx-runtime`, you might get a TypeScript error (such as
56-
`Property 'Fragment' is missing in type`), because it is typed incorrectly.
57-
To remediate this, do:
58-
5955
```tsx
6056
import * as runtime from 'react/jsx-runtime'
6157

packages/preact/test/index.jsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,16 @@
22
/* @jsxImportSource preact */
33

44
/**
5-
* @import {Fragment, Jsx} from '@mdx-js/mdx'
65
* @import {ComponentProps} from 'preact'
76
*/
87

98
import assert from 'node:assert/strict'
109
import {test} from 'node:test'
1110
import {evaluate} from '@mdx-js/mdx'
1211
import {MDXProvider, useMDXComponents} from '@mdx-js/preact'
13-
import * as runtime_ from 'preact/jsx-runtime'
12+
import * as runtime from 'preact/jsx-runtime'
1413
import {render} from 'preact-render-to-string'
1514

16-
const runtime = /** @type {{Fragment: Fragment, jsx: Jsx, jsxs: Jsx}} */ (
17-
runtime_
18-
)
19-
2015
test('@mdx-js/preact', async function (t) {
2116
await t.test('should expose the public api', async function () {
2217
assert.deepEqual(Object.keys(await import('@mdx-js/preact')).sort(), [

packages/react/test/index.jsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/**
2-
* @import {Fragment, Jsx} from '@mdx-js/mdx'
32
* @import {ComponentProps} from 'react'
43
*/
54

@@ -8,13 +7,9 @@ import {test} from 'node:test'
87
import {evaluate} from '@mdx-js/mdx'
98
import {MDXProvider, useMDXComponents} from '@mdx-js/react'
109
import React from 'react'
11-
import * as runtime_ from 'react/jsx-runtime'
10+
import * as runtime from 'react/jsx-runtime'
1211
import {renderToString} from 'react-dom/server'
1312

14-
const runtime = /** @type {{Fragment: Fragment, jsx: Jsx, jsxs: Jsx}} */ (
15-
/** @type {unknown} */ (runtime_)
16-
)
17-
1813
test('@mdx-js/react', async function (t) {
1914
await t.test('should expose the public api', async function () {
2015
assert.deepEqual(Object.keys(await import('@mdx-js/preact')).sort(), [

packages/vue/test/index.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/**
2-
* @import {Fragment, Jsx} from '@mdx-js/mdx'
32
* @import {MDXModule} from 'mdx/types.js'
43
* @import {Component} from 'vue'
54
*/
@@ -8,18 +7,10 @@ import assert from 'node:assert/strict'
87
import test from 'node:test'
98
import {compile, run} from '@mdx-js/mdx'
109
import {MDXProvider, useMDXComponents} from '@mdx-js/vue'
11-
import * as runtime_ from 'vue/jsx-runtime'
10+
import serverRenderer from '@vue/server-renderer'
11+
import * as runtime from 'vue/jsx-runtime'
1212
import * as vue from 'vue'
1313

14-
const runtime = /** @type {{Fragment: Fragment, jsx: Jsx, jsxs: Jsx}} */ (
15-
/** @type {unknown} */ (runtime_)
16-
)
17-
18-
// Note: a regular import would be nice but that completely messes up the JSX types.
19-
const name = '@vue/server-renderer'
20-
/** @type {{default: {renderToString(node: unknown): string}}} */
21-
const {default: serverRenderer} = await import(name)
22-
2314
test('@mdx-js/vue', async function (t) {
2415
await t.test('should expose the public api', async function () {
2516
assert.deepEqual(Object.keys(await import('@mdx-js/vue')).sort(), [
@@ -133,7 +124,10 @@ async function evaluate(value) {
133124
outputFormat: 'function-body',
134125
providerImportSource: '#'
135126
})
136-
return run(file, {...runtime, useMDXComponents})
127+
return run(file, {
128+
...runtime,
129+
useMDXComponents
130+
})
137131
}
138132

139133
/**

0 commit comments

Comments
 (0)