The `serverless-plugin-typescript` package offers zero-configuration TypeScript support for applications built with the Serverless Framework, particularly targeting AWS Lambda functions. It automatically handles the compilation of TypeScript source files to JavaScript during standard Serverless deployment lifecycle hooks, such as `sls package`, `sls deploy`, and `sls deploy function`. The current stable version is 2.1.5, with the last update in June 2023 addressing minor bug fixes. Major version changes are less frequent, with v2.0.0 released in September 2021, indicating a slower, maintenance-oriented release cadence rather than rapid feature additions. A key differentiator is its 'zero-config' philosophy, allowing developers to integrate TypeScript without needing to set up Webpack, Babel, or other complex build tools, making it an attractive option for simpler Serverless projects. It supports modern ES2015+ features like `async/await` and works well with `sls invoke local` (including a `--watch` mode) and the popular `serverless-offline` plugin for local development and testing.
npm install serverless-plugin-typescriptVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to enable the plugin and create a basic TypeScript-based AWS Lambda function, including the necessary `serverless.yml`, `handler.ts`, and `tsconfig.json` files. This setup enables automatic compilation and local testing with `serverless-offline`.
Upgrade your Serverless Framework installation to v2.x or v3.x (`npm install -g serverless`).
Ensure your Node.js environment is v10 or later.
Adjust your build process to rely on the plugin's default output directory (`.build`) and root directory behavior, or ensure your tsconfig aligns with these fixed values.
Update your `serverless.yml` to ensure `- serverless-plugin-typescript` appears before `- serverless-offline` in the `plugins` section.
Add a `"main": "handler.js"` entry to your `package.json` and ensure the referenced TypeScript file (e.g., `handler.ts`) exists.
Install TypeScript in your project: `npm install -D typescript` or `yarn add -D typescript`.
Update your `serverless.yml` to ensure `- serverless-plugin-typescript` appears before `- serverless-offline` in the `plugins` section.
Verify your Serverless Framework version. If it's v1.x, either upgrade Serverless Framework to v2/v3 (`npm install -g serverless`) or downgrade `serverless-plugin-typescript` to a v1.x version that supports Serverless v1.