-
Notifications
You must be signed in to change notification settings - Fork 108
Closed
Description
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:
- Create a new TypeScript project
- Install @coinbase/cdp-sdk and typescript
- Import and use any function from the SDK
- 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.
jacksondoherty, Geeknerd1337 and chad-schwab
Metadata
Metadata
Assignees
Labels
No labels