feathers-hooks-common
feathers-hooks-common copied to clipboard
Typescript: Hook type no longer compatible for disablePagination
trafficstars
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
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: [],
},
}
@eXigentCoder it works! But hope for fixing.
did you get the solution???