Skip to content

@safe-global/types-kit globally pollutes abitype AddressType to string #1323

@jaan1025

Description

@jaan1025

Problem

@safe-global/types-kit exports a global declare module 'abitype' that overrides AddressType to string:

https://github.com/safe-global/safe-core-sdk/blob/main/packages/types-kit/src/index.ts#L15-L24

declare module 'abitype' {
  export interface Register {
    AddressType: string
  }
}

This is a global ambient declaration — any project that depends on @safe-global/types-kit (even transitively via api-kit or protocol-kit) has its abitype Address type silently widened from `0x${string}` to string.

Impact

  • All viem/wagmi types are affected. useAccount().address becomes string | undefined instead of `0x${string}` | undefined, breaking type-safety for any project that uses both wagmi and Safe SDK.
  • The consumer has no way to opt out short of adding their own counter-declaration in every TypeScript compilation unit:
    declare module 'abitype' {
      interface Register {
        AddressType: `0x${string}`;
      }
    }
  • This affects any monorepo or app that pulls in @safe-global/api-kit or @safe-global/protocol-kit as a dependency, even if the Safe SDK is only used in a small part of the codebase.

Suggestion

Move the declare module 'abitype' block out of the published package's type declarations. If Safe SDK needs AddressType: string internally (e.g. for ethers.js compatibility), it should be scoped to the SDK's own compilation — not exported to consumers.

Options:

  1. Move it to a tsconfig or internal .d.ts file that is not included in the published dist/
  2. Use type assertions (as string) at the Safe SDK boundary instead of globally overriding abitype's Register

Environment

  • @safe-global/types-kit: 3.0.0
  • abitype: 1.2.3
  • viem: 2.44.4
  • wagmi: 2.19.5
  • typescript: 5.9.3

Metadata

Metadata

Assignees

Labels

SEV-4bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions