原文见 pauledenburg.com/line-0-pars…
报错如下:
Parsing error: : Cannot read property ‘map’ of undefined
检查有没有声明为空数组 [ ]的类型!!!
如 type A = [ ], const B:[ ] = [ ]
如果没有,就重新install.
原文搬运:
If you’re using React and typescript, try these few actions:
- Reinstall the dependencies:
**rm -rf node_modules; yarn install** - Remove the cache that’s inside the
builddirectory: remove thebuilddirectory and restart the node service - This did it for me (and Trat Westerholt) : don’t type your variables/constants as ‘bare’ arrays:
This failed:
// don't do this - a 'bare' array as type
const customers: [] = []
SOLUTION: It was fixed by:
// add a type to the array
const customers: string[] = []