{"library":"serverless-plugin-typescript","title":"Serverless TypeScript Plugin","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install serverless-plugin-typescript"],"cli":{"name":"sls","version":null}},"imports":["plugins:\n  - serverless-plugin-typescript"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"/* serverless.yml */\nservice: my-typescript-service\n\nframeworkVersion: \"2 || 3\"\n\nprovider:\n  name: aws\n  runtime: nodejs16.x # Or a newer supported Node.js version\n  region: us-east-1\n\nplugins:\n  - serverless-plugin-typescript\n  - serverless-offline # Example for common integration\n\nfunctions:\n  hello:\n    handler: handler.hello\n    events:\n      - http:\n          path: hello\n          method: get\n\n/* handler.ts */\nimport { APIGatewayProxyHandler } from 'aws-lambda';\n\nexport const hello: APIGatewayProxyHandler = async (event, context) => {\n  return {\n    statusCode: 200,\n    body: JSON.stringify(\n      {\n        message: 'Go Serverless with TypeScript! Your function executed successfully!',\n        input: event,\n      },\n      null,\n      2\n    ),\n  };\n};\n\n/* tsconfig.json */\n{\n  \"compilerOptions\": {\n    \"preserveConstEnums\": true,\n    \"strictNullChecks\": true,\n    \"sourceMap\": true,\n    \"allowJs\": true,\n    \"target\": \"es5\", // Plugin default, cannot be overridden via tsconfig.json for compilation target\n    \"outDir\": \".build\", // Plugin default, cannot be overridden\n    \"moduleResolution\": \"node\",\n    \"lib\": [\"es2015\"], // Plugin default\n    \"rootDir\": \"./\", // Plugin default, cannot be overridden\n    \"esModuleInterop\": true,\n    \"resolveJsonModule\": true\n  },\n  \"include\": [\"**/*\"],\n  \"exclude\": [\"node_modules\", \".build\"]\n}\n","lang":"typescript","description":"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`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}