RocketChat / RocketChat/Rocket.Chat

Fix: remove unnecessary type assertions in http-router Router.ts

Open Beginner friendly
#39,228 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

While running yarn lint on the codebase, found unnecessary type assertions
in packages/http-router/src/Router.ts flagged by the
@typescript-eslint/no-unnecessary-type-assertion rule, and an unused import.

These assertions do not change the type of the expression and can be safely removed.

Steps to reproduce:
  1. Clone the repository
  2. Run yarn lint --filter=@rocket.chat/http-router
  3. Observe warnings on Router.ts
Expected behavior:

No unnecessary type assertion warnings or unused import errors in Router.ts

Actual behavior:
  • Line 310: as string assertion is unnecessary (TypeScript already infers string from the fallback)
  • Line 317: as 101 | 204 | 205 | 304 is unnecessary (already narrowed by the isContentLess type guard)
  • Line 325: as StatusCode is unnecessary
  • Line 7: StatusCode is imported but never used after removing the assertion
Server Setup Information:
  • Version of Rocket.Chat Server:
  • License Type:
  • Number of Users:
  • Operating System:
  • Deployment Method:
  • Number of Running Instances:
  • DB Replicaset Oplog:
  • NodeJS Version:
  • MongoDB Version:
Client Setup Information
  • Desktop App or Browser Version:
  • Operating System:
Additional context
Relevant logs:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running yarn lint --filter=@rocket.chat/http-router and open packages/http-router/src/Router.ts. Inspect the assertions at lines 310, 317, and 325 and the unused StatusCode import at line 7. Done means the assertions and unused import are resolved and the filtered lint command reports no warnings or errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.