Skip to content

Typescript Error #410

@wisefool769

Description

@wisefool769

Summary

The @coinbase/cdp-sdk package contains a TypeScript compilation error in auth/utils/http.ts that prevents projects from building when TypeScript strict mode is enabled.

Error Details

  node_modules/@coinbase/cdp-sdk/auth/utils/http.ts(148,5): error TS7053: Element implicitly has an 'any' type because expression of type '"source_version"' can't be used to index type '{ sdk_version: string; 
  sdk_language: string; source: string; }'.
    Property 'source_version' does not exist on type '{ sdk_version: string; sdk_language: string; source: string; }'.

  node_modules/@coinbase/cdp-sdk/auth/utils/http.ts(151,46): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ sdk_version: string; 
  sdk_language: string; source: string; }'.
    No index signature with a parameter of type 'string' was found on type '{ sdk_version: string; sdk_language: string; source: string; }'.

Root Cause

In auth/utils/http.ts at line 141, the getCorrelationData function creates a data object with an implicit type that doesn't allow dynamic property assignment:

  export function getCorrelationData(source?: string, sourceVersion?: string): string {
    const data = {  // <- Implicitly typed as { sdk_version: string; sdk_language: string; source: string; }
      sdk_version: version,
      sdk_language: "typescript",
      source: source || "sdk-auth",
    };
    if (sourceVersion) {
      data["source_version"] = sourceVersion;  // <- TS Error: Property doesn't exist on type
    }
    return Object.keys(data)
      .map(key => `${key}=${encodeURIComponent(data[key])}`)  // <- TS Error: No index signature
      .join(",");
  }

Proposed Fix

Add an explicit type annotation to allow dynamic property assignment:

  const data: Record<string, string> = {
    sdk_version: version,
    sdk_language: "typescript",
    source: source || "sdk-auth",
  };

Environment

  • SDK Version: 1.35.0 (also affects earlier versions)
  • TypeScript Version: 5.9.2
  • Node.js Version: 22.x

Reproduction

I've created a minimal reproduction case that demonstrates this issue:

  1. Create a new TypeScript project
  2. Install @coinbase/cdp-sdk and typescript
  3. Import and use any function from the SDK
  4. Run tsc - the compilation will fail with the above error

The error occurs during TypeScript's static analysis phase, regardless of whether the problematic code path is actually executed.

Workaround

Currently, the only workarounds are:

  • Set skipLibCheck: true in tsconfig.json (not always effective with Next.js and other frameworks)
  • Use // @ts-ignore or // @ts-expect-error comments (requires patching node_modules)
  • Set TypeScript to non-strict mode (reduces type safety)

None of these are ideal solutions as they reduce type safety or require workarounds that may break with SDK updates.

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