Skip to content

bun-types@1.3.12: duplicate computed keys in bun:ffi break tsgo / TypeScript native preview #29191

@BleedingDev

Description

@BleedingDev

Summary

bun-types@1.3.12 fails under tsgo / TypeScript native preview because bun:ffi declares duplicate computed keys in FFITypeToArgsType and FFITypeToReturnsType.

The problem reproduces with a clean minimal project outside our repo.

Versions

  • bun-types: 1.3.12
  • typescript: 6.0.2
  • @typescript/native-preview: 7.0.0-dev.20260326.1
  • @effect/tsgo: 0.2.1

Minimal repro

package.json

{
  "private": true,
  "type": "module",
  "devDependencies": {
    "@effect/tsgo": "0.2.1",
    "@typescript/native-preview": "7.0.0-dev.20260326.1",
    "bun-types": "1.3.12",
    "typescript": "6.0.2"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "noEmit": true,
    "strict": true,
    "types": ["bun-types"]
  },
  "include": ["index.ts"]
}

index.ts

export {};

Commands:

pnpm install
pnpm exec tsgo --noEmit -p tsconfig.json

Actual result

The compile fails with duplicate identifier errors from bun-types/ffi.d.ts, for example:

node_modules/.pnpm/bun-types@1.3.12/node_modules/bun-types/ffi.d.ts(347,5): error TS2300: Duplicate identifier '[FFIType.int8_t]'.
node_modules/.pnpm/bun-types@1.3.12/node_modules/bun-types/ffi.d.ts(349,5): error TS2300: Duplicate identifier '[FFIType.uint8_t]'.
node_modules/.pnpm/bun-types@1.3.12/node_modules/bun-types/ffi.d.ts(355,5): error TS2300: Duplicate identifier '[FFIType.int32_t]'.
node_modules/.pnpm/bun-types@1.3.12/node_modules/bun-types/ffi.d.ts(364,5): error TS2300: Duplicate identifier '[FFIType.double]'.
node_modules/.pnpm/bun-types@1.3.12/node_modules/bun-types/ffi.d.ts(369,5): error TS2300: Duplicate identifier '[FFIType.ptr]'.

Why this seems wrong

The published declarations include both canonical enum members and legacy aliases as separate computed keys:

[FFIType.int8_t]: number;
[FFIType.i8]: number;
...
[FFIType.ptr]: Pointer | null;
[FFIType.pointer]: Pointer | null;

When those enum values collapse to the same computed property key, tsgo reports them as duplicates.

The same pattern exists in both:

  • FFITypeToArgsType
  • FFITypeToReturnsType

Relevant published declarations

From the published tarball for bun-types@1.3.12:

  • ffi.d.ts contains the duplicate alias pairs
  • wasm.d.ts also contains:
interface ModuleExportDescriptor extends Bun.WebAssembly.ModuleExportDescriptor {}
interface ModuleImportDescriptor extends Bun.WebAssembly.ModuleImportDescriptor {}

We locally patched both areas, but the ffi.d.ts duplicate keys are the directly reproducible failure above.

Expected result

bun-types should typecheck cleanly under the current TypeScript native preview / tsgo toolchain without requiring a local patch that removes the alias duplicates.

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