Skip to content

Commit

Permalink
Fix: workaround issue with TS spread compilation: jaredpalmer/tsdx#91…
Browse files Browse the repository at this point in the history
  • Loading branch information
kepelrs committed Jul 13, 2021
1 parent c42faff commit 0ac42cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/access-policy/default-policies/rbac.policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const RBAC = <T extends AllowedRolesId = AllowedRolesId>(
}

// if this is reached type of allowedRoles: RbacParams is AllowedRolesId
const userRolesArray = [...userRolesSet];
const userRolesArray = Array.from(userRolesSet);
const allowedRolesSet = new Set(allowedRoles as any[]);
for (let i = 0; i < userRolesArray.length; i++) {
const role = userRolesArray[i];
Expand Down
8 changes: 4 additions & 4 deletions src/prisma-crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export class PrismaCrudService {
private getSanitizedDefaultJoins(
defaultJoins: string[] | undefined | null,
allowedJoinsSet: Set<string>,
) {
): string[] {
if (!(defaultJoins instanceof Array)) {
return [...allowedJoinsSet]; // defaultJoins equals allowedJoins when not specified
return Array.from(allowedJoinsSet); // defaultJoins equals allowedJoins when not specified
}

for (let i = 0; i < defaultJoins.length; i++) {
Expand All @@ -56,7 +56,7 @@ export class PrismaCrudService {
}
}

return [...new Set(defaultJoins)];
return Array.from(new Set(defaultJoins));
}

private getIncludes(requestSpecificIncludes: string[] | undefined | null) {
Expand All @@ -75,7 +75,7 @@ export class PrismaCrudService {
}
}

return transformJoinsToInclude([...new Set(allowedJoins)]);
return transformJoinsToInclude(Array.from(new Set(allowedJoins)));
}

private parseCrudQ(crudQ: undefined | null | string): CrudObj {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function transformJoinsToInclude(joins: string[]) {
return {};
}

joins = [...joins];
joins = joins.slice();
joins.sort(function(a, b) {
// ASC -> a.length - b.length
// DESC -> b.length - a.length
Expand Down

0 comments on commit 0ac42cc

Please sign in to comment.