You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Next.js部署Vercel遇@typescript-eslint/no-empty-object-type错误求助

解决Next.js部署Vercel时@typescript-eslint/no-empty-object-type错误

问题分析

你部署时遇到的错误提示是@typescript-eslint/no-empty-object-type,但你尝试禁用的是@typescript-eslint/no-empty-interface——这两个是不同的ESLint规则,这就是之前方法无效的核心原因。

你的InputProps接口继承了React.InputHTMLAttributes<HTMLInputElement>但未添加任何新属性,属于no-empty-object-type规则的检查范围,而非no-empty-interface。

解决方案

以下是三种可行的解决方式:

1. 修改ESLint配置,关闭正确规则

在你的ESLint配置文件(如.eslintrc.json或eslint.config.js)中添加:

{
  "rules": {
    "@typescript-eslint/no-empty-object-type": "off"
  }
}

2. 行内禁用对应规则

将文件顶部的注释替换为针对正确规则的禁用语句,或在接口上方添加行内注释:

// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}

也可以替换文件顶部的块注释:

/* eslint-disable @typescript-eslint/no-empty-object-type */
import * as React from "react"

// 剩余代码保持不变

3. 移除空接口,直接使用原生类型

既然InputProps没有扩展任何自定义属性,完全可以省略这个接口,直接在forwardRef中使用React.InputHTMLAttributes<HTMLInputElement>:

import * as React from "react"
import { cn } from "@/lib/utils"

const Input = React.forwardRef<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>(
  ({ className, type, ...props }, ref) => {
    return (
      <input
        type={type}
        className={cn(
          "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
          className
        )}
        ref={ref}
        {...props}
      />
    )
  }
)
Input.displayName = "Input"

export { Input }

内容的提问来源于stack exchange,提问作者Yan Zhang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 17:30:06