Skip to content

Commit 2df641b

Browse files
authored
🤖 Merge PR DefinitelyTyped#73979 fix(chrome): Fix definitions of MV2 permissions by @rnwst
1 parent 51b82cb commit 2df641b

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

‎types/chrome/index.d.ts‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ declare namespace chrome {
246246
): void;
247247

248248
/**
249-
* Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned. If {@link declarativeNetRequest.ExtensionActionOptions.displayActionCountAsBadgeText displayActionCountAsBadgeText} is enabled, a placeholder text will be returned unless the {@link runtime.ManifestPermissions declarativeNetRequestFeedback} permission is present or tab-specific badge text was provided.
249+
* Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned. If {@link declarativeNetRequest.ExtensionActionOptions.displayActionCountAsBadgeText displayActionCountAsBadgeText} is enabled, a placeholder text will be returned unless the {@link runtime.ManifestPermission declarativeNetRequestFeedback} permission is present or tab-specific badge text was provided.
250250
*
251251
* Can return its result via Promise.
252252
*/
@@ -7776,7 +7776,7 @@ declare namespace chrome {
77767776
/** The list of host permissions, including those specified in the `optional_permissions` or `permissions` keys in the manifest, and those associated with [Content Scripts](https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts). */
77777777
origins?: string[];
77787778
/** List of named permissions (does not include hosts or origins). */
7779-
permissions?: chrome.runtime.ManifestPermissions[];
7779+
permissions?: chrome.runtime.ManifestPermission[];
77807780
}
77817781

77827782
export interface AddHostAccessRequest {
@@ -9082,7 +9082,7 @@ declare namespace chrome {
90829082
}
90839083

90849084
/** Source: https://developer.chrome.com/docs/extensions/reference/permissions-list */
9085-
export type ManifestPermissions =
9085+
export type ManifestPermission =
90869086
| "accessibilityFeatures.modify"
90879087
| "accessibilityFeatures.read"
90889088
| "activeTab"
@@ -9166,9 +9166,14 @@ declare namespace chrome {
91669166
| "webRequestBlocking"
91679167
| "webRequestAuthProvider";
91689168

9169+
/**
9170+
* @deprecated Use `ManifestPermission` instead.
9171+
*/
9172+
export type ManifestPermissions = ManifestPermission;
9173+
91699174
/** Source : https://developer.chrome.com/docs/extensions/reference/api/permissions */
9170-
export type ManifestOptionalPermissions = Exclude<
9171-
ManifestPermissions,
9175+
export type ManifestOptionalPermission = Exclude<
9176+
ManifestPermission,
91729177
| "debugger"
91739178
| "declarativeNetRequest"
91749179
| "devtools"
@@ -9183,6 +9188,11 @@ declare namespace chrome {
91839188
| "webAuthenticationProxy"
91849189
>;
91859190

9191+
/**
9192+
* @deprecated Use `ManifestOptionalPermission` instead.
9193+
*/
9194+
export type ManifestOptionalPermissions = ManifestOptionalPermission;
9195+
91869196
export interface SearchProvider {
91879197
name?: string | undefined;
91889198
keyword?: string | undefined;
@@ -9402,8 +9412,8 @@ declare namespace chrome {
94029412
}
94039413
| undefined;
94049414
content_security_policy?: string | undefined;
9405-
optional_permissions?: ManifestOptionalPermissions[] | string[] | undefined;
9406-
permissions?: ManifestPermissions[] | string[] | undefined;
9415+
optional_permissions?: (ManifestOptionalPermission | string)[] | undefined;
9416+
permissions?: (ManifestPermission | string)[] | undefined;
94079417
web_accessible_resources?: string[] | undefined;
94089418
}
94099419

@@ -9438,9 +9448,9 @@ declare namespace chrome {
94389448
sandbox?: string;
94399449
};
94409450
host_permissions?: string[] | undefined;
9441-
optional_permissions?: ManifestOptionalPermissions[] | undefined;
9451+
optional_permissions?: ManifestOptionalPermission[] | undefined;
94429452
optional_host_permissions?: string[] | undefined;
9443-
permissions?: ManifestPermissions[] | undefined;
9453+
permissions?: ManifestPermission[] | undefined;
94449454
web_accessible_resources?:
94459455
| Array<
94469456
& {

‎types/chrome/test/index.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,13 @@ function testGetManifest() {
10361036
manifest.content_security_policy; // $ExpectType string | undefined
10371037

10381038
manifest.host_permissions; // $ExpectType any
1039-
manifest.optional_permissions; // $ExpectType ManifestOptionalPermissions[] | string[] | undefined
1040-
manifest.permissions; // $ExpectType ManifestPermissions[] |string[] | undefined
1039+
manifest.optional_permissions; // $ExpectType string[] | undefined
1040+
manifest.permissions; // $ExpectType string[] | undefined
1041+
// Verify that string permissions can be added.
1042+
if (manifest.optional_permissions && manifest.permissions) {
1043+
manifest.optional_permissions.push("*://developer.mozilla.org/*");
1044+
manifest.permissions.push("*://developer.mozilla.org/*");
1045+
}
10411046

10421047
manifest.web_accessible_resources; // $ExpectType string[] | undefined
10431048
} else if (manifest.manifest_version === 3) {
@@ -1051,9 +1056,9 @@ function testGetManifest() {
10511056
};
10521057

10531058
manifest.host_permissions; // $ExpectType string[] | undefined
1054-
manifest.optional_permissions; // $ExpectType ManifestOptionalPermissions[] | undefined
1059+
manifest.optional_permissions; // $ExpectType ManifestOptionalPermission[] | undefined
10551060
manifest.optional_host_permissions; // $ExpectType string[] | undefined
1056-
manifest.permissions; // $ExpectType ManifestPermissions[] | undefined
1061+
manifest.permissions; // $ExpectType ManifestPermission[] | undefined
10571062

10581063
manifest.web_accessible_resources = [{
10591064
resources: ["resource.js"],

0 commit comments

Comments
 (0)