Skip to content

Commit 0f1cdf4

Browse files
authored
Add docs for augmenting JSX
Previously frameworks used to define a global `JSX` namespace. This is no longer the case. Now users need to define it themselves using module augmentation. Closes GH-2661. Reviewed-by: Titus Wormer <tituswormer@gmail.com>
1 parent 50aa8df commit 0f1cdf4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/docs/getting-started.mdx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,16 @@ Our packages are typed with [TypeScript][].
172172
For types to work,
173173
the `JSX` namespace must be typed.
174174
This is done by installing and using the types of your framework,
175-
such as [`@types/react`][definitely-typed-react].
175+
such as [`@types/react`][definitely-typed-react],
176+
then augmenting the `mdx/types.js` module.
177+
178+
```ts twoslash path="example.ts"
179+
import * as React from 'react'
180+
181+
declare module 'mdx/types.js' {
182+
export import JSX = React.JSX
183+
}
184+
```
176185

177186
To enable types for imported `.mdx`, `.md`, etc.,
178187
install and use [`@types/mdx`][definitely-typed-mdx].

0 commit comments

Comments
 (0)