Skip to content

(aws-apigateway): TS compilation error when exactOptionalPropertyTypes set true #19077

@victorsmirnov

Description

@victorsmirnov

General Issue

TypeScript compilation fails when exactOptionalPropertyTypes is set to true

The Question

Compilation fails when exactOptionalPropertyTypes is set to true.

Several other modules also have the same error.

> tsc

node_modules/aws-cdk-lib/aws-apigateway/lib/restapi.d.ts:226:31 - error TS2420: Class 'RestApiBase' incorrectly implements interface 'IRestApi'.
  Types of property 'latestDeployment' are incompatible.
    Type 'Deployment | undefined' is not assignable to type 'Deployment'.
      Type 'undefined' is not assignable to type 'Deployment'.

226 export declare abstract class RestApiBase extends Resource implements IRestApi {
                                  ~~~~~~~~~~~

CDK CLI Version

2.13.0

Framework Version

2.13.0

Node.js Version

16.12.0

OS

macOS Big Sur

Language

Typescript

Language Version

TypeScript (4.5.5)

Other information

Most likely, replacing readonly latestDeployment?: Deployment; with readonly latestDeployment: Deployment | undefined; should fix the issue. I can try this as my first issue in the project. Please let me know if I should make a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p2package/toolsRelated to AWS CDK Tools or CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions