Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error in modules/example-node/src/kms_filtered_discovery.ts #1520

Open
elmaimbo opened this issue Nov 15, 2024 · 1 comment
Open

Comments

@elmaimbo
Copy link

Problem:

Attempting to compile the example code in "modules/example-node/src/kms_filtered_discovery.ts" results in a Typescript compile error:

Type 'KmsClientSupplier<KMS>' is not assignable to type 'KmsClientSupplier<AwsEsdkKMSInterface>'.
  Type 'KMS' is not assignable to type 'AwsEsdkKMSInterface'.
    The types returned by 'decrypt(...)' are incompatible between these types.
      Type 'Promise<DecryptCommandOutput>' is not assignable to type 'Promise<DecryptResponse> | AwsSdkV2Response<DecryptResponse>'.
        Type 'Promise<DecryptCommandOutput>' is not assignable to type 'Promise<DecryptResponse>'.
          Type 'DecryptCommandOutput' is not assignable to type 'DecryptResponse' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
            Types of property 'KeyId' are incompatible.
              Type 'string | undefined' is not assignable to type 'string'.
                Type 'undefined' is not assignable to type 'string'.

The problem goes away if you comment out line 38:

    const keyring = new KmsKeyringNode({
    //   clientProvider,
      discovery,
      discoveryFilter,
    })

But this is not a real solution, because what I actually want is to limit the AWS regions, which is achieved using the following on line 29:

const clientProvider = limitRegions(['ap-southeast-2'], getKmsClient)
@elmaimbo
Copy link
Author

I've worked out what caused this issue. It was the following line in my tsconfig.json file:

"exactOptionalPropertyTypes": true,

The typescript documentation for this option can be found here: https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes

For now I've commented out this line and my program compiles successfully.

Nick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant