react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

refactor: remove debug console logs and improve TypeScript type safety

Open ShubhamPatra opened this issue 1 month ago • 1 comments

This PR improves code quality by removing unnecessary debug logging and enhancing TypeScript type safety in the codebase.

Changes

  • Remove build-time console.log statements from compileMDX.ts that were logging cache hits/misses
  • Improve TypeScript types in usePendingRoute.ts by replacing any with NodeJS.Timeout | undefined
  • Add conditional guards before clearTimeout calls to prevent passing undefined values
  • Bump DISK_CACHE_BREAKER from 11 to 12 after modifying compileMDX.ts

This results in :

  1. Cleaner Build Output: The console logs in compileMDX.ts were debug statements that cluttered the build process without providing value to end users
  2. Better Type Safety: Replacing any with explicit types improves code maintainability and catches potential errors at compile time, aligning with the project's strict TypeScript configuration
  3. Cross-Environment Compatibility: Added proper type guards to handle NodeJS.Timeout type correctly in both server and client environments

Files Changed

  • src/utils/compileMDX.ts - Removed 2 console.log statements, bumped cache breaker
  • src/hooks/usePendingRoute.ts - Improved timer type definition and added null checks

ShubhamPatra avatar Nov 27 '25 17:11 ShubhamPatra

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

github-actions[bot] avatar Nov 27 '25 17:11 github-actions[bot]