-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,275 additions
and
1,774 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Jarrod Mosen <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,62 @@ | ||
# preact-cli-plugin-typescript | ||
# preact-cli-plugin-typescript · [![Travis Status](https://img.shields.io/travis/wub/preact-cli-plugin-typescript/master.svg?label=travis&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) | ||
- [awesome-typescript-loader](https://github.com/s-panferov/awesome-typescript-loader) | ||
|
||
In the future, you'll be able to choose between `awesome-typescript-loader` | ||
and `ts-loader`. | ||
|
||
If you prefer Flow, check out [preact-cli-plugin-flow](https://github.com/SaraVieira/preact-cli-plugin-flow). | ||
|
||
## Getting Started | ||
## Installation | ||
|
||
Install via npm or yarn: | ||
Install via npm: | ||
|
||
```shell | ||
npm i preact-cli-plugin-typescript --save-dev | ||
``` | ||
```shell | ||
yarn add preact-cli-plugin-typescript --dev | ||
``` | ||
|
||
This will install: | ||
|
||
- [typescript](https://github.com/Microsoft/TypeScript) | ||
- [awesome-typescript-loader](https://github.com/s-panferov/awesome-typescript-loader) | ||
After installation, this plugin will create a `tsconfig.json` (TypeScript | ||
configuration file), and `preact.config.js`, if they don't exist already. | ||
|
||
After installation, this plugin will create a `tsconfig.json` (TypeScript configuration file). | ||
## Usage | ||
|
||
Create or edit `preact.config.js` to add the plugin: | ||
In the root of your project, edit `preact.config.js` to add the plugin: | ||
|
||
```javascript | ||
```js | ||
import preactCliTypeScript from 'preact-cli-plugin-typescript'; | ||
|
||
export default function (config) { | ||
preactCliTypeScript(config); | ||
} | ||
``` | ||
|
||
TypeScript will now be compiled. Cool. | ||
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. | ||
|
||
If you want to incrementally move to TypeScript, be sure to enable `allowJs` | ||
in your `tsconfig.json`: | ||
|
||
```json | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.