yezihaohao/react-admin

npm run build 报错

xiaobo0113 opened this issue · 3 comments

TypeScript error in D:/xiaobo/work/Github/react-admin/node_modules/jest-diff/build/diffLines.d.ts(8,13):
'=' expected. TS1005

 6 |  */
 7 | import { Diff } from './cleanupSemantic';

8 | import type { DiffOptions } from './types';
| ^
9 | export declare const diffLinesUnified: (aLines: string[], bLines: string[], options?: DiffOptions | undefined) => string;
10 | export declare const diffLinesUnified2: (aLinesDisplay: string[], bLinesDisplay: string[], aLinesCompare: string[], bLinesCompare: string[], options?: DiffOptions | undefined) => string;
11 | export declare const diffLinesRaw: (aLines: string[], bLines: string[]) => Diff[];

没复现出问题,你是升级了依赖包吗?

问题在jest issues里面可以找到及解决方案,可以参考一下:jestjs/jest#9703

我什么都没有改,你可以试着从仓库重新clone一个下来试试,看看能不能复现

1.jest使用的是24.9.0版本,但是查看node_modules/jest-diff/package.json文件,发现使用的是26.0.1版本

2.在package.json中写的是"echarts-for-react": "^2.0.15-beta.1",注意有个^符号,导致了npm i的时候会去获取新版本,查看node_modules/echarts-for-react/package.json文件,发现是"echarts-for-react@2.0.16",即下载了2.0.16版本的echarts-for-react,导致了和你代码中使用的api不一致。

解决办法:
1.在package.json中添加"jest-diff": "24.9.0"指定使用24.9.0的jest-diff
2.在package.json中更新为`"echarts-for-react": "2.0.15-beta.1"指定使用2.0.15-beta.1版本的echarts-for-react