Skip to content

@casl/vue@1.2.0

Choose a tag to compare

@stalniy stalniy released this 26 Dec 18:09

1.2.0 (2020-12-26)

Bug Fixes

  • angular: fixes sourcemap generation for the code built by ngc (7715263), closes #387 #382
  • package: removes engine section that points to npm@6 (eecd12a), closes #417

Features

  • builder: improves typings for AbilityBuilder [skip release] (ebd4d17), closes #379
  • esm: adds ESM support for latest Node.js through exports prop in package.json (cac2506), closes #331

BREAKING CHANGES

  • builder: changes main generic parameter to be a class instead of instance and makes defineAbility to accept options as the 2nd argument.

    Before

    import { AbilityBuilder, defineAbility, Ability } from '@casl/ability';
    
    const resolveAction = (action: string) => {/* custom implementation */ };
    const ability = defineAbility({ resolveAction }, (can) => can('read', 'Item'));
    const builder = new AbilityBuilder<Ability>(Ability);

    After

    import { AbilityBuilder, defineAbility, Ability } from '@casl/ability';
    
    const resolveAction = (action: string) => {/* custom implementation */ };
    const ability = defineAbility((can) => can('read', 'Item'), { resolveAction });
    const builder = new AbilityBuilder(Ability); // first argument is now mandatory!

    The 1st parameter to AbilityBuilder is now madatory. This allows to infer generic parameters from it and makes AbilityType that is built to be explicit.