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

Vite-plugin-checker开发运行时无法识别TypeScript错误的问题咨询

Vite-plugin-checker开发阶段不检测TS错误的解决方案

可能的原因及修复步骤

1. 版本兼容性冲突

vite-plugin-checker@0.5.6属于旧版本,对TypeScript 5.x的支持存在问题。两种解决方向:

  • 升级vite-plugin-checker到最新稳定版(如^0.6.0及以上),同时同步升级vue-tsc到匹配版本(例如vue-tsc@1.8.x+适配TS5.x)
  • 降级TypeScript到4.9.x版本,与vite-plugin-checker@0.5.6保持兼容

2. 插件配置不完整

旧版插件可能需要显式声明开发模式下启用检查,或指定TS配置文件路径。修改vite.config.ts的插件配置:

import checker from 'vite-plugin-checker'

export default defineConfig({
  plugins: [
    vue(),
    checker({
      typescript: {
        enabled: true,
        tsconfigPath: './tsconfig.json' // 指定你的tsconfig路径
      },
      vueTsc: {
        enabled: true
      },
      dev: {
        enable: true // 强制开启开发模式检查
      }
    })
  ]
})

3. TypeScript配置规则过松

检查tsconfig.json中的严格检查选项是否开启:

  • 确保strict设置为true
  • 确认include字段包含你的源码目录(如"include": ["src/**/*"])
  • 必要时开启具体检查规则,比如noImplicitAny、strictNullChecks等

4. 缓存干扰

删除Vite缓存目录node_modules/.vite,然后重启开发服务器,避免缓存导致检查逻辑失效

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.24 10:27:39