🔴 CRITICAL: Widespread use of 'any' type bypassing TypeScript safety
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #1268 by @Harshit2405-2004 — closed without merging
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Refactor
- Clarity
- Needs clarification
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- developer-experience
Research direction
Start by auditing the listed files, including packages/api/src/cloneArray.ts, packages/api/src/EmbeddedChatApi.ts, packages/auth/src/RocketChatAuth.ts, packages/auth/src/Api.ts, and packages/rc-app/lib/getCallbackContent.ts, then locate the remaining occurrences. Review the existing data shapes and package TypeScript settings before changing signatures. Done means the reported any usages are addressed, critical paths are typed, and the proposed strict checks can be enabled without unresolved type errors.
Written by the indexing model from the issue text.
Description
🔴 CRITICAL Type Safety Issue
Severity: CRITICAL
Type: TypeScript Type Safety / Code Quality
Impact: Runtime Errors / Broken Refactoring
📍 Scope
30+ occurrences of any type across the codebase, bypassing TypeScript's type safety.
Affected Files (sample):
packages/api/src/cloneArray.ts:1packages/api/src/EmbeddedChatApi.ts:16-20packages/auth/src/RocketChatAuth.ts:11packages/auth/src/Api.ts:7, 33-34packages/rc-app/lib/getCallbackContent.ts:1- And 25+ more files
🔥 Problem Description
Extensive use of any type eliminates TypeScript's core benefits:
- No compile-time type checking
- No IDE autocomplete
- No refactoring safety
- Runtime errors in production
Examples:
// Example 1: cloneArray - No type safety
const cloneArray = (array: any[]): any[] => [...array];
// Example 2: EmbeddedChatApi constructor - Callbacks not typed
constructor(
host: string,
rid: string,
{ getAuth, setAuth }: any, // No type checking
) {}
// Example 3: Message callbacks - Structure unknown
onMessage(callback: (message: any) => void) {
// Caller has no idea what message contains
}
// Example 4: RocketChatAuth - User shape unknown
currentUser: any = null;
💥 Impact
- No IDE autocomplete - Developers don't know available properties
- Runtime errors - Type mismatches caught only in production
- Broken refactoring - Renaming fields doesn't update all usages
- Impossible to trace data flow - No way to understand message structure
Example Runtime Error:
onMessage((message: any) => {
console.log(message.user.name); // Runtime error if user is undefined
});
✅ Recommended Fix
Define proper interfaces and use generic types:
// Define message interface
interface MessageData {
_id: string;
rid: string;
msg: string;
ts: Date;
u: {
_id: string;
username: string;
name?: string;
};
attachments?: Attachment[];
[key: string]: unknown; // Allow additional fields
}
// Fix cloneArray with generics
const cloneArray = <T extends Record<string, unknown>>(array: T[]): T[] => {
return [...array];
};
// Fix auth callbacks
interface AuthCallbacks {
getAuth: () => AuthToken | null;
setAuth: (token: AuthToken) => void;
}
constructor(
host: string,
rid: string,
callbacks: AuthCallbacks,
) {}
// Fix message callback
onMessage(callback: (message: MessageData) => void) {
// Now type-safe
}
// Fix currentUser
interface UserData {
_id: string;
username: string;
name?: string;
roles: string[];
// ... other fields
}
currentUser: UserData | null = null;
🎯 Action Items
- Define core interfaces (MessageData, UserData, AuthToken, etc.)
- Replace
anyin critical paths (EmbeddedChatApi, RocketChatAuth) - Update function signatures with proper types
- Add generic constraints where appropriate
- Enable strict TypeScript checks
- Audit remaining
anyusage
📝 Implementation Strategy
Phase 1 (Week 1): Type critical paths
- EmbeddedChatApi methods
- RocketChatAuth core methods
- Message handling callbacks
Phase 2 (Week 2): Type remaining packages
- Auth package
- RC-app package
- API utilities
Phase 3 (Ongoing): Enable strict mode
noImplicitAny: truestrictNullChecks: true
⏱️ Timeline
Start: Immediately
Complete Critical Paths: 1 week
Full Resolution: 2-3 weeks
Priority: P0 - Critical Code Quality
Discovered by: Automated codebase security analysis
Date: April 5, 2026
- Dominant language
- JavaScript
- Stars
- 171
- Forks
- 421
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RocketChat/EmbeddedChat
-
Bug: username fallback in updateUserUsername never runs since the ddp-client migrationPossibly taken @MuhammadFaizan-prog claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
RocketChat/EmbeddedChat#1489 ·
Maintainers usually reply within 1 day
-
[Bug]: Low contrast on color swatch borders in Theme Lab (Layout Editor)Possibly taken @yashsarvaiya45 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
RocketChat/EmbeddedChat#1486 ·
Maintainers usually reply within 1 day
-
bug(api): _doConnect swallows connection/auth errors and marks failed sessions as authenticatedPossibly taken @ashwanisingh011 claimed this 1 day ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
RocketChat/EmbeddedChat#1484 ·
Maintainers usually reply within 1 day
-
Bug: White screen crash (`Cannot read properties of undefined (reading 'members')`) when rendering UserMention outside MarkupInteractionContextPossibly taken @swarnendusahu10-dotcom claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
RocketChat/EmbeddedChat#1482 ·
Maintainers usually reply within 1 day
-
Bug: UIKit PreviewBlock cover image tiles repeatedly and stretches across viewport when zoomed outPossibly taken @swarnendusahu10-dotcom claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
RocketChat/EmbeddedChat#1480 · 1 comment ·
Maintainers usually reply within 1 day
All issues in RocketChat/EmbeddedChat
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
[Docs] CONTRIBUTING.md links to retired GitHub Learning Lab and Try Git sitesPossibly taken @adityamukesh claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
reillywalter/win-dev-doctor#92 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100