【发布时间】:2020-11-03 12:10:07
【问题描述】:
我使用 React,我还使用 Relay,它会生成一些我的应用程序包含的 TypeScript 文件,并且在更改生成这些文件的目录后,TypeScript 抱怨它找不到它们,但有些奇怪。
例如,TypeScript 编译器是这样说的:
> react-scripts build
Creating an optimized production build...
.\src\pages\MyAccount.tsx
Cannot find file './__generated__/MyAccountMutation.graphql' in '.\src\pages'.
error Command failed with exit code 1.
这是真的,没有/src/pages/__generated__/MyAccountMutation.graphql,但MyAccount.tsx 不需要该文件。导入行是:
import {MyAccountMutation} from "../__generated__/MyAccountMutation.graphql"
没错,有一个/src/pages/../__generated__/MyAccountMutation.graphql(即/src/__generated__/MyAccountMutation.graphql)存在。
运行tsc 工作正常。 React 开发服务器也会出现这个问题。
任何想法为什么 React/TypeScript 会尝试获取错误的文件?
【问题讨论】:
标签: reactjs typescript relayjs relay