authz: restrict type of PermissionCondition params

We need a guarantee that we'll be able to spread permission condition
params when applying the condition via the `apply` or `toQuery` methods
on the corresponding rule. As such, we need to enforce that the TParams
type parameter is an array.

This commit also supplies a default value of unknown[] for this type
param to make it a bit more convenient to use the type in situations
where the type of the params is not important.

Signed-off-by: Mike Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
Mike Lewis
2021-11-11 13:32:18 +00:00
parent 00448f02e6
commit ea77555fe3
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ export class PermissionClient {
}
// @public
export type PermissionCondition<TParams> = {
export type PermissionCondition<TParams extends unknown[] = unknown[]> = {
rule: string;
params: TParams;
};
+1 -1
View File
@@ -54,7 +54,7 @@ export type AuthorizeRequest = {
* claims from a identity token.
* @public
*/
export type PermissionCondition<TParams> = {
export type PermissionCondition<TParams extends unknown[] = unknown[]> = {
rule: string;
params: TParams;
};