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

如何将react-scripts的三斜杠引用替换为import语法?

解决create-react-app中react-app-env.d.ts的三斜杠引用ESLint错误

直接按下面的步骤修改即可:

  • 打开项目根目录下的react-app-env.d.ts文件
  • 删除原有代码:/// <reference types="react-scripts" />
  • 替换成这行代码:import 'react-scripts';
  • 保存文件后,ESLint的@typescript-eslint/triple-slash-reference错误就会消失

这个import语句和原来的三斜杠引用作用完全一致,都是让TypeScript加载react-scripts的类型定义,但写法更符合ESLint的规则要求。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 04:50:22