Skip to content

infer multi, id & paginate of service.options #3012

@fratzinger

Description

@fratzinger

Problem:

  • For all services the type of data for create is T or T[], even true for services with multi: false / multi: { create: false }.
  • For all services the type of id for patch & remove is NullableId, even for services with multi: false / multi: { patch: false, remove: false }
  • For all services the awaited return type of find is Result[] | Paginated<Result>, even for services with paginate: false
  • { $select: ['email'] } does not return Pick<Result, 'email'> but the 'full' type Result instead. Even though Pick<Result, 'email'> wouldn't be the correct type either. It has to be Pick<Result, 'email' | Service['options']['id']>

The root of these problems above is, that the type of service.options is not considered in the service methods. The AdapterBase already has a generic Options. We only need to infer the type and fall back to the general types, if it cannot infer.

Other things to consider:

es6 classes are tedious to work with for heavy TS work like inference. We already saw this for feathers-pinia and moved away from model classes. I think we should move away from es6 classes for adapters & services and make a custom useService(...) function. But I guess I need to open another issue/discussion for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions