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

Typescript: Hook type no longer compatible for disablePagination #564

Open
lwhiteley opened this issue Jan 19, 2020 · 3 comments
Open

Typescript: Hook type no longer compatible for disablePagination #564

lwhiteley opened this issue Jan 19, 2020 · 3 comments

Comments

@lwhiteley
Copy link

lwhiteley commented Jan 19, 2020

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

@lwhiteley lwhiteley changed the title Hook types are no longer compatible Hook type no longer compatible for disablePagination ... (maybe some others) Jan 19, 2020
@lwhiteley lwhiteley changed the title Hook type no longer compatible for disablePagination ... (maybe some others) Hook type no longer compatible for disablePagination Jan 19, 2020
@lwhiteley lwhiteley changed the title Hook type no longer compatible for disablePagination Typescript: Hook type no longer compatible for disablePagination Jan 19, 2020
@eXigentCoder
Copy link

eXigentCoder commented Jul 30, 2020

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: [],
    },
}

@holmesconan
Copy link

@eXigentCoder it works! But hope for fixing.

@ishfaq-dar
Copy link

did you get the solution???

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

4 participants