Skip to content

var awslambda declaration conflicts with @types/aws-lambda namespace declaration (TS2300) #22

@rubenfonseca

Description

@rubenfonseca

Description

When using @aws/lambda-invoke-store alongside @types/aws-lambda, TypeScript compilation fails with:

error TS2300: Duplicate identifier 'awslambda'.

Root Cause

@aws/lambda-invoke-store declares awslambda as a variable:

declare global {
    var awslambda: {
        InvokeStore?: InvokeStoreBase;
        [key: string]: unknown;
    };
}

@types/aws-lambda declares awslambda as a namespace:

declare global {
    namespace awslambda {
        class HttpResponseStream extends Writable { ... }
    }
}

TypeScript does not allow both a var and namespace with the same identifier.

Reproduction

  1. Create a project with both dependencies:

    {
      "dependencies": {
        "@aws-lambda-powertools/batch": "^2.29.0",
        "@types/aws-lambda": "8.10.159"
      }
    }
  2. Run tsc - you will see the duplicate identifier error.

Proposed Solution

Change the global declaration from var to namespace to allow TypeScript declaration merging (as proposed in PR #18).

Current Workaround

Set skipLibCheck: true in tsconfig.json.

Environment

  • @aws/lambda-invoke-store: 0.2.1
  • @types/aws-lambda: 8.10.159
  • TypeScript: 5.9.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions