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

refactor: gets rid of deprecated Ability type and replaces it with MongoAbility #951

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/casl-vue/src/component/can.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { defineComponent, ComponentCustomProperties } from 'vue';
import {
SubjectType,
Generics,
AnyAbility,
Ability,
Abilities,
IfString,
AbilityTuple,
AnyAbility,
Generics,
IfString,
MongoAbility,
SubjectType
} from '@casl/ability';
import { ComponentCustomProperties, defineComponent } from 'vue';
import { useAbility } from '../useAbility';

type AbilityCanProps<
Expand All @@ -27,7 +27,7 @@ export type CanProps<T extends AnyAbility> = AbilityCanProps<Generics<T>['abilit

type VueAbility = ComponentCustomProperties extends { $ability: AnyAbility }
? ComponentCustomProperties['$ability']
: Ability;
: MongoAbility;

function detectSubjectProp(props: Record<string, unknown>) {
if (props.a !== undefined) {
Expand Down
4 changes: 2 additions & 2 deletions packages/casl-vue/src/useAbility.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { AnyAbility, MongoAbility } from '@casl/ability';
import { inject, InjectionKey, provide } from 'vue';
import type { AnyAbility, Ability } from '@casl/ability';
import { reactiveAbility } from './reactiveAbility';

export const ABILITY_TOKEN: InjectionKey<AnyAbility> = Symbol('ability');

export function useAbility<T extends AnyAbility = Ability>(): T {
export function useAbility<T extends AnyAbility = MongoAbility>(): T {
const ability = inject<T>(ABILITY_TOKEN);

if (!ability) {
Expand Down
Loading