fix: comment out debug console.logs and tighten TypeScript any types#5
fix: comment out debug console.logs and tighten TypeScript any types#5yassinsolim wants to merge 2 commits into
Conversation
- Comment out 4x console.log debug calls in Hitboxes.ts (non-test file)
- Mouse.ts: event: any -> event: MouseEvent & { inComputer?: boolean }
- EventBus.ts: dispatch data: any -> unknown
- CoffeeSteam.ts: model: any -> Record<string, unknown>
- Camera.ts: easing?: any -> easing?: (k: number) => number
- .gitignore: add .env and .env.local entries
Code quality audit finding.
There was a problem hiding this comment.
Pull request overview
This PR cleans up production debug output and tightens several TypeScript types to improve type safety, while also ensuring local environment files aren’t committed.
Changes:
- Commented out debug
console.logcalls in theHitboxesmousedown handler. - Narrowed several
anytypes to more specific typings (MouseEventintersection,unknown, easing function signature). - Updated
.gitignoreto exclude.envand.env.local.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Application/World/Hitboxes.ts | Comments out debug logging in the mousedown raycasting code path. |
| src/Application/World/CoffeeSteam.ts | Attempts to replace any for model with a safer type (currently introduces type breakage). |
| src/Application/Utils/Mouse.ts | Narrows the mousemove payload type to include inComputer on top of MouseEvent. |
| src/Application/UI/EventBus.ts | Changes dispatch payload type from any to unknown (also exposes an existing remove/unsubscribe bug). |
| src/Application/Camera/Camera.ts | Narrows easing to a tween-compatible (k: number) => number function. |
| .gitignore | Ignores .env and .env.local. |
Comments suppressed due to low confidence (3)
src/Application/Utils/Mouse.ts:24
if (event.clientX && event.clientY)will skip updates when the cursor is at x=0 or y=0 (valid values), leaving stale coordinates. Check for!= null/!== undefinedinstead of truthiness, or just assign fromevent.clientX/event.clientYunconditionally since this handler is only for mousemove events.
this.on('mousemove', (event: MouseEvent & { inComputer?: boolean }) => {
if (event.clientX && event.clientY) {
this.x = event.clientX;
this.y = event.clientY;
}
src/Application/UI/EventBus.ts:10
on()registers a wrapper listener(e) => callback(e.detail), butremove()attempts to unregistercallbackdirectly. This won't remove the actual event listener, leading to leaks and handlers firing after expected cleanup. Consider returning the wrapper function fromon()(so callers can pass it toremoveEventListener), or store a Map from callback -> wrapper and remove the wrapper.
dispatch(event: string, data: unknown) {
document.dispatchEvent(new CustomEvent(event, { detail: data }));
},
remove(event: string, callback: (...args: any[]) => any) {
document.removeEventListener(event, callback);
src/Application/World/Hitboxes.ts:44
- These lines add repeated TODOs while leaving commented-out
console.logstatements inline. If the goal is to remove debug output, it's cleaner to delete the logs entirely or gate them behind an existing debug flag/logger so they don't accumulate as commented code.
// TODO: replace with proper logger // console.log(this.camera.instance.position);
// TODO: replace with proper logger // console.log(this.mouse);
const ray = new THREE.Raycaster();
ray.setFromCamera(
{ x: this.mouse.x, y: this.mouse.y },
this.camera.instance
);
// TODO: replace with proper logger // console.log(ray);
const intersects = ray.intersectObjects(this.scene.children);
// TODO: replace with proper logger // console.log(intersects);
| model: Record<string, unknown>; | ||
| application: Application; |
There was a problem hiding this comment.
Changing model from any to Record<string, unknown> makes all of the subsequent this.model.color/material/mesh property accesses type-unsafe under strict TS (they become unknown), and will cause type errors (e.g., new THREE.Color(this.model.color) and this.model.material.uniforms...). Define an explicit interface/type for the model shape (color/material/mesh) or use a typed object literal so these properties are correctly typed.
|



Summary
Cleans up debug output and improves TypeScript type safety across the codebase.
Changes
event: any→event: MouseEvent & { inComputer?: boolean }dispatch data: any→unknownmodel: any→Record<string, unknown>easing?: any→easing?: (k: number) => numberValidation
Risks / Notes