Serverless.ts provider.apiGateway.shouldStartNameWithService


I am kicking off a new project with a new Serverless TypeScript monorepo! Used the aws-nodejs-typescript template, which gave me a serverless.ts config file. After some weeks, I am now getting the nice warning below from Serverless on command line.

Ok! Looks great, and I like the new naming. And since it’s a new project, better to apply the new naming now, before we release anything. However, it looks like the TypeScript definitions are rather strict, and do not seem to allow for the new variable yet. TS error is below as well.

It is definitely possible to translate the serverless.ts file to YAML, but since the template came with serverless.ts, I am hoping there is a way to move forward w/o abandoning serverless.ts.

Please advise,

– Tim

Serverless: Deprecation warning: Starting with next major version, API Gateway naming will be changed from “{stage}-{service}” to “{service}-{stage}”.
Set “provider.apiGateway.shouldStartNameWithService” to “true” to adapt to the new behavior now.
More Info:

Loading failed with: TSError: ⨯ Unable to compile TypeScript:
serverless.ts(44,7): error TS2322: Type ‘{ minimumCompressionSize: number; shouldStartNameWithService: true; }’ is not assignable to type ‘ApiGateway’.
Object literal may only specify known properties, and ‘shouldStartNameWithService’ does not exist in type ‘ApiGateway’.

awsProvider.d.ts(51, 9): The expected type comes from property ‘apiGateway’ which is declared here on type ‘Provider’

This post got hidden by “community flags”, but I was able to get an assist on SO. Can’t seem to post a link to the SO question here either, so please search and I’m certain you will find it. Basically need to coerce the TS type.

The type coercion looks like this:

    apiGateway: {
      minimumCompressionSize: 1024,
      shouldStartNameWithService: true,
    } as ApiGateway,