TypeScript Configuration
Write serverless.ts instead of serverless.yml for full type safety.
Why TypeScript?
YAML files have no type checking. A typo in memorySize vs MemorySize or an invalid runtime string won't fail until deploy time — sometimes not even then.
With @interlace/serverless-devkit, every configuration option is typed. Your editor catches errors as you type.
Setup
1. Install
npm install @interlace/serverless-devkit2. Create serverless.ts
import { defineConfig, defineFunction } from '@interlace/serverless-devkit';
export default defineConfig({
service: 'my-api',
provider: {
name: 'aws',
runtime: 'nodejs20.x',
region: 'us-east-1',
memorySize: 512,
environment: {
TABLE_NAME: 'my-table',
},
},
plugins: ['@interlace/serverless-api-gateway-caching'],
custom: {
interlaceCaching: {
enabled: true,
clusterSize: '0.5',
ttlInSeconds: 300,
},
},
functions: {
getUser: defineFunction({
handler: 'src/handlers/getUser.handler',
events: [
{
http: {
path: '/users/{id}',
method: 'get',
caching: {
enabled: true,
cacheKeyParameters: [{ name: 'request.path.id' }],
},
},
},
],
}),
},
});3. Deploy
The Serverless Framework natively supports .ts config files:
sls deployBenefits
- Autocomplete — every AWS provider option, event type, and plugin setting
- Type errors — invalid values caught before deploy
- Refactoring — rename a function and all references update
- Reusable patterns — share typed configs across services via imports
Serverless Devkit
TypeScript-first configuration toolkit for Serverless Framework — defineConfig, defineFunction, and typed plugin helpers.
Extending defineConfig types
How third-party @interlace plugins can opt into typed `custom.*` config without devkit ever knowing about them — via TypeScript module augmentation.