描述bug
在升级到react-scripts v5时,运行react-scripts start
或react-scripts build
的任何.test.ts
或.spec.ts
文件中的类型错误会被报告给构建过程,导致构建失败。
你是否尝试恢复依赖项?
我启动了一个新项目来重现错误,但bug仍然存在
你在用户指南中搜索了哪些术语?
Typescript, types, tests.
环境
Environment Info:
current version of create-react-app: 5.0.0
running from /Users/joewalton/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app
System:
OS: macOS 12.0.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 16.13.1 - ~/.asdf/installs/nodejs/16.13.1/bin/node
Yarn: 1.22.17 - ~/.asdf/installs/nodejs/16.13.1/.npm/bin/yarn
npm: 8.1.2 - ~/.asdf/installs/nodejs/16.13.1/bin/npm
Browsers:
Chrome: 97.0.4692.71
Edge: Not Found
Firefox: Not Found
Safari: 15.1
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: ^5.0.0 => 5.0.0
npmGlobalPackages:
create-react-app: Not Found
重现步骤
- 使用typescript模板创建一个新的create-react-app。
npx create-react-app my-app --template typescript
- 在
src/App.test.tsx
中添加一个类型错误。 - 运行
npm run build
预期行为
在运行或构建应用程序代码时,测试文件中的类型错误应被忽略。
实际行为
在运行或构建应用程序代码时,测试文件中的类型错误会被报告。
1条答案
按热度按时间8aqjt8rx1#
同样的问题,除此之外,通常
@ts-ignore
或@ts-expect-error
可以正常工作,但在.test
文件中无法正常工作,它们被忽略了,但在主代码中仍然可以正常工作。因此,我认为当运行测试时,存在一些配置差异,它可能会忽略linting插件?或者这些插件已经过时,不支持测试环境?