Skip to content

[0.3] fix(types): unblock websocket.test.ts type errors - #206

Merged
h4yfans merged 2 commits into
mainfrom
debt/0.3-websocket-types
Apr 15, 2026
Merged

[0.3] fix(types): unblock websocket.test.ts type errors#206
h4yfans merged 2 commits into
mainfrom
debt/0.3-websocket-types

Conversation

@h4yfans

@h4yfans h4yfans commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a TypeScript type assertion to the require('events') call inside vi.hoisted() in apps/desktop/src/main/sync/websocket.test.ts so the returned module namespace is typed correctly without enabling esModuleInterop project-wide.

The CJS require('events') returned any, which flowed through the destructured EventEmitter and into class MockWS extends EE, cascading into ~45 downstream type errors in that file when checked against tests/tsconfig.json.

Fix applied

// before
const { EventEmitter: EE } = require('events')

// after
const { EventEmitter: EE } = require('events') as typeof import('events')

This was option (b) from the task spec — cast the require result to the proper ES module namespace type. No tsconfig changes needed; avoids the broader blast radius of turning on esModuleInterop / allowSyntheticDefaultImports.

Before / after

  • Before (baseline on main): ~45 type errors in apps/desktop/src/main/sync/websocket.test.ts when typechecked via tests/tsconfig.json.
  • After (this branch): 0 type errors in websocket.test.ts. Confirmed via pnpm exec tsc --noEmit -p tests/tsconfig.json — remaining errors are in unrelated test files (calendar, inbox, ipc handlers) and outside this unit's scope.
  • pnpm --filter @memry/desktop typecheck:node — passes cleanly (test files already excluded by production tsconfig; no regressions).
  • pnpm --filter @memry/desktop exec vitest run src/main/sync/websocket.test.ts28/28 tests pass.

Test plan

  • websocket.test.ts typechecks clean via tests/tsconfig.json
  • websocket.test.ts runtime — all 28 tests pass
  • typecheck:node still green (test files excluded there)
  • CI lint / typecheck / test pipeline green

@h4yfans
h4yfans merged commit 3e3bbbb into main Apr 15, 2026
2 checks passed
@h4yfans
h4yfans deleted the debt/0.3-websocket-types branch April 15, 2026 20:18
h4yfans added a commit that referenced this pull request May 6, 2026
[0.3] fix(types): unblock websocket.test.ts type errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant