From 066ad05eca43cff447f0e7fac0523f37d804f4a1 Mon Sep 17 00:00:00 2001 From: Erwan Jugand Date: Fri, 17 Apr 2026 20:18:47 +0200 Subject: [PATCH] [chrome] drop support for TypeScript 5.3 and below, remove type deprecations and unexpose _debugger namespace --- types/chrome/index.d.ts | 54 +++++++++++--------------------------- types/chrome/package.json | 2 +- types/chrome/test/index.ts | 6 ++--- 3 files changed, 19 insertions(+), 43 deletions(-) diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index a4be0921370abf..6da0ca4315a88f 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -2246,7 +2246,7 @@ declare namespace chrome { * * Permissions: "debugger" */ - export namespace _debugger { + namespace _debugger { /** Debuggee identifier. Either tabId, extensionId or targetId must be specified */ interface Debuggee { /** The id of the tab which you intend to debug. */ @@ -9217,11 +9217,6 @@ declare namespace chrome { | "webRequestBlocking" | "webRequestAuthProvider"; - /** - * @deprecated Use `ManifestPermission` instead. - */ - type ManifestPermissions = ManifestPermission; - /** Source : https://developer.chrome.com/docs/extensions/reference/api/permissions */ type ManifestOptionalPermission = Exclude< ManifestPermission, @@ -9239,11 +9234,6 @@ declare namespace chrome { | "webAuthenticationProxy" >; - /** - * @deprecated Use `ManifestOptionalPermission` instead. - */ - type ManifestOptionalPermissions = ManifestOptionalPermission; - interface SearchProvider { name?: string | undefined; keyword?: string | undefined; @@ -10112,12 +10102,7 @@ declare namespace chrome { * Permissions: "storage" */ export namespace storage { - /** NoInfer for old TypeScript versions (Required TS 5.4+) */ - type NoInferX = T[][T extends any ? 0 : never]; - // The next line prevents things without the export keyword from being automatically exported (like NoInferX) - export {}; - - export interface StorageArea { + interface StorageArea { /** * Gets the amount of space (in bytes) being used by one or more items. * @param keys A single key or list of keys to get the total usage for. An empty list will return 0. Pass in `null` to get the total usage of all of storage. @@ -10164,11 +10149,11 @@ declare namespace chrome { * Can return its result via Promise in Manifest V3 or later since Chrome 95. */ get( - keys?: NoInferX | Array> | Partial> | null, + keys?: NoInfer | Array> | Partial> | null, ): Promise; get(callback: (items: T) => void): void; get( - keys: NoInferX | Array> | Partial> | null | undefined, + keys: NoInfer | Array> | Partial> | null | undefined, callback: (items: T) => void, ): void; @@ -10195,19 +10180,19 @@ declare namespace chrome { getKeys(callback: (keys: string[]) => void): void; } - export interface StorageChange { + interface StorageChange { /** The new value of the item, if there is a new value. */ newValue?: unknown; /** The old value of the item, if there was an old value. */ oldValue?: unknown; } - export interface LocalStorageArea extends StorageArea { + interface LocalStorageArea extends StorageArea { /** The maximum amount (in bytes) of data that can be stored in local storage, as measured by the JSON stringification of every value plus every key's length. This value will be ignored if the extension has the unlimitedStorage permission. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError when using a callback, or a rejected Promise if using async/await. */ QUOTA_BYTES: 10485760; } - export interface SyncStorageArea extends StorageArea { + interface SyncStorageArea extends StorageArea { /** @deprecated The storage.sync API no longer has a sustained write operation quota. */ MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: 1000000; /** The maximum total amount (in bytes) of data that can be stored in sync storage, as measured by the JSON stringification of every value plus every key's length. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError when using a callback, or when a Promise is rejected. */ @@ -10230,18 +10215,18 @@ declare namespace chrome { MAX_WRITE_OPERATIONS_PER_MINUTE: 120; } - export interface SessionStorageArea extends StorageArea { + interface SessionStorageArea extends StorageArea { /** The maximum amount (in bytes) of data that can be stored in memory, as measured by estimating the dynamically allocated memory usage of every value and key. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError when using a callback, or when a Promise is rejected. */ QUOTA_BYTES: 10485760; } - export type AreaName = "sync" | "local" | "managed" | "session"; + type AreaName = "sync" | "local" | "managed" | "session"; /** * The storage area's access level. * @since Chrome 102 */ - export enum AccessLevel { + enum AccessLevel { /** Specifies contexts originating from the extension itself. */ TRUSTED_CONTEXTS = "TRUSTED_CONTEXTS", /** Specifies contexts originating from outside the extension. */ @@ -10249,13 +10234,13 @@ declare namespace chrome { } /** Items in the `local` storage area are local to each machine. */ - export const local: LocalStorageArea; + const local: LocalStorageArea; /** Items in the `sync` storage area are synced using Chrome Sync. */ - export const sync: SyncStorageArea; + const sync: SyncStorageArea; /** Items in the `managed` storage area are set by an enterprise policy configured by the domain administrator, and are read-only for the extension; trying to modify this namespace results in an error. For information on configuring a policy, see Manifest for storage areas. */ - export const managed: StorageArea; + const managed: StorageArea; /** * Items in the `session` storage area are stored in-memory and will not be persisted to disk. @@ -10263,10 +10248,10 @@ declare namespace chrome { * MV3 only * @since Chrome 102 */ - export const session: SessionStorageArea; + const session: SessionStorageArea; /** Fired when one or more items change. */ - export const onChanged: events.Event<(changes: { [key: string]: StorageChange }, areaName: AreaName) => void>; + const onChanged: events.Event<(changes: { [key: string]: StorageChange }, areaName: AreaName) => void>; } //////////////////// @@ -10289,10 +10274,6 @@ declare namespace chrome { total: number; } - /** @deprecated Use {@link CpuTime} instead. */ - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface ProcessorUsage extends CpuTime {} - interface ProcessorInfo { /** Cumulative usage info for this logical processor. */ usage: CpuTime; @@ -12525,10 +12506,6 @@ declare namespace chrome { reconnect?: string | undefined; } - /** @deprecated Use {@link Parameters} instead */ - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface VpnSessionParameters extends Parameters {} - /** The enum is used by the platform to notify the client of the VPN session status. */ enum PlatformMessage { /** Indicates that the VPN configuration connected. */ @@ -13433,7 +13410,6 @@ declare namespace chrome { /** Fired before sending an HTTP request, once the request headers are available. This may occur after a TCP connection is made to the server, but before any HTTP data is sent. */ const onBeforeSendHeaders: WebRequestEvent< - // eslint-disable-next-line @typescript-eslint/no-invalid-void-type (details: OnBeforeSendHeadersDetails) => BlockingResponse | undefined, `${OnBeforeSendHeadersOptions}`[] >; diff --git a/types/chrome/package.json b/types/chrome/package.json index c043d0ad49af5e..91da517ec54d30 100644 --- a/types/chrome/package.json +++ b/types/chrome/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/chrome", - "version": "0.1.9999", + "version": "0.2.9999", "nonNpm": "conflict", "nonNpmDescription": "The complete reference to all APIs made available to Chrome Extensions", "projects": [ diff --git a/types/chrome/test/index.ts b/types/chrome/test/index.ts index 1953fa2a314026..c270df4fb1564e 100644 --- a/types/chrome/test/index.ts +++ b/types/chrome/test/index.ts @@ -1301,6 +1301,9 @@ function testTabCapture() { // https://developer.chrome.com/docs/extensions/reference/api/debugger function testDebugger() { + // @ts-expect-error Property '_debugger' does not exist on type 'typeof chrome' + chrome._debugger + chrome.debugger.DetachReason.CANCELED_BY_USER === "canceled_by_user"; chrome.debugger.DetachReason.TARGET_CLOSED === "target_closed"; @@ -1460,9 +1463,6 @@ function testStorage() { }; } - // @ts-expect-error - const testNoInferX: chrome.storage.NoInferX = "This test checks if NoInferX is accidentally exported"; - const StorageArea = ["sync", "managed", "local", "session"] as const; StorageArea.forEach((area) => {