# ts-plugin-inferno

> A typescript transformer for InfernoJS

Latest version **10.0.0** (published 2026-10-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-plugin-inferno
pnpm add ts-plugin-inferno
yarn add ts-plugin-inferno
bun add ts-plugin-inferno
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support; large bundle.

## Facts

| | |
|---|---|
| Version | 10.0.0 |
| Published | 2026-10-04 |
| First published | 2022-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=24 |
| Dependencies | 1 |
| Unpacked size | 107.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Deam Hansen, Sampo Kivistö |
| Maintainers | havunen |
| Keywords | typescript, transform, inferno |

## Links

- npm: https://www.npmjs.com/package/ts-plugin-inferno
- Repository: https://github.com/infernojs/ts-plugin-inferno
- Homepage: https://github.com/infernojs/ts-plugin-inferno#readme
- Issues: https://github.com/infernojs/ts-plugin-inferno/issues
- npm.io page: https://npm.io/package/ts-plugin-inferno

## Dependencies (1)

- [typescript](https://npm.io/package/typescript.md) ^6

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 10.0.0 (latest) — 2026-10-04
- 7.0.0 — 2026-09-25
- 6.2.0 — 2026-08-19
- 6.1.1 — 2025-06-11
- 6.1.0 — 2024-08-31
- 6.0.3 — 2023-12-12
- 6.0.2 — 2023-09-08
- 6.0.1 — 2023-09-08
- 6.0.0 — 2023-04-06
- 5.0.0 — 2023-03-26
- 1.1.0 — 2023-01-22
- 1.0.6 — 2022-12-01
- 1.0.5 — 2022-12-01
- 1.0.4 — 2022-11-29
- 1.0.3 — 2022-10-05
- … 3 more at https://npm.io/package/ts-plugin-inferno/versions

## README

# ts-plugin-inferno

[![npm version](https://badge.fury.io/js/ts-plugin-inferno.svg)](https://badge.fury.io/js/ts-plugin-inferno)

Typescript JSX transformer for [InfernoJS](https://github.com/infernojs/inferno).

This is a plugin for Typescript compiler that compiles Typescript JSX syntax ( TSX ) directly to Inferno API to avoid createElement method calls.

## Inferno versions

Version 10 of the plugin compiles JSX for Inferno 10. It calls `newVNode`, `newComponentVNode`, `newFragment` and `newTextVNode`, and writes the flags of each vNode, including the shape of its children, as one number. For example `<div>Hello</div>` becomes `newVNode(3, "div", null, "Hello")`: `HtmlElement` (1) and `HasTextChildren` (2).

For Inferno 9 and older, use version 7 of the plugin. Inferno 10 numbers its vNode flags differently, so code compiled by version 7 has to be compiled again for Inferno 10.

From version 10 on, the major version of the plugin matches the major version of Inferno: use plugin 10.x with Inferno 10.x, plugin 11.x with Inferno 11.x, and so on. See the [Inferno 10 migration guide](https://github.com/infernojs/inferno/blob/master/documentation/v10-migration.md).

# Install

`yarn add -D ts-plugin-inferno typescript`

The compiled code imports `inferno`, so the project needs `inferno` 10 installed.

## General usage

```javascript
const transformInferno = require('ts-plugin-inferno').default

// Typescript compiler options
options: {
    getCustomTransformers: () => ({
        after: [transformInferno()],
    }),
},
```

It's different depending on what bundler you're using. Please check the examples folder.

The plugin imports the Inferno functions that the compiled JSX calls (`newVNode`, `newComponentVNode`, ...) in the module format of the output.
A file without imports and exports is a script (unless `moduleDetection` is `"force"`), which TypeScript emits without a module wrapper, so the plugin requires them there with `require("inferno")`: an import declaration would turn the script into a module.

## Options

```javascript
transformInferno({
    uselessFlags: 'warn'
})
```

### uselessFlags

What to do about [useless flags](#useless-flags):

- `'warn'` (default): print a warning with `console.warn`.
- `'error'`: stop the build with an error that points at the flag. For example, CI can use it to keep useless flags out.
- `'off'`: do nothing.

Any other value throws when the plugin is created, so a typo does not turn the check off silently.
To use a different level in CI, set it where the plugin is created:

```javascript
after: [transformInferno({
    // Most CI services set CI=true
    uselessFlags: process.env.CI ? 'error' : 'warn'
})],
```

## Special flags

The plugin provides a few compile time flags that can be used to optimize an Inferno application:

```tsx
// ChildFlags
<div $HasTextChildren /> - Children is rendered as pure text
<div $HasVNodeChildren /> - Children is another vNode (Element or Component)
<div $HasNonKeyedChildren /> - Children is always an array without keys
<div $HasKeyedChildren /> - Children is an array of vNodes having unique keys
<div $ChildFlag={expression} /> - Defines the children shape at runtime, see ChildFlags in inferno-vnode-flags

// Functional flags
<div $Flags={expression} /> - Replaces the vNode flags, see VNodeFlags in inferno-vnode-flags
```

`$ChildFlag` and `$Flags` need a value, a valueless one is a compile error.

`$ReCreate` has been removed in Inferno 10, and the plugin throws an error for it. To re-create an element, change its key instead, for example `key={version}`: Inferno unmounts the old element and mounts a new one when the key changes.

A `$ChildFlag` written as a ChildFlags number, e.g. `$ChildFlag={16}` (HasTextChildren), is packed into the flags like the other child flags. Any other `$ChildFlag` expression is only known at runtime, so that element is compiled to the deprecated `createVNode` (or `createFragment`), which converts the value.

`$Flags={expression}` replaces the flags of the element; the plugin still adds the child bit of the children, and `HasInvalidChildren` (16) for a component.

The flags the plugin writes, from `VNodeFlags` of inferno-vnode-flags 10:

| Flag | Value | Written for |
| --- | --- | --- |
| `ComponentUnknown` | 0 | components; Inferno sets the component type at runtime |
| `HtmlElement` | 1 | elements |
| `HasTextChildren` | 2 | one text child |
| `HasNonKeyedChildren` | 4 | an array of children without keys |
| `HasVNodeChildren` | 8 | one element or component child |
| `HasInvalidChildren` | 16 | no children |
| `HasKeyedChildren` | 32 | an array of children that all have a key |
| `SvgElement` | 64 | SVG elements |
| `Fragment` | 256 | Fragments |
| `InputElement` | 512 | `<input>` |
| `TextareaElement` | 2048 | `<textarea>` |
| `SelectElement` | 4096 | `<select>` |
| `ContentEditable` | 131072 | elements and components with a `contentEditable` prop |

Children that need normalizing, such as `{expression}`, get no child bit, e.g. `<div>{a}</div>` becomes `newVNode(1, "div", null, a)`.

### Invalid flags

When the JSX shows that the children cannot have the shape a child flag declares, the plugin throws an error that points at the flag. Inferno would otherwise render the children wrong or throw in development. For example:

```tsx
// An array is not a single vNode
<div $HasVNodeChildren><a/><b/></div>
<div $HasVNodeChildren>{[a, b]}</div>

// Text is not a vNode, and an element is not text
<div $HasVNodeChildren>text</div>
<div $HasTextChildren><a/></div>

// One element is not an array, and keyed children need keys
<ul $HasNonKeyedChildren><li/></ul>
<ul $HasKeyedChildren><li key="1"/><li/></ul>

// Not a ChildFlags value
<div $ChildFlag={3}>{a}</div>
```

```
/project/src/App.tsx(1,6): $HasVNodeChildren needs one element or component child, but there are 2 children.
> 1 | <div $HasVNodeChildren><a/><b/></div>
    |      ^^^^^^^^^^^^^^^^^
```

Dynamic children such as `{expression}` are not checked, and neither are the children of components. Parentheses and type assertions do not hide a child, e.g. `{<a/> as any}` is an element. The `uselessFlags` option does not change this check.

### Useless flags

Child flags are only needed for children whose shape the plugin cannot see, such as `{expression}` children or a `children={expression}` prop.
When the children are written as JSX, the plugin sets the child flags itself.
It warns about flags that cannot improve the output:

```tsx
// The children are known at compile time: the plugin already compiles them with HasVNodeChildren
<div $HasVNodeChildren>
  <h1>Hi</h1>
</div>

// Components get their children in props.children, so child flags do nothing
<Foo $HasKeyedChildren>{items}</Foo>

// Only one child flag applies. The order is $ChildFlag, $HasKeyedChildren, $HasNonKeyedChildren,
// $HasTextChildren, $HasVNodeChildren
<div $HasKeyedChildren $HasNonKeyedChildren>{items}</div>

// $Flags has no effect on Fragments
<Fragment $Flags={1}>{items}</Fragment>
```

A warning shows the file, line and column, the reason and the code around the flag:

```
ts-plugin-inferno: /project/src/App.tsx(3,10): $HasVNodeChildren is not needed: the children are known at compile time, so the plugin sets their child flags. Child flags only help with dynamic children such as {expression}.
  1 | function App() {
  2 |   return (
> 3 |     <div $HasVNodeChildren>
    |          ^^^^^^^^^^^^^^^^^
  4 |       <h1>Hi</h1>
  5 |     </div>
  6 |   );
```

With `uselessFlags: 'error'` the build fails at the first useless flag, with the same message and code.
The warnings do not change the compiled code. Remove the flags they point at, or set `uselessFlags: 'off'`.

## Breaking change in v6.0.0


Since version v6.0.0 this plugin only supports Javascript runtime environment where `Object.assign` is available.
It's also highly recommended to set typescript settings as follows

- `compilerOptions.module` to `ES2015` or `ES6` or higher.
- `commpilerOptions.target` to `ES2015` or higher



## Usage with FuseBox

Look into the `examples/fuse-box` folder and the `fuse.js` file.

You could also try to build the project by running the following commands:

`cd examples/fuse-box && npm install`

`npm run start:dev` or `npm run start:prod`

## Usage with webpack and ts-loader

Look into the `examples/webpack` folder and its webpack config.

You could also try to build the project by running the following commands:

`cd examples/webpack && npm install`

`npm run build:prod` or `npm start`

## Testing

You can run the following command to test: `npm test`

### Adding test cases

Write your test in a `.tsx` file and add it to `tests/cases`.

Compile with `npm test` and look into the `tests/temp` and verify.

Overwrite references by running the following command: `npm run overwrite-references`

Run `npm test` again to verify that all tests are passing.

## Benchmarks

`bench/` measures how much time and memory the plugin itself costs, separated from what TypeScript costs anyway.
It has no dependencies beyond the ones the tests use.

```bash
npm run bench            # every case, about 5 minutes
npm run bench:quick      # shorter runs, without the largest case
npm run bench:compare    # working tree against HEAD; pass another ref with -- --baseline <ref>
npm run bench:profile    # CPU and allocation profile of the plugin functions (case mixed-M)
node bench/run.js --help # filters, compiler options, rounds, output file
```

The plugin is built from `src/` into `bench/.cache/` for every run; a git baseline is extracted and built the same way,
so the two only differ by the plugin's code. `--baseline` also takes a directory with a built plugin, e.g. a copy of
the published package.

The cases are the same as in babel-plugin-inferno's benchmark, so the results of the two plugins compare: hand-written
components in `bench/fixtures/` (a TodoMVC app, a dashboard, an SVG icon set, an article and a TSX form) and generated
modules from `bench/generate.js`: random but seeded component trees of 200, 2,000 and 20,000 JSX nodes
(`mixed-S/M/L`), a list of 2,000 keyed children (`wide-M`) and elements nested 200 deep (`deep-M`).


## Credits

This is fork of awesome [ts-transform-inferno](https://github.com/deamme/ts-transform-inferno)!

---
_Source: https://npm.io/package/ts-plugin-inferno · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
