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

Next.js 14中TypeScript无法识别全局类型的问题求助

Next.js 14 + TypeScript 在WSL2环境下VSCode无法识别标准全局类型(无运行时错误)

我的Next.js 14应用运行完全正常,但VSCode编辑器中几乎所有文件都出现类型报错,提示无法找到TypeScript的标准全局类型,比如Boolean、Array等。使用环境为WSL2,仅存在编辑器层面的报错,无任何运行时异常。

当前tsconfig.json配置如下:

{
  "compilerOptions": {
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

具体报错内容:

  • Cannot find global type 'Boolean'.ts
  • Cannot find global type 'CallableFunction'.ts
  • Cannot find global type 'IArguments'.ts
  • Cannot find global type 'NewableFunction'.ts
  • Cannot find global type 'Number'.ts
  • Cannot find global type 'Object'.ts

已尝试的解决方法均无效:

  • 重装TypeScript模块
  • 新建Next.js项目测试(新项目同样出现该问题)
  • 清理pnpm缓存

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 19:41:12