on-internet
← Community

How to set ability conditions using TypeScript

Stack Overflow ·

I am following CASL's cookbook on roles with predefined permissions. I have defined my PlatformAbility as follows, in line with the cookbook instructions. import { Ability, AbilityClass, ForcedSubject } from '@casl/ability'; const platformBaseActions = ['manage', 'read', 'write'] as const; const platformSubjects = [ 'all', 'membership', 'work-order', 'equipment', 'user', ] as const; type PlatformAbilities = [ typeof platformBaseActions[number], ( | typeof platformSubjects[number] | ForcedSubject<Exclude<typeof platformSubjects[number], 'all'>> ), ]; export type PlatformAbility = Ability<Platfo

Comments

Sign in or sign up to comment and upvote.

No comments yet.