-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
Description
While building Rocket.Chat locally from source, the build fails in the @rocket.chat/http-router package due to a TypeScript type incompatibility when dynamically accessing Hono router methods using method.toLowerCase().
The issue originates from TypeScript’s stricter type inference (TS 5.x) combined with Hono’s strongly typed router interface, which no longer allows dynamic string indexing without an explicit and safe narrowing.
This results in a TypeScript compile-time error that blocks yarn build, even though the runtime behavior is valid.
The issue is reproducible on a clean clone, and once a small type-safe adjustment is applied, the entire project builds successfully.
Steps to reproduce
- Clone Rocket.Chat repository
git clone https://github.com/RocketChat/Rocket.Chat.git
cd Rocket.Chat
- Checkout a recent branch (tested on develop)
git checkout develop
- Use the required Node.js version
nvm install 22.16.0
nvm use 22.16.0
- Install dependencies
yarn install
- Run the build
yarn build
- Build fails at:
packages/http-router/src/Router.ts:197
Expected behavior
yarn build should complete successfully on a clean setup using the officially required Node.js version.
TypeScript should accept valid dynamic routing logic when using Method enums with Hono.
Actual behavior
TypeScript compilation fails with an error similar to:
` error TS2345: Argument of type 'string' is not assignable to parameter of type 'H<...>'`
The error originates from dynamically accessing the Hono router method:
` this.innerRouter[method.toLowerCase()]`
This prevents the build from completing.
Server Setup Information
- Version of Rocket.Chat Server: develop (local build)
- License Type: N/A (local development)
- Number of Users: N/A
- Operating System: Ubuntu (WSL2 on Windows)
- Deployment Method: Source build
- Number of Running Instances: 1
- DB Replicaset Oplog: N/A
- NodeJS Version: v22.16.0
- MongoDB Version: N/A (build-time issue)
Server Setup Information
- Version of Rocket.Chat Server: develop (local build)
- License Type: N/A (local development)
- Number of Users: N/A
- Operating System: Ubuntu (WSL2 on Windows)
- Deployment Method: Source build
- Number of Running Instances: 1
- DB Replicaset Oplog: N/A
- NodeJS Version: v22.16.0
- MongoDB Version: N/A (build-time issue)
Additional context
This issue is not related to Sharp, Deno, or MongoDB
It is a pure TypeScript + Hono typing regression
Likely surfaced due to:
Node 22 adoption
TypeScript 5.x stricter index access rules
A small refactor can permanently fix this across all environments
I am happy to open a PR with the validated fix if this approach is acceptable.
Heart of the problem:
A TypeScript type mismatch in packages/http-router/src/Router.ts prevents dynamic access to Hono router methods (this.innerRouter[method.toLowerCase()]), breaking local builds despite correct runtime behavior.
Why it’s important to solve:
This blocks contributors from building Rocket.Chat locally and introduces unnecessary friction in development, onboarding, and CI reliability for a core routing layer.
Relevant logs
<details> <summary>TypeScript build error</summary>
packages/http-router/src/Router.ts:197:63
error TS2345: Argument of type 'string' is not assignable to parameter of type 'H<...>'