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

Upgrade feathers-permissions to be compatible with Feathers v5 (Dove) #152

Open
2 tasks done
noahsal opened this issue Apr 10, 2024 · 4 comments
Open
2 tasks done

Comments

@noahsal
Copy link

noahsal commented Apr 10, 2024

Steps to reproduce

feathers-permissions currently uses Feathers 4.5.15. This library is not compatible with the latest Feathers v5 hook types. Specifically, the return type of checkPermissions (Hook) is not compatible with the new HookFunction type - Argument of type 'Hook' is not assignable to parameter of type 'HookFunction<A, S>.

The common solution seems to be to cast the checkPermissions hook to any (or some other matching type), which isn't ideal.

  • Tell us what broke. The more detailed the better.
  • If you can, please create a simple example that reproduces the issue and link to a gist, jsbin, repo, etc.

Expected behavior

Using the checkPermissions hook with Feathers v5 does not produce a type error.

Actual behavior

Type error when using checkPermissions hook with Feathers v5.

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):

  • "@feathersjs/feathers": "^5.0.24"
  • "feathers-permissions": "^2.1.4"

NodeJS version:
v20.3.0

Operating System:
14.3.1 (23D60)

Browser Version:
Chrome Version 123.0.6312.59

@noahsal
Copy link
Author

noahsal commented Apr 10, 2024

I just noticed that this duplicates the in-progress PR #125. However, that PR updates to a pre-release version instead of the now released latest version (and hasn't been touched in a while).

Going to leave this open for now, since the issue is still ongoing and doesn't seem to be actively in progress. Feel free to close if this duplicate violates issue guidelines.

@aessig
Copy link

aessig commented Jul 10, 2024

@noahsal Hello, any news on this topic ?

@noahsal
Copy link
Author

noahsal commented Jul 10, 2024

@aessig I think this issue has not been fixed yet. The checkPermissions function still uses Hook, but does not give any way for the user to supply generic types to make types compatible when a custom HookContext is used throughout the application.

For example, I have the following defined:

export type MyApplication = ExpressFeathers<MyServiceTypes>;
export type MyHookContext = FeathersHookContext<MyApplication>;

In order for checkPermissions to pass the type check I need to cast it as follows:

checkPermissions({
  ...
}) as HookFunction<MyHookContext>

It would be nice if I could just do something like checkPermissions<MyHookContext>(...), instead of needing to use an as cast.

@aessig
Copy link

aessig commented Aug 5, 2024

@noahsal Thanks for the update, I hope it will be updated soon.

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

2 participants