Skip to content

Commit db934ea

Browse files
Fix usage of TSX in headers.
Co-authored-by: Claudia Meadows <[email protected]>
1 parent 1f0e45d commit db934ea

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/jsx.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Explanation, examples, and build notes on how to use JSX in your Mithril.js-base
55
# JSX
66

77
- [Description](#description)
8-
- [Setup JSX](#setup-jsx)
8+
- [Setup for JavaScript](#setup-for-javascript)
99
- [Production build](#production-build)
1010
- [Using Babel with Webpack](#using-babel-with-webpack)
11-
- [Setup TSX](#setup-tsx-jsx-in-typescript)
12-
- [Using Closure Components in TSX](#using-closure-components-in-tsx)
11+
- [Setup for TypeScript](#setup-for-typescript)
12+
- [Using Closure Components in TypeScript with JSX](#using-closure-components-in-typescript-with-jsx)
1313
- [Differences with React](#differences-with-react)
1414
- [JSX vs hyperscript](#jsx-vs-hyperscript)
1515
- [Tips and Tricks](#tips-and-tricks)
@@ -60,7 +60,7 @@ m.render(document.body, <MyComponent />)
6060

6161
---
6262

63-
### Setup JSX
63+
### Setup for JavaScript
6464

6565
When using JavaScript, the simplest way to use JSX is via a [Babel](https://babeljs.io/) plugin. (For TypeScript, follow the [instructions below](#setup-tsx-jsx-in-typescript).)
6666

@@ -261,7 +261,7 @@ Add `jsx` and `jsxFactory` to `compilerOptions` in your `tsconfig.json`:
261261

262262
This setup should be enough to get most JSX functionality working.
263263

264-
#### Using closure components in TSX
264+
#### Using closure components in TypeScript with JSX
265265
>Because of https://github.com/microsoft/TypeScript/issues/21699, we advise against using [closure components](components.md#closure-component-state) in TypeScript for now. Either use [class components](components.md#class-component-state) without attribute inspection or Hyperscript instead (see the list of alternatives below the code example).
266266
267267
TypeScript only expects an attribute object as a parameter. But Mithril.js provides a `Vnode` object instead. This leads to the editor showing faulty parameters even though the JSX would compile correctly. If you want to use closure components in TypeScript, you need to trick the TypeScript error checking.

0 commit comments

Comments
 (0)