Skip to content

build: bun run build fails on @cap/sdk-recorder DTS — package is outside the typecheck graph #2915

Open

Description

@Addin

Symptom

bun run build exits 1 on @cap/sdk-recorder:

@cap/sdk-recorder:build: src/index.ts(88,38): error TS2345: Argument of type 'EventHandler<K>' is not assignable to parameter of type 'EventHandler<keyof RecorderEventMap>'.
@cap/sdk-recorder:build:   Type 'keyof RecorderEventMap' is not assignable to type 'K'.
@cap/sdk-recorder:build:     'keyof RecorderEventMap' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'keyof RecorderEventMap'.
@cap/sdk-recorder:build: Error: error occurred in dts build
@cap/sdk-recorder:build: error: script "build" exited with code 1

Reproduces standalone with bun run --cwd packages/sdk-recorder build (exit 1). It is pre-existing: it reproduces with the Bun 1.4.4 branch changes stashed at c3f0a92.

Root cause

packages/sdk-recorder/src/index.ts:48

private listeners = new Map<string, Set<EventHandler<keyof RecorderEventMap>>>();

on<K extends keyof RecorderEventMap>(event: K, handler: EventHandler<K>) erases the key type with an explicit cast on add (line 86) but not on delete (line 88):

if (set) set.add(handler as EventHandler<keyof RecorderEventMap>);
return () => {
	this.listeners.get(event)?.delete(handler);
};

Why CI does not catch it

  • packages/sdk-recorder is not in the root tsconfig.json references (ui, recorder-core, ui-solid, utils, desktop, chrome-extension, web), so bun run typecheck never checks this package.
  • No workflow runs bun run build (grep "bun run build" .github/workflows/*.yml returns nothing).

Both the TypeScript 5.9.3 checker used by tsup's DTS build and Bun's TypeScript 7.1-dev checker (bun check -p packages/sdk-recorder) report the same error, so this is not a checker-version artifact.

Proposed fix

Cast at delete as already done at add:

this.listeners.get(event)?.delete(handler as EventHandler<keyof RecorderEventMap>);

Beyond the one-line fix, add the package to the root tsconfig.json references so bun run typecheck covers it. A CI job that runs bun run build (or at least turbo run build --filter=@cap/sdk-recorder) would keep this from regressing.

Note: the SIGSEGV/SIGBUS seen when running the full build is unrelated and environmental — it reproduces under Node 26 as well, and the build is stable at --concurrency=2.

Activity

  1. linear commented on Oct 22, 2026

    @linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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