Skip to content

Commit afc5ca8

Browse files
fix: resolve permissions.test.ts type errors from upstream merge
Add PermissionSettings import and use explicit type annotations for settings objects with empty arrays (as const produces readonly never[] which is incompatible with Required<PermissionSettings>).
1 parent 2329f8f commit afc5ca8

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

packages/core/src/tests/permissions.test.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
isPathInAnyDirectory,
1313
parseBashSideEffects,
1414
} from "../common/permissions";
15-
import type { PermissionScope } from "../settings";
15+
import type { PermissionScope, PermissionSettings } from "../settings";
1616

1717
const tempDirs: string[] = [];
1818

@@ -33,11 +33,11 @@ test("parseBashSideEffects accepts valid scopes and normalizes unsafe values to
3333
});
3434

3535
test("evaluatePermissionScopes applies deny, ask, allow, and default mode precedence", () => {
36-
const settings = {
37-
allow: ["read-in-cwd" as const],
38-
deny: ["write-out-cwd" as const],
39-
ask: ["network" as const],
40-
defaultMode: "askAll" as const,
36+
const settings: Required<PermissionSettings> = {
37+
allow: ["read-in-cwd"] as PermissionScope[],
38+
deny: ["write-out-cwd"] as PermissionScope[],
39+
ask: ["network"] as PermissionScope[],
40+
defaultMode: "askAll",
4141
};
4242

4343
assert.equal(evaluatePermissionScopes(["write-out-cwd"], settings), "deny");
@@ -49,41 +49,41 @@ test("evaluatePermissionScopes applies deny, ask, allow, and default mode preced
4949
});
5050

5151
test("evaluatePermissionScopes allows unknown when defaultMode is allowAll", () => {
52-
const allowAllSettings = {
53-
allow: [] as const,
54-
deny: [] as const,
55-
ask: [] as const,
56-
defaultMode: "allowAll" as const,
52+
const allowAllSettings: Required<PermissionSettings> = {
53+
allow: [] as PermissionScope[],
54+
deny: [] as PermissionScope[],
55+
ask: [] as PermissionScope[],
56+
defaultMode: "allowAll",
5757
};
5858
assert.equal(evaluatePermissionScopes(["unknown"], allowAllSettings), "allow");
5959

6060
// unknown + other scopes that would otherwise trigger ask should still ask for those scopes
61-
const askNetworkSettings = {
62-
allow: [] as const,
63-
deny: [] as const,
64-
ask: ["network" as const],
65-
defaultMode: "allowAll" as const,
61+
const askNetworkSettings: Required<PermissionSettings> = {
62+
allow: [] as PermissionScope[],
63+
deny: [] as PermissionScope[],
64+
ask: ["network"] as PermissionScope[],
65+
defaultMode: "allowAll",
6666
};
6767
assert.equal(evaluatePermissionScopes(["unknown", "network"], askNetworkSettings), "ask");
6868
});
6969

7070
test("getPermissionScopesRequiringAsk excludes unknown when defaultMode is allowAll", () => {
71-
const allowAllSettings = {
72-
allow: [] as const,
73-
deny: [] as const,
74-
ask: ["network" as const],
75-
defaultMode: "allowAll" as const,
71+
const allowAllSettings: Required<PermissionSettings> = {
72+
allow: [] as PermissionScope[],
73+
deny: [] as PermissionScope[],
74+
ask: ["network"] as PermissionScope[],
75+
defaultMode: "allowAll",
7676
};
7777
const result = getPermissionScopesRequiringAsk(["unknown", "network"], allowAllSettings);
7878
assert.deepEqual(result, ["network"]);
7979
});
8080

8181
test("getPermissionScopesRequiringAsk includes unknown when defaultMode is askAll", () => {
82-
const askAllSettings = {
83-
allow: [] as const,
84-
deny: [] as const,
85-
ask: ["network" as const],
86-
defaultMode: "askAll" as const,
82+
const askAllSettings: Required<PermissionSettings> = {
83+
allow: [] as PermissionScope[],
84+
deny: [] as PermissionScope[],
85+
ask: ["network"] as PermissionScope[],
86+
defaultMode: "askAll",
8787
};
8888
const result = getPermissionScopesRequiringAsk(["unknown", "network"], askAllSettings);
8989
assert.deepEqual(result, ["unknown", "network"]);

0 commit comments

Comments
 (0)