Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feathers sequlize type confict when overwritting find and calling super.find #432

Open
chrisbag opened this issue Apr 3, 2024 · 1 comment

Comments

@chrisbag
Copy link

chrisbag commented Apr 3, 2024

Steps to reproduce

Hello,

I have been playing around with Feathers Dove V5 in order to see the implications of upgrading from v4 and have stumbled upon this typescript Error while customizing the sequelize adapter.

When I create a new Sequelize Service and overwrite find method and call super.find(params), I get a type error because

  • the type of super.find is Promise<User[] | Paginated>
  • the type of the Sequelize adapter find function is 'PaginatedOrArray<User, P>'
import { SequelizeService, SequelizeAdapterOptions } from "feathers-sequelize"
import { Application, Params } from "src/declarations"

export class Users extends SequelizeService<User> {
  app: Application

  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  constructor(options: SequelizeAdapterOptions, app: Application) {
    super(options)
    this.app = app
  }

  async find(params: Params) {
    return super.find(params)
  }
}

Expected behavior

Ideally, params and result types should be overwritten and be compatible with PaginatedOrArray

Actual behavior

image image
@chrisbag chrisbag changed the title feathers sequlize type confict when calling super.find feathers sequlize type confict when overwritting find and calling super.find Apr 3, 2024
@chrisbag
Copy link
Author

chrisbag commented Apr 5, 2024

Find the solution in the docs for those who might stumble onto that issue

When overriding an existing [service method](https://feathersjs.com/api/services.html#service-methods) on a database adapter the method and overload signatures have to match. The following example shows how to override every service method. Only the methods you want to customize have to be added.
https://feathersjs.com/guides/cli/service.class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant