2.2.0 (2020-12-26)
Bug Fixes
- angular: fixes sourcemap generation for the code built by ngc (7715263), closes #387 #382
- package: removes
enginesection 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
exportsprop in package.json (cac2506), closes #331
BREAKING CHANGES
-
builder: changes main generic parameter to be a class instead of instance and makes
defineAbilityto 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
AbilityBuilderis now madatory. This allows to infer generic parameters from it and makes AbilityType that is built to be explicit.