Skip to content

[Bug] Invalid union type for subject when subjects have different actions #900

@douglasg14b

Description

@douglasg14b

Describe the bug

The union type for Subject appears to be incorrect when different subjcts have different actions.

To Reproduce

type Abilities = ["create" | "manage", "campaign"] | ["create" | "delete", "user:invite"]

const ability = createMongoAbility<Abilities>();

// Intellisense suggests this, but TS actually errors indicating this is incorrect (which it is)
ability.can('delete', 'campaign')

// This is correct
ability.can('delete', 'user:invite')

image

Expected behavior

The union type for subject should be impacted by the action, and not suggest subjects that are not valid for a given action.

CASL Version

@casl/ability: 6.7.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions