feathersjs-ecosystem / feathers-sequelize

A Feathers service adapter for the Sequelize ORM. Supporting MySQL, MariaDB, Postgres, SQLite, and SQL Server
MIT License
208 stars 75 forks source link

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

Open chrisbag opened 4 months ago

chrisbag commented 4 months ago

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

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 commented 4 months ago

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