fix(meteor): meteor/* type resolution under TS7 (drop packages.d.ts fallback)

Merged
GG
3mo ago
+20-2

Summary

Fixes the meteor/* module-type resolution that broke under TypeScript 7 (~60 errors: Accounts._bcryptRounds, Accounts.LoginCancelledError, DDPRateLimiter._check, …).

Root cause

Those Meteor internals are typed by our own ambient augmentations in apps/meteor/definition/externals/meteor/*.d.ts, merging with @types/meteor. TS7 merges these fine — the problem is the generated .meteor/local/types/packages.d.ts, pulled in through the paths fallback. It declares every meteor module as:

declare module 'meteor/accounts-base' {
  import exports = require('package-types/…/accounts-base.d');
  export = exports;
}

Under TS7, once that file enters the program, the export = declaration takes over the module identity and the ambient merges are discarded — all our augmented internals vanish. TS5 resolved the ambient declarations in favor of the merge, which is why this never surfaced before. Verified by isolation: a probe with just the augmentation is green on TS7; adding packages.d.ts to the program makes the members disappear.

Fix

  • Remove the packages.d.ts fallback from paths — a coverage check of every meteor/* specifier the app imports showed everything it declared is already covered by @types/meteor + definition/externals, except:
  • meteor/npm-mongo → new shim re-exporting the mongodb driver as NpmModuleMongodb (matches the real package),
  • WebApp.rawHandlers → added to definition/externals (present in Meteor 3's generated types, missing from @types/meteor).

Verification

  • TS5 (current toolchain): probe covering all three symbol classes (Accounts._bcryptRounds, NpmModuleMongodb.GridFSBucket, WebApp.rawHandlers) — 0 errors, no regression.
  • TS7: full-app typecheck probe drops 230 → 172; the Accounts/DDPRateLimiter class goes to zero. The remainder is the Endpoints type-drift (tracked separately as W3) plus a small tail.

Part of the TS7-readiness set (W2).

Task: ARCH-2283

Summary by CodeRabbit

  • Bug Fixes
    • Improved TypeScript compatibility for Meteor integrations.
    • Corrected type support for MongoDB imports and web application request handlers.
    • Preserved SAML middleware routing while ensuring it works with updated Meteor typings.