|
2 | 2 | description: Set up your Forge configuration to use TypeScript |
3 | 3 | --- |
4 | 4 |
|
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 |
10 | 6 |
|
11 | 7 | ## Installation |
12 | 8 |
|
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). |
14 | 10 |
|
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 %} |
18 | 14 |
|
19 | 15 | ## Configuration file |
20 | 16 |
|
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. |
24 | 18 |
|
25 | 19 | {% code title="forge.config.ts" %} |
26 | 20 | ```typescript |
@@ -85,3 +79,13 @@ const config: ForgeConfig = { |
85 | 79 | export default config; |
86 | 80 | ``` |
87 | 81 | {% 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