Fix typescript error: Unexpected any and empty object issues

Fix typescript error: Unexpected any and empty object issues

Sandipan Das
Sandipan Das |
2 min read7 views
twitterfacebooklinkedinpinterestW

To fix the typescript error: Unexpected any and empty object issues

eslint.config.mjs

import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";


const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);


const compat = new FlatCompat({
  baseDirectory: __dirname,
});


const eslintConfig = [
  ...compat.extends("next/core-web-vitals", "next/typescript"),
  // = = = = = = = = = = = = = = = = = =
  // TO AVOID ERROR OF
  // Unexpected any. Specify a different type.eslint@typescript-eslint/no-explicit-any
  // AND
  // The {} ("empty object") type allows any non-nullish value, including literals like 0 and "".
  // = = = = = = = = = = = = = = = = = =
  {
    rules: {
      // Turn off `no-explicit-any`
      "@typescript-eslint/no-explicit-any": "off",


      // Allow `{}` as a valid type
      "@typescript-eslint/ban-types": [
        "error",
        {
          "types": {
            "{}": false,
          },
        },
      ],
    },
    parserOptions: {
      project: "./tsconfig.json",
      tsconfigRootDir: __dirname,
    },
  },
  // = = = = = = = = = = = = = = = = = =
  // ERROR FIXED
  // = = = = = = = = = = = = = = = = = =
];


export default eslintConfig;


twitterfacebooklinkedinpinterestW

Join & Grow

Be Part of a Winning Community!
Let’s Connect, learn, and succeed with like-minded people. Follow now!

Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image

+100s of Happy Clients!

Thanks for checking out my portfolio!

I really enjoy programming—it's not just my job, it's something I love. I've finished lots of web projects using different tools, and I'm excited to share what I know with everyone and help out.

I know my way around ReactJS, NextJS, MongoDB, WordPress, Laravel, CodeIgniter, and making things look good (UI/UX). I'm also a quick learner, always ready to learn and grow in my field.

If you've got any questions or need some help, feel free to get in touch anytime.

Best Regards,

SANDIPAN DASFull Stack Web Developer

Let‘s collaborate
on your next project

Chat on WhatsApp
Schedule a Zoom Meeting