Developing in TypeScript
When you run the
.ts files that import the necessary type definitions from our NPM package. It will also create a
tsconfig.json, which allows you to adjust TypeScript's settings.
Build Step Required
You will need to build your TypeScript before running commands such as
connect test or
connect publish to ensure that the command is using your latest code. To make this easier, we add the following scripts to your
npm run build. You can also customize the build script however you need, such as passing options to the compiler or add pre-build or post-build steps.
The "watch" script runs the TypeScript compiler in "watch mode", which automatically detects source code changes and does a fast, differential rebuild. Note that you'll need to leave your terminal window running, and you'll need to open a new terminal window to perform any other commands, such as