Reactjs 如何在react Typescript应用程序中导入react admin?
我正在尝试在typescript中设置react admin应用程序,但我不太清楚如何导入react admin。它给了我一个(简单的)错误Reactjs 如何在react Typescript应用程序中导入react admin?,reactjs,typescript,react-admin,Reactjs,Typescript,React Admin,我正在尝试在typescript中设置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
"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上找不到其他人对此提出抱怨。我错过什么了吗?就我所见,大多数东西已经迁移到了typescript
编辑:找到了实际引用ts问题的。但是,自从他们说“需要几个月”以来,已经5个月了。当前版本的react admin没有导出类型定义。要使项目进行编译,您需要创建
index.d.ts
文件并修改tsconfig.json
├── @types
│ └── react-admin
│ └── index.d.ts
└── tsconfig.json
如果在.d.ts文件创建之后存在问题,请在tsconfig.json中使用
“noImplicitAny”:false,
,谢谢,这是正确的答案。一般来说,在index.d.ts中声明模块通常会起作用。
// tsconfig.json
{
...
"compilerOptions": {
...
"typeRoots": ["./@types"],
...
},
...
}
// index.d.ts
declare module 'react-admin';