adminjs
adminjs copied to clipboard
Resource fields don't show typing informations
Describe the bug
No typing information is showed on editors when trying to add a new resource to the resource array in the AdminJS
instance.
Installed libraries and their versions
- adminjs@^6.0.0
- @adminjs/express@^5.0.0
- @adminjs/mongoose@^3.0.0
To Reproduce
- Create a new AdminJS instance
- In the property
resource
of the options object, add an array with a resource - Typing won't be available for the resource item
I've created a repo for reproducing the bug: https://github.com/asynched/adminjs-resource-fields-repro
Expected behavior Expected to have typing schema for a resource entry in the array of resources.
Screenshots
Additional context
The problem seems to be related to the AdminJSOptions
type definition, where the resource type is Array<ResourceWithOptions | any>
, removing the any
type seems to fix the problem (as the screenshot below shows).
The editor I'm currently using is VSCode, I don't know if the problem is specific to VSCode.
I think any
comes from you being able to pass any
ORM/ODM model, e.g. Typeorm entity, Mongoose model, etc. We could probably fix this by introducing generic T
type for AdminJSOptions
which would be a type for your entity. This would cause typing problems if you're using multiple ORMs/ODMs though. I'll investigate how we can type this better.
This is a duplicate of https://github.com/SoftwareBrothers/adminjs/issues/656