swarooppatilx / scruter

Scruter is a local classifieds and community site designed to bring people together for buying, selling, and exchanging goods and services.
https://scruter.vercel.app
GNU General Public License v3.0
28 stars 135 forks source link

Build Issues Due to Next.js Latest Syntax and TypeScript Rules #508

Closed ShivanshPlays closed 2 weeks ago

ShivanshPlays commented 2 weeks ago

Build Issues Due to Next.js Latest Syntax and TypeScript Rules

Description

This issue has been created to address various build issues arising from the non-compliance with the latest Next.js syntax and TypeScript rules in the codebase. These issues are preventing a successful deployment and need to be resolved to ensure smooth builds moving forward.

Issues Identified

  1. TypeScript Implicit 'any' Type Errors:

    • In several places, the any type is implicitly used without proper type declarations. This violates the stricter TypeScript settings and leads to build errors.
    • Example:
      const contributorsResponse = await axios.get('https://api.github.com/repos/...');
      const contributorsData: Contributor[] = contributorsResponse.filter(contributor => contributor.login !== 'dependabot[bot]');
    • Fix: Ensure all variables and parameters are properly typed to avoid implicit any usage.
  2. Next.js Image Component Invalid src prop Error:

    • The next/image component is unable to handle external image sources like avatars.githubusercontent.com because the hostname is not configured in next.config.js.
    • Fix: Add the required domains to the images configuration in next.config.js:
      module.exports = {
      images: {
       domains: ['avatars.githubusercontent.com'],
      },
      };
  3. Deprecated or Invalid Next.js Syntax:

    • Some parts of the codebase are using outdated or deprecated Next.js syntax that is no longer compatible with the latest version.
    • Fix: Update the codebase to follow the latest Next.js features and syntax (e.g., React Server Components, Image Optimization, etc.).
  4. Missing Type Declarations for API Responses:

    • API response data is being used without proper TypeScript interfaces or type assertions, leading to potential runtime errors.
    • Fix: Add appropriate types for API responses to ensure safe and predictable data handling.
  5. Improper or Inconsistent Use of async and await:

    • Some asynchronous operations are not handled properly, leading to unhandled promise rejections or incorrect flow.
    • Fix: Ensure that all asynchronous functions use async/await correctly and handle errors gracefully.
  6. Other TypeScript Configuration Issues:

    • There might be additional TypeScript configuration issues, such as missing or incorrect tsconfig.json settings that need to be fixed for proper type checking and compilation.

Steps to Resolve

  1. Update the Codebase:

    • Review and update the code to comply with the latest Next.js and TypeScript standards.
    • Ensure all variables and function parameters are correctly typed.
    • Refactor any deprecated or incorrect syntax.
  2. Check Next.js Configuration:

    • Review next.config.js and ensure all external resources (e.g., image domains) are properly configured.
    • Update the Next.js configuration to follow the latest best practices.
  3. Test Locally:

    • Run the application locally after making the fixes to ensure the issues are resolved and the build is successful.
  4. Submit Pull Requests:

    • After resolving the issues, create pull requests to address the identified problems.
    • Ensure all changes are well-documented and include explanations for the fixes.

Expected Outcome

Additional Notes


Labels: bug, build, TypeScript, Next.js, deployment