Skip to content

Commit a0829d6

Browse files
erickzhaogitbook-bot
authored andcommitted
GITBOOK-216: Update TypeScript configuration docs
1 parent 9a226ca commit a0829d6

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

config/typescript-configuration.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,19 @@
22
description: Set up your Forge configuration to use TypeScript
33
---
44

5-
# TypeScript Configuration
6-
7-
By default, Electron Forge's [configuration](./configuration.md) only supports JavaScript and JSON files as inputs.
8-
9-
Forge also supports configuration files in other languages that transpile down to JavaScript as long as a transpiler is installed locally in your project's `devDependencies`. These configuration files follow the same format as `forge.config.js`.
5+
# TypeScript Setup
106

117
## Installation
128

13-
For TypeScript, we recommend installing [`ts-node`](https://github.com/TypeStrong/ts-node). Upon installation, it will automatically be registered as a module loader for `.ts` files.
9+
As of [Forge v7.8.1](https://github.com/electron/forge/releases/tag/v7.8.1), Electron Forge loads `forge.config.ts` files without any additional configuration using [`jiti`](https://github.com/unjs/jiti).
1410

15-
```bash
16-
npm install --save-dev ts-node
17-
```
11+
{% hint style="warning" %}
12+
For older versions, follow the [#alternate-file-syntaxes](typescript-configuration.md#alternate-file-syntaxes "mention") section below with the [`ts-node`](https://github.com/TypeStrong/ts-node) package.
13+
{% endhint %}
1814

1915
## Configuration file
2016

21-
Once you have `ts-node` installed, Forge will be able to load a `forge.config.ts` file from your project's root directory.
22-
23-
This config format is functionally identical to `forge.config.js`.
17+
Forge's TypeScript format is functionally identical to `forge.config.js`. Types can be imported from the [`@electron-forge/shared-types`](https://www.npmjs.com/package/@electron-forge/shared-types) package.
2418

2519
{% code title="forge.config.ts" %}
2620
```typescript
@@ -85,3 +79,13 @@ const config: ForgeConfig = {
8579
export default config;
8680
```
8781
{% endcode %}
82+
83+
## Alternate file syntaxes
84+
85+
Forge also supports configuration files in other languages that transpile down to JavaScript as long as a module loader for that language is installed locally in your project's `devDependencies`. For example, installing `coffeescript` enables Forge to read from a `forge.config.ts` file.
86+
87+
These configuration files follow the same format as `forge.config.js`.
88+
89+
{% hint style="info" %}
90+
The transpiler module you use needs to be compatible with [`interpret`](https://github.com/gulpjs/interpret) to work.
91+
{% endhint %}

0 commit comments

Comments
 (0)