# preact-cli-plugin-typescript

> Use TypeScript with preact-cli

Latest version **0.2.2** (published 2017-07-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install preact-cli-plugin-typescript
pnpm add preact-cli-plugin-typescript
yarn add preact-cli-plugin-typescript
bun add preact-cli-plugin-typescript
```

Provides the command `preact-cli-plugin-typescript`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2017-07-18 |
| First published | 2017-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 49 |
| Author | Jarrod Mosen |
| Maintainers | jarrod-mosen |
| Keywords | preact, preact-cli, typescript |

## Links

- npm: https://www.npmjs.com/package/preact-cli-plugin-typescript
- Repository: https://github.com/wub/preact-cli-plugin-typescript
- Homepage: https://github.com/wub/preact-cli-plugin-typescript#readme
- Issues: https://github.com/wub/preact-cli-plugin-typescript/issues
- npm.io page: https://npm.io/package/preact-cli-plugin-typescript

## Dependencies (2)

- [typescript](https://npm.io/package/typescript.md) ^2.4.1
- [awesome-typescript-loader](https://npm.io/package/awesome-typescript-loader.md) ^3.2.1

## 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

- 0.2.2 (latest) — 2017-07-18
- 0.2.1 — 2017-07-18
- 0.2.0 — 2017-07-18
- 0.1.2 — 2017-07-18
- 0.1.1 — 2017-07-18
- 0.1.0 — 2017-07-17

## README

# preact-cli-plugin-typescript &middot; [![Build status](https://img.shields.io/travis/wub/preact-cli-plugin-typescript/master.svg?label=build&maxAge=43200)](https://travis-ci.org/wub/preact-cli-plugin-typescript) [![npm version](https://img.shields.io/npm/v/preact-cli-plugin-typescript.svg)](https://www.npmjs.com/package/preact-cli-plugin-typescript) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

Use TypeScript with [preact-cli](https://github.com/developit/preact-cli).

This will install [typescript](https://github.com/Microsoft/TypeScript)
and [awesome-typescript-loader](https://github.com/s-panferov/awesome-typescript-loader).

If you prefer Flow, check out [preact-cli-plugin-flow](https://github.com/SaraVieira/preact-cli-plugin-flow).

## Installation

Install via npm:

```shell
npm i preact-cli-plugin-typescript --save-dev
```

After installation, this plugin will create a `tsconfig.json` (TypeScript 
configuration file), and `preact.config.js`, if they don't exist already.

In the root of your project, edit `preact.config.js` to add the plugin:

```js
import preactCliTypeScript from 'preact-cli-plugin-typescript'

export default function(config) {
  preactCliTypeScript(config)
}
```

## Usage

### Existing `tsconfig.json`

If you have an existing `tsconfig.json` file, be sure to use the correct
JSX factory:

```json
{
  "compilerOptions": {
    "jsx": "react",
    "jsxFactory": "h"
  }
}
```

Now you can simply add `.ts`/`.tsx` files to your project, and they'll
be compiled. Cool. Make sure you use `.tsx` if you want to use JSX.

### Mixing JavaScript and TypeScript

You might see an error like
`Module './components/app' was resolved to '/src/components/app.js', but '--allowJs' is not set.`.

To fix this, or if you want to incrementally move to TypeScript, make sure
`allowJs` is enabled in your `tsconfig.json`:

```json
{
  "compilerOptions": {
    "allowJs": true
  }
}
```

### Changing the entrypoint

By default, preact-cli looks for `src/index.js` to start your app. This plugin
widens the scope to "any file in `src` that starts with `index` and has
a file extension resolved by webpack" - to change this,
override the `preact-cli-entrypoint` in `preact.config.js`:

```js
import { resolve } from 'path'

export default function (config, env, helpers) {
  preactCliTypeScript(config)

  config.resolve.alias['preact-cli-entrypoint'] = resolve(__dirname, 'src', 'foo-file.foo-extension')
}

```

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