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

前端 未结 2 1631
滥情空心
滥情空心 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条回答
  • 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';
    
    0 讨论(0)
  • 2021-02-20 04:56

    if the issue exist after after the .d.ts file creation, use "noImplicitAny": false, in your tsconfig.json

    0 讨论(0)
提交回复
热议问题