react.dev
react.dev copied to clipboard
refactor: remove debug console logs and improve TypeScript type safety
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 :
- Cleaner Build Output: The console logs in compileMDX.ts were debug statements that cluttered the build process without providing value to end users
- 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
- 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
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! 🙌