Skip to content

[@types/serverless] Add Serverless Framework v4 types and comprehensive JSDoc documentation - #74484

Merged
typescript-bot merged 9 commits into
DefinitelyTyped:masterfrom
ofri-peretz:feature/serverless-add-v4-types
Feb 12, 2026
Merged

typescript-bot merged 9 commits into
DefinitelyTyped:masterfrom
ofri-peretz:feature/serverless-add-v4-types

Conversation

@ofri-peretz

@ofri-peretz ofri-peretz commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds support for Serverless Framework v4 properties and significantly improves the documentation of the AWS provider type definitions.

Breaking Changes

None. This PR only adds optional properties and documentation. All existing type definitions remain unchanged and backward compatible.


🆕 New v4-Specific Properties (@since v4)

Root Serverless Interface

Property Type Description
stages Stages Stage-specific configuration for parameters, observability, and integrations
build Build | false Native build configuration for TypeScript/JavaScript bundling with EsBuild

Provider Interface

Property Type Description
licenseKey string Serverless Framework license key for v4+

New Interfaces

Interface Description
Stages Map of stage names to stage configurations
StageConfig Configuration for a specific stage (params, observability, resolvers)
StageResolvers Variable resolvers configuration (Vault, Terraform, custom)
VaultResolver HashiCorp Vault variable resolver (address, token, version, path)
TerraformResolver Terraform state variable resolver (s3, cloud, remote, http backends)
Build Native build configuration container
EsBuildConfig EsBuild bundler configuration (configFile, bundle, minify, sourcemap, external, target, platform)

VaultResolver Properties

Property Type Description
address string Vault server URL (or use VAULT_ADDR env var)
token string Authentication token (or use VAULT_TOKEN env var)
version string Vault API version (default: v1)
path string Default path prefix for secrets

TerraformResolver Properties

Property Type Description
type 's3' | 'cloud' | 'remote' | 'http' Terraform state backend type
bucket string S3 bucket name (for s3 backend)
key string S3 object key for state file (for s3 backend)
region string AWS region (for s3 backend)
organization string Terraform Cloud/HCP organization name
workspaces { name?: string } Terraform Cloud/HCP workspace configuration
address string HTTP endpoint URL (for http backend)

EsBuildConfig Properties

Property Type Description
configFile string Path to esbuild config file relative to serverless.yml
bundle boolean Enable bundling
minify boolean Enable minification
sourcemap boolean Enable source maps
external string[] External packages to exclude from bundle
target string Target environment
platform 'node' | 'browser' Platform

⚠️ Deprecation Warnings

The following properties now include @deprecated annotations pointing to their modern replacements:

Serverless Interface

Deprecated Property Replacement Notes
variablesResolutionMode N/A Only relevant for v2 migrations
tenant org Use org property instead

Service Interface

Deprecated Property Replacement Notes
awsKmsKeyArn provider.kmsKeyArn Use kmsKeyArn at the provider level

Provider Interface

Deprecated Property Replacement Notes
lambdaHashingVersion N/A No longer needed in v3+
role iam.role Use IAM configuration instead
rolePermissionsBoundary iam.role.permissionsBoundary Use IAM configuration instead
iamRoleStatements iam.role.statements Use IAM configuration instead
iamManagedPolicies iam.role.managedPolicies Use IAM configuration instead
cfnRole iam.deploymentRole Use IAM configuration instead

Package Interface

Deprecated Property Replacement Notes
include patterns Use patterns with positive globs

AwsFunction Interface

Deprecated Property Replacement Notes
awsKmsKeyArn kmsKeyArn Use kmsKeyArn property instead

📚 Documentation Improvements

  • Added comprehensive JSDoc comments with @see links to official Serverless Framework documentation
  • Added @example blocks with YAML configuration examples
  • Documented all previously undocumented interfaces (50+ interfaces)
  • Added property-level documentation for all interface members
  • Added AWS Lambda Kafka documentation reference
  • Added migration warning for build property when using legacy bundler plugins

🐛 Bug Fixes

  • Fixed syntax error in YAML example where */* pattern was breaking JSDoc comment parsing (wrapped in quotes: '*/*')

Testing

  • ✅ TypeScript compilation passes with tsc --noEmit
  • ✅ No breaking changes to existing types
  • ✅ All additions are optional properties

References

@typescript-bot

typescript-bot commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor

@ofri-peretz Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.

This is a live comment that I will keep updated.

1 package in this PR

Code Reviews

Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by type definition owners or DT maintainers

