我正在尝试在打字稿中设置一个react-admin应用程序,但我不太清楚如何导入react-admin。它给了我(简单)错误说
"Could not find a declaration file for module 'react-admin'. '.../node_modules/react-admin/lib/index.js' implicitly has an 'any' type. Try `npm install @types/react-admin` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-admin';`"
@ types / react- admin不是有效的程序包,但是我找不到其他人在github或stackoverflow上对此抱怨。我想念什么吗?据我所知,大多数东西已经迁移到打字稿上了。
编辑:发现这实际上引用了ts问题。但是距离他们说“需要几个月”已经过去了5个月。
当前版本的react-admin不导出类型定义。为了使您的项目能够编译,您需要创建index.d.ts文件并进行修改tsconfig.json。
index.d.ts
tsconfig.json
├── @types │ └── react-admin │ └── index.d.ts └── tsconfig.json // tsconfig.json { ... "compilerOptions": { ... "typeRoots": ["./@types"], ... }, ... } // index.d.ts declare module 'react-admin';