Skip to content

Commit

Permalink
Export accesscontrol types
Browse files Browse the repository at this point in the history
We want to be able to use interfaces such as
[Permission](https://onury.io/accesscontrol/?api=ac#AccessControl~Permission)
in our typedefs, so if we use `InjectRolesBuilder() ac: RolesBuilder` we
can say `let perm: Permission = this.ac.can(roles).readAny('photos')`.

Alternatives:
Just use type inference: without the `: Permission`,  `perm` is still
inferred as `Permission` type.  But what if we want to be explicit for
readability?

Separately add `accesscontrol` to our `package.json` and import
`Permission` separately.  This is fine (and what we'll do if this PR
doesn't get accepted), but why not just give us these?

Is it because you rename `AccessControl`→`RoleBuilder`, and you don't
want to add confusion by having both types available?
  • Loading branch information
vegerot committed Jan 7, 2021
1 parent 0cae9e0 commit b45adf4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ export * from './access-control.module';
export * from './roles-builder.class';
export * from './role.interface';
export * from './access-control.guard';
export { ROLES_BUILDER_TOKEN } from './constants'
export type {
Access,
IAccessInfo,
Query,
IQueryInfo,
Permission,
AccessControlError,
} from 'accesscontrol';
export { ROLES_BUILDER_TOKEN } from './constants';

0 comments on commit b45adf4

Please sign in to comment.