Typescript: Hook type no longer compatible for disablePagination · Issue #564 · feathersjs-ecosystem/feathers-hooks-common · GitHub
Skip to content

Typescript: Hook type no longer compatible for disablePagination  #564

Open

Description

@lwhiteley

Steps to reproduce

Using disablePagination hook produces a typescript error

eg. 1

// /src/app.hooks.ts
import { disablePagination } from "feathers-hooks-common";

export default {
  before: {
    all: [],
    find: [disablePagination()],
    get: [],
   ...
 Types of property 'find' are incompatible.
   Type 'Hook<any, Service<any>>[]' is not assignable to 
     type 'Hook<any, Service<any>> | Hook<any, Service<any>>[] | undefined'.

eg 2

// /src/app.hooks.ts
import { disablePagination } from "feathers-hooks-common";

export default {
  before: {
    all: [],
    find: disablePagination(),
    get: [],
   ...
Types of property 'find' are incompatible.
    Type 'Hook<any, Service<any>>' is not assignable to 
      type 'Hook<any, Service<any>> | Hook<any, Service<any>>[] | undefined'.

Actual behavior

Application does not compile when hook is used

Expected behavior

Application should compile without issues

Module versions :

"@feathersjs/feathers": "^4.5.0",
"feathers-hooks-common": "^5.0.1",
"tslint": "^5.20.1",
"typescript": "^3.7.5"

If it helps.

im using yarn as the package manager

Activity

  1. changed the title [-]Hook types are no longer compatible[/-] [+]Hook type no longer compatible for disablePagination ... (maybe some others)[/+] on Jan 19, 2020
  2. changed the title [-]Hook type no longer compatible for disablePagination ... (maybe some others)[/-] [+]Hook type no longer compatible for disablePagination [/+] on Jan 19, 2020
  3. changed the title [-]Hook type no longer compatible for disablePagination [/-] [+]Typescript: Hook type no longer compatible for disablePagination [/+] on Jan 19, 2020
  4. eXigentCoder commented on Jul 30, 2020

    @eXigentCoder

    Having the same issue with validateSchema

    feathers-hooks-common: 5.0.3
    @feathersjs/feathers: 4.5.1

    Also using yarn

    Conversion of type 'Hook<any, Service<any>>' to type 'Hook<AdvancedSearchResult, Service<AdvancedSearchResult>>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
      Types of parameters 'hook' and 'hook' are incompatible.
        Type 'HookContext<AdvancedSearchResult, Service<AdvancedSearchResult>>' is not comparable to type 'HookContext<any, Service<any>>'.
          Types of property 'app' are incompatible.
            Type 'Application<{}>' is missing the following properties from type 'Application<{}>': lookup, channels, channel, publish, and 2 more.ts(2352)
    

    As a workaround for now I'm doing the following:

    {
        after: {
    	all: [],
    	find: [(validateSchema(responseSchema(), ajv) as unknown) as Hook],
    	get: [],
    	create: [],
    	update: [],
    	patch: [],
    	remove: [],
        },
    }
  5. holmesconan commented on Aug 13, 2020

    @holmesconan

    @eXigentCoder it works! But hope for fixing.

  6. ishfaq-dar commented on Oct 19, 2021

    @ishfaq-dar

    did you get the solution???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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