TypeScript in the Homey CLI
How it works
Creating new drivers with TypeScript
When the file tsconfig.json is present in the root folder of your app, the Homey CLI will default to TypeScript when running homey app driver create. If you want to avoid this, remove or rename tsconfig.json file.
Removing or remaning the tsconfig.json file will also prevent the TypeScript compiler from being invoked when running/installing/publishing your app.
Creating a new app using TypeScript
Run homey app create in your terminal and answer 'Yes' when the CLI asks you to initialize your app with TypeScript utilities. All necessary and recommended dependencies and files will be created for you.
Converting an existing app to TypeScript
Create a .tsconfig.json
The first thing to do is adding a file named .tsconfig.json to the root folder of your App. This will make Homey recognize your app as a TypeScript app. You are free to configure tsconfig.json to your liking. Only exception being the outDir which should remain build and having sourceMap: true is strongly recommended.
Make sure you have the file .tsconfig.json present in the root folder of your app. Then run the following command to install all necessary dependencies.
homey app add-types
Change your App entrypoint:
Rename app.js to app.ts and add the following lines at the top (You can remove 'use strict').
import sourceMapSupport from 'source-map-support';
Add the build step
Add a TypeScript transpile step in the npm build script.
Now you're all set! Run your app with homey app run. If you performed all steps correctly, then you should see a Compiling TypeScript... prompt before your app is being run.