adminjs icon indicating copy to clipboard operation
adminjs copied to clipboard

Improve types

Open wojtek-krysiak opened this issue 5 years ago • 1 comments

Describe the problem feature solves

Right now typescript types are not well designed in multiple places and could be better.

Those are the places:

  • Action interface
  • PropertyOptions
  • BasePropertyComponent and its child components
  • ApiClient and ViewHelpers

Describe the solution you'd like

All the types should be improved and also clear to understand from the documentation point of view.

Acceptance criteria

These are the proposed changes:

Acton

  • Right now Action takes type argument which is an ActionResponse, which is just one difference. We should get rid of that
  • Particular custom action properties should be typed based on: actionType and the name
  • Still there should be one global Action interface which will go to the docs.

PropertyOptions

  • they should take care of type and based on that compute types for custom property and props property.

BasePropertyComponent

  • there are types for Edit/List/Show/FilterPropertyComponent and they are not reused in child components it should change
  • In BasePropertyComponetn when you pass Custom components they have any type - they should be typed
  • Types from child components should be exported as well
  • Docs should be updated to describe child components

ApiClient and ViewHelpers

  • don't have any particular idea how it can be fixed - the problem is that there are many types and it would be good that they will be simplified

Merging

This task should be split to smaller chunks and immediately merged to release branch

wojtek-krysiak avatar Oct 26 '20 07:10 wojtek-krysiak

I also believe https://github.com/SoftwareBrothers/adminjs/blob/9bb269cab385376525728699f8201cebf0e47bd0/src/adminjs-options.interface.ts#L101 falls into this issue

The usage of | any boils the type down to Array<any>

AshotN avatar Jun 03 '22 21:06 AshotN