stalniy / casl

CASL is an isomorphic authorization JavaScript library which restricts what resources a given user is allowed to access
https://casl.js.org/
MIT License
5.92k stars 267 forks source link

Typescript issue with the new ofType of accessibleBy #899

Closed kemalcany closed 6 months ago

kemalcany commented 6 months ago

Hello!

Typescript doesn't allow the mongoose 8.0.1 package usage as described in the latest docs (link and the TS error screenshot below)

https://casl.js.org/v6/en/package/casl-mongoose#accessible-by-helper

image

stalniy commented 6 months ago

I think you use the old version of @casl/mongoose very likely 7.x. This is expected because in that version accessibleBy returns proxy which is then on property access returns AbilityQuery. this is not the case for 8.x

I double checked and it works as expected -> https://playcode.io/1816910

stalniy commented 6 months ago

Close as it’s not casl issue but feel free to comment

kemalcany commented 6 months ago

Apologies it was my mistake with the editor. Thank you for looking into it!