问题
An empty interface declaration allows any non-nullish value, including literals like0
and""
.
- If that’s what you want, disable this lint rule with an inline comment or configure the ‘allowInterfaces’ rule option.
- If you want a type meaning “any object”, you probably want
object
instead.- If you want a type meaning “any value”, you probably want
unknown
instead.eslint@typescript-eslint/no-empty-object-type
新增 规则
...compat.config({rules: {"@typescript-eslint/no-empty-object-type": "off",},}),
or
...compat.config({rules: {allowInterfaces: 'with-single-extends'},}),
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"),...compat.config({rules: {// "@typescript-eslint/no-empty-object-type": "off",allowInterfaces: "with-single-extends",},}),
];export default eslintConfig;