All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 74484,
  "author": "ofri-peretz",
  "headCommitOid": "7387ede6eba2468218d57f24929f2fc0a9fb8b97",
  "mergeBaseOid": "95c727ac6ff4dfa56699b456e6411e1eac718f05",
  "lastPushDate": "2026-02-05T22:07:16.000Z",
  "lastActivityDate": "2026-02-12T06:49:52.000Z",
  "mergeOfferDate": "2026-02-12T06:25:54.000Z",
  "mergeRequestDate": "2026-02-12T06:49:52.000Z",
  "mergeRequestUser": "ofri-peretz",
  "hasMergeConflict": false,
  "isFirstContribution": true,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Popular",
  "pkgInfo": [
    {
      "name": "serverless",
      "kind": "edit",
      "files": [
        {
          "path": "types/serverless/plugins/aws/provider/awsProvider.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/serverless/serverless-tests.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "hassankhan",
        "JonathanWilbur",
        "a-pavlenko",
        "fredericbarthelet",
        "bryan-hunter",
        "thomasaribart",
        "G-Rath",
        "AbdullahAli",
        "fargito",
        "bacarybruno",
        "domazet93"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    }
  ],
  "reviews": [
    {
      "type": "approved",
      "reviewer": "fargito",
      "date": "2026-02-12T06:25:13.000Z",
      "isMaintainer": false
    }
  ],
  "mainBotCommentID": 3856551927,
  "ciResult": "pass"
}

@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Untested Change This PR does not touch tests labels Feb 5, 2026
@typescript-bot typescript-bot moved this to Waiting for Code Reviews in Pull Request Status Board Feb 5, 2026
@typescript-bot

Copy link
Copy Markdown
Contributor

🔔 @hassankhan @JonathanWilbur @a-pavlenko @fredericbarthelet @bryan-hunter @ThomasAribart @G-Rath @AbdullahAli @fargito @bacarybruno @domazet93 — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot typescript-bot added the The CI failed When GH Actions fails label Feb 5, 2026
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Author Action in Pull Request Status Board Feb 5, 2026
@typescript-bot

Copy link
Copy Markdown
Contributor

@ofri-peretz The CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

Note: builds that are failing do not end up on the list of PRs for the DT maintainers to review.

@typescript-bot typescript-bot removed The CI failed When GH Actions fails Untested Change This PR does not touch tests labels Feb 5, 2026
@typescript-bot typescript-bot moved this from Needs Author Action to Waiting for Code Reviews in Pull Request Status Board Feb 5, 2026
@ofri-peretz

Copy link
Copy Markdown
Contributor Author

@czubocha @eahefnawy

@czubocha

czubocha commented Feb 6, 2026

Copy link
Copy Markdown

Thanks for the contribution! One thing worth noting - the official @serverless/typescript package auto-generates its TypeScript definitions directly from the framework's JSON schema. It may be worth aligning with that as a source of truth.

I also validated the type changes here and found a few issues:

1. licenseKey is on the wrong interface
licenseKey is a root-level property, not a provider property. It should be on the Serverless interface, not Provider.

2. build type is incomplete
build accepts string | object. The PR types it as Build | false — missing the string variant (e.g. build: 'esbuild').

3. observability type is incomplete
The PR types it as boolean, but it also accepts 'axiom' | 'dashboard' strings and { provider: 'axiom' | 'dashboard'; dataset?: string } objects.

4. stages.*.resolvers types are incomplete
There are 13 built-in resolver types (aws, vault, terraform, env, file, param, self, git, sls, strToBool, output, doppler, opt), each with different config shapes - I think resolvers should be typed as an open object.

5. EsBuildConfig is incomplete
Missing properties: exclude, packages, buildConcurrency. Also sourcemap should accept boolean | { type: 'inline' | 'linked' | 'external'; setNodeOptions?: boolean }, not just boolean.

@ofri-peretz

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @czubocha, I'll fix your comments here.

I'll check the package you mentioned.

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Action in Pull Request Status Board Feb 6, 2026
@typescript-bot typescript-bot moved this from Needs Maintainer Action to Waiting for Code Reviews in Pull Request Status Board Feb 6, 2026
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Action in Pull Request Status Board Feb 6, 2026
@typescript-bot typescript-bot moved this from Needs Maintainer Action to Waiting for Code Reviews in Pull Request Status Board Feb 6, 2026
@ofri-peretz

Copy link
Copy Markdown
Contributor Author

@czubocha, I've addressed all your comments. Please re-review and confirm everything is ok, so the TypeScript team can see your confirmation and proceed.

@ofri-peretz

Copy link
Copy Markdown
Contributor Author

@czubocha if you’re referring to the Serverless Schema, the JSDoc comments are vital for a smooth developer experience. We use serverless.ts (not serverless.yml) across all our repositories, and having that inline documentation is what allows us to scale knowledge across multiple teams and organizations effectively. I’d be happy to show you our implementation if it helps provide context on why this is so critical for TypeScript-heavy workflows.

@czubocha

czubocha commented Feb 9, 2026

Copy link
Copy Markdown

Thanks @ofri-peretz, the types are looking much better now - the earlier issues have been addressed.

I also agree with you on the value of JSDoc comments for developer experience. We'll look into adding description fields to our JSON schema definitions so that @serverless/typescript (which uses json-schema-to-typescript) can auto-generate proper JSDoc comments as well.

Two things I noticed on the build types:

  1. Build.esbuild is currently typed as EsBuildConfig | undefined, but the esbuild plugin schema defines it as anyOf: [{ type: 'object', ... }, { type: 'boolean' }]. It should be boolean | EsBuildConfig | undefined — setting build.esbuild: false is the recommended way to disable the native build.

  2. The root-level build is typed as string | Build | false | undefined, but the config schema only allows string or object — not boolean. The way to disable esbuild is build: { esbuild: false }, not build: false. In practice, build: false wouldn't actually disable esbuild for TypeScript files since false?.esbuild evaluates to undefined, causing it to fall through to zero-config auto-detection. So false should be removed from the root build type.

Otherwise looks good to me!

@ofri-peretz

Copy link
Copy Markdown
Contributor Author

@czubocha thank you, apologies for missing these types. I'll update the PR later today.
Adding descriptions should be a great addition. If you will be able to generate JSDocs with good formatting and detailed using json-schema-to-typescript (which we're using the same approach to in our internal/platform packages), then the package under this repo can truly be deprecated!

I would want to add as a consumer that maybe worth after adding these descriptions to highlight or add extra explanation regarding serverless/typescript in your original docs, because many developers would miss how to find those types, and because these are generated during CI/CD runtime, they will not find the source code either.

… JSDoc documentation

- Add v4-specific properties: stages, build, Stages, StageConfig, Build, EsBuildConfig
- Add comprehensive JSDoc documentation with @see links to official docs
- Fix syntax error in YAML example (*/* pattern breaking JSDoc parsing)
- Document all previously undocumented interfaces
- Add @SInCE v4 annotations for new properties
- Add @deprecated annotations for legacy properties
…rning

- Add configFile property to EsBuildConfig for custom esbuild configuration
- Add migration warning for users coming from v3 with bundler plugins
- Allow build: false to disable native bundling during plugin migration
… types

- Add resolvers property to StageConfig for external data sources
- Add VaultResolver interface with address, token, version, path options
- Add TerraformResolver interface supporting s3, cloud, remote, http backends
- Add StageResolvers interface for custom named resolvers
- All new types marked with @SInCE v4 annotation
- Replace @minimum/@maximum tags with inline descriptions (CI lint fix)
- Add comprehensive tests for v4 types: stages, build, resolvers
- Test VaultResolver, TerraformResolver with all backend types
- Test EsBuildConfig with all properties
- Test backward compatibility with deprecated properties
- Test Kafka event with consumerGroupId
Fixes based on @czubocha's review:

1. licenseKey is on the wrong interface
   - Moved from Provider to root Serverless interface

2. build type is incomplete
   - Changed from 'Build | false' to 'string | Build | false'
   - Supports shorthand like 'build: esbuild'

3. observability type is incomplete
   - Added 'axiom' | 'dashboard' string variants
   - Added ObservabilityConfig object form with provider and dataset

4. stages.*.resolvers types are incomplete
   - Changed from StageResolvers to open object { [k: string]: unknown }
   - Accommodates all 13 built-in resolver types with varying shapes

5. EsBuildConfig is incomplete
   - Added missing properties: exclude, packages, buildConcurrency
   - Fixed sourcemap to accept boolean | SourcemapConfig object
   - Added SourcemapConfig interface with type and setNodeOptions
   - Added index signature for additional esbuild options

Added comprehensive tests for all new features.
@ofri-peretz
ofri-peretz force-pushed the feature/serverless-add-v4-types branch from 4506760 to 7387ede Compare February 10, 2026 08:07
@ofri-peretz

Copy link
Copy Markdown
Contributor Author

@czubocha I pushed the updates. Please confirm so the TS team can see that and set the tags as 'approved by owner'.

@czubocha

Copy link
Copy Markdown

Confirmed - both fixes look correct. Thanks!

@ofri-peretz

Copy link
Copy Markdown
Contributor Author

@typescript-bot What's next? How can we proceed? The author has confirmed the PR

@ofri-peretz

Copy link
Copy Markdown
Contributor Author

@ElizabethSamuel-MSFT @AlexJerabek Can one of you guide me on what comes next after the author of the popular package approves the PR? (I just saw you both able to approve PR and probably can assist)

@ofri-peretz

Copy link
Copy Markdown
Contributor Author

@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner labels Feb 12, 2026
@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Waiting for Author to Merge in Pull Request Status Board Feb 12, 2026
@typescript-bot

Copy link
Copy Markdown
Contributor

@ofri-peretz: Everything looks good here. I am ready to merge this PR (at 7387ede) on your behalf whenever you think it's ready.

If you'd like that to happen, please post a comment saying:

Ready to merge

and I'll merge this PR almost instantly. Thanks for helping out! ❤️

(@hassankhan, @JonathanWilbur, @a-pavlenko, @fredericbarthelet, @bryan-hunter, @ThomasAribart, @G-Rath, @AbdullahAli, @fargito, @bacarybruno, @domazet93: you can do this too.)

@ofri-peretz

Copy link
Copy Markdown
Contributor Author

Ready to merge

@typescript-bot typescript-bot moved this from Waiting for Author to Merge to Recently Merged in Pull Request Status Board Feb 12, 2026
@typescript-bot
typescript-bot merged commit 63f13c2 into DefinitelyTyped:master Feb 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Owner Approved A listed owner of this package signed off on the pull request. Popular package This PR affects a popular package (as counted by NPM download counts). Self Merge This PR can now be self-merged by the PR author or an owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants