Skip to content

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

Merged
dionisio-bot[bot] merged 1 commit into
developfrom
chore/ts7-meteor-resolution
Jul 21, 2026
Merged

fix(meteor): meteor/* type resolution under TS7 (drop packages.d.ts fallback)#41489
dionisio-bot[bot] merged 1 commit into
developfrom
chore/ts7-meteor-resolution

Conversation

@ggazzo

@ggazzo ggazzo commented Jul 20, 2026

Copy link
Copy Markdown
Member

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).

Review in cubic

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.

@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 60d06da

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The PR adds Meteor module declarations for npm-mongo and webapp, updates Meteor TypeScript path resolution, and casts WebApp.connectHandlers to express.Application when wiring the SAML listener.

Changes

Meteor typing compatibility

Layer / File(s) Summary
Meteor module declarations and resolution
apps/meteor/definition/externals/meteor/npm-mongo.d.ts, apps/meteor/definition/externals/meteor/webapp.d.ts, apps/meteor/tsconfig.json
Adds the meteor/npm-mongo re-export, declares WebApp.rawHandlers, and removes the local generated-types fallback from the meteor/* path mapping.
SAML listener application typing
apps/meteor/server/lib/saml/listener.ts
Casts WebApp.connectHandlers to express.Application before calling .use(...), while preserving the existing SAML middleware chain.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested labels: type: bug, area: authentication

Suggested reviewers: sampaiodiego, ricardogarim

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing meteor/* type resolution under TS7 by removing the packages.d.ts fallback.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • ARCH-2283: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dionisio-bot

dionisio-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@ggazzo ggazzo added this to the 8.7.0 milestone Jul 20, 2026
@ggazzo

ggazzo commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

/jira ARCH-2200

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.60%. Comparing base (ea70952) to head (60d06da).
⚠️ Report is 6 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41489      +/-   ##
===========================================
- Coverage    68.62%   68.60%   -0.03%     
===========================================
  Files         4134     4134              
  Lines       160802   160802              
  Branches     29247    29263      +16     
===========================================
- Hits        110347   110314      -33     
- Misses       45343    45391      +48     
+ Partials      5112     5097      -15     
Flag Coverage Δ
e2e 58.88% <ø> (-0.02%) ⬇️
e2e-api 45.35% <100.00%> (-0.27%) ⬇️
unit 70.55% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…mpat)

The generated .meteor/local/types/packages.d.ts declares each meteor module
with 'import exports = require(...); export = exports'. Under TypeScript 7,
once that file enters the program (via the paths fallback), its 'export ='
declarations take over the module identity and discard the ambient merges
from @types/meteor and our own definition/externals augmentations — dropping
Accounts._bcryptRounds, DDPRateLimiter internals, etc. (~60 errors).

Everything packages.d.ts declared is already covered by @types/meteor plus
definition/externals, except:

- meteor/npm-mongo: add a shim re-exporting the mongodb driver as
  NpmModuleMongodb (matches the real package)
- WebApp.rawHandlers: present in Meteor 3's generated types but missing from
  @types/meteor; add it to definition/externals

Verified on both compilers: TS5 resolves all three symbol classes (0 errors);
the TS7 probe drops from 230 to 172 (remaining: Endpoints drift + small tail).
@ggazzo
ggazzo force-pushed the chore/ts7-meteor-resolution branch from b51141f to 60d06da Compare July 20, 2026 21:36
@ggazzo
ggazzo marked this pull request as ready for review July 21, 2026 13:05
@ggazzo
ggazzo requested a review from a team as a code owner July 21, 2026 13:05

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/meteor/server/lib/saml/listener.ts`:
- Around line 80-81: Remove the explanatory inline comment near the
connectHandlers usage in the SAML listener implementation, leaving the
surrounding code unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 27bac53e-82ca-478f-a924-6ef9daa143d5

📥 Commits

Reviewing files that changed from the base of the PR and between 4a4c297 and 60d06da.

📒 Files selected for processing (4)
  • apps/meteor/definition/externals/meteor/npm-mongo.d.ts
  • apps/meteor/definition/externals/meteor/webapp.d.ts
  • apps/meteor/server/lib/saml/listener.ts
  • apps/meteor/tsconfig.json
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/definition/externals/meteor/webapp.d.ts
  • apps/meteor/definition/externals/meteor/npm-mongo.d.ts
  • apps/meteor/server/lib/saml/listener.ts
🧠 Learnings (3)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/definition/externals/meteor/webapp.d.ts
  • apps/meteor/definition/externals/meteor/npm-mongo.d.ts
  • apps/meteor/server/lib/saml/listener.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/definition/externals/meteor/webapp.d.ts
  • apps/meteor/definition/externals/meteor/npm-mongo.d.ts
  • apps/meteor/server/lib/saml/listener.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/definition/externals/meteor/webapp.d.ts
  • apps/meteor/definition/externals/meteor/npm-mongo.d.ts
  • apps/meteor/server/lib/saml/listener.ts
🔇 Additional comments (4)
apps/meteor/definition/externals/meteor/npm-mongo.d.ts (1)

1-4: LGTM!

apps/meteor/definition/externals/meteor/webapp.d.ts (1)

1-8: LGTM!

apps/meteor/tsconfig.json (1)

25-29: 🎯 Functional Correctness

Verify that removing the fallback leaves all Meteor modules resolvable.

This mapping now makes @types/meteor the only path target for every meteor/* import, while the supplied changes add declarations for only npm-mongo and webapp. Run the full Meteor typecheck and verify modules previously provided only by .meteor/local/types/packages.d.ts still resolve.

apps/meteor/server/lib/saml/listener.ts (1)

82-82: 🎯 Functional Correctness

Verify that the cast targets the intended Meteor 3 handler.

This call still uses WebApp.connectHandlers, while the new declaration types WebApp.rawHandlers; the unknown as cast bypasses compile-time validation. Confirm the alias and middleware-order semantics for the supported Meteor version before merging. Meteor’s current documentation exposes WebApp.handlers, and its migration guide identifies rawHandlers as the replacement for rawConnectHandlers. (docs.meteor.com)

Comment thread apps/meteor/server/lib/saml/listener.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Re-trigger cubic

@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Jul 21, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 21, 2026
@ggazzo ggazzo modified the milestones: 8.7.0, 8.8.0 Jul 21, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jul 21, 2026
Merged via the queue into develop with commit 2077b7e Jul 21, 2026
56 checks passed
@dionisio-bot
dionisio-bot Bot deleted the chore/ts7-meteor-resolution branch July 21, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: authentication stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants