How do I import react-admin in a React Typescript appplication?

前端 未结 2 1637
滥情空心
滥情空心 2021-02-20 04:22

I\'m trying to set up a react-admin app in typescript and I can\'t quite figure out how to import react-admin. It gives me the (simple) error saying

\"Could not         


        
2条回答
  •  萌比男神i
    2021-02-20 04:55

    Current version of react-admin does not export types definition. To make your project to compile you need to create index.d.ts file and modify tsconfig.json.

    ├── @types
    │   └── react-admin
    │       └── index.d.ts
    └── tsconfig.json
    
    // tsconfig.json
    
    {
      ...
      "compilerOptions": {
        ...
        "typeRoots": ["./@types"],
        ...
      },
      ...
    }
    
    // index.d.ts
    declare module 'react-admin';
    

提交回复
热议问题