@types/chrome 0.0.271 → 0.0.272

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. chrome/README.md +1 -1
  2. chrome/index.d.ts +23 -13
  3. chrome/package.json +2 -2
chrome/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for chrome (http://developer.chrome.com/e
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chrome.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Sat, 14 Sep 2024 10:37:02 GMT
11
+ * Last updated: Wed, 25 Sep 2024 00:29:50 GMT
12
12
  * Dependencies: [@types/filesystem](https://npmjs.com/package/@types/filesystem), [@types/har-format](https://npmjs.com/package/@types/har-format)
13
13
 
14
14
  # Credits
chrome/index.d.ts CHANGED
@@ -8357,6 +8357,11 @@ declare namespace chrome.sessions {
8357
8357
  * @since Chrome 20
8358
8358
  */
8359
8359
  declare namespace chrome.storage {
8360
+ /** NoInfer for old TypeScript versions */
8361
+ type NoInferX<T> = T[][T extends any ? 0 : never];
8362
+ // The next line prevents things without the export keyword from being automatically exported (like NoInferX)
8363
+ export {};
8364
+
8360
8365
  export interface StorageArea {
8361
8366
  /**
8362
8367
  * Gets the amount of space (in bytes) being used by one or more items.
@@ -8370,14 +8375,17 @@ declare namespace chrome.storage {
8370
8375
  * @return A Promise that resolves with a number
8371
8376
  * @since MV3
8372
8377
  */
8373
- getBytesInUse(keys?: string | string[] | null): Promise<number>;
8378
+ getBytesInUse<T = { [key: string]: any }>(keys?: keyof T | Array<keyof T> | null): Promise<number>;
8374
8379
  /**
8375
8380
  * Gets the amount of space (in bytes) being used by one or more items.
8376
8381
  * @param keys Optional. 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.
8377
8382
  * @param callback Callback with the amount of space being used by storage, or on failure (in which case runtime.lastError will be set).
8378
8383
  * Parameter bytesInUse: Amount of space being used in storage, in bytes.
8379
8384
  */
8380
- getBytesInUse(keys: string | string[] | null, callback: (bytesInUse: number) => void): void;
8385
+ getBytesInUse<T = { [key: string]: any }>(
8386
+ keys: keyof T | Array<keyof T> | null,
8387
+ callback: (bytesInUse: number) => void,
8388
+ ): void;
8381
8389
  /**
8382
8390
  * Removes all items from storage.
8383
8391
  * @return A void Promise
@@ -8397,7 +8405,7 @@ declare namespace chrome.storage {
8397
8405
  * @return A void Promise
8398
8406
  * @since MV3
8399
8407
  */
8400
- set(items: { [key: string]: any }): Promise<void>;
8408
+ set<T = { [key: string]: any }>(items: Partial<T>): Promise<void>;
8401
8409
  /**
8402
8410
  * Sets multiple items.
8403
8411
  * @param items An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected.
@@ -8405,7 +8413,7 @@ declare namespace chrome.storage {
8405
8413
  * @param callback Optional.
8406
8414
  * Callback on success, or on failure (in which case runtime.lastError will be set).
8407
8415
  */
8408
- set(items: { [key: string]: any }, callback: () => void): void;
8416
+ set<T = { [key: string]: any }>(items: Partial<T>, callback: () => void): void;
8409
8417
  /**
8410
8418
  * Removes one or more items from storage.
8411
8419
  * @param keys A single key or a list of keys for items to remove.
@@ -8413,20 +8421,20 @@ declare namespace chrome.storage {
8413
8421
  * @return A void Promise
8414
8422
  * @since MV3
8415
8423
  */
8416
- remove(keys: string | string[]): Promise<void>;
8424
+ remove<T = { [key: string]: any }>(keys: keyof T | Array<keyof T>): Promise<void>;
8417
8425
  /**
8418
8426
  * Removes one or more items from storage.
8419
8427
  * @param keys A single key or a list of keys for items to remove.
8420
8428
  * @param callback Optional.
8421
8429
  * Callback on success, or on failure (in which case runtime.lastError will be set).
8422
8430
  */
8423
- remove(keys: string | string[], callback: () => void): void;
8431
+ remove<T = { [key: string]: any }>(keys: keyof T | Array<keyof T>, callback: () => void): void;
8424
8432
  /**
8425
8433
  * Gets the entire contents of storage.
8426
8434
  * @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set).
8427
8435
  * Parameter items: Object with items in their key-value mappings.
8428
8436
  */
8429
- get(callback: (items: { [key: string]: any }) => void): void;
8437
+ get<T = { [key: string]: any }>(callback: (items: T) => void): void;
8430
8438
  /**
8431
8439
  * Gets one or more items from storage.
8432
8440
  * @param keys A single key to get, list of keys to get, or a dictionary specifying default values.
@@ -8434,7 +8442,9 @@ declare namespace chrome.storage {
8434
8442
  * @return A Promise that resolves with an object containing items
8435
8443
  * @since MV3
8436
8444
  */
8437
- get(keys?: string | string[] | { [key: string]: any } | null): Promise<{ [key: string]: any }>;
8445
+ get<T = { [key: string]: any }>(
8446
+ keys?: NoInferX<keyof T> | Array<NoInferX<keyof T>> | Partial<NoInferX<T>> | null,
8447
+ ): Promise<T>;
8438
8448
  /**
8439
8449
  * Gets one or more items from storage.
8440
8450
  * @param keys A single key to get, list of keys to get, or a dictionary specifying default values.
@@ -8442,9 +8452,9 @@ declare namespace chrome.storage {
8442
8452
  * @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set).
8443
8453
  * Parameter items: Object with items in their key-value mappings.
8444
8454
  */
8445
- get(
8446
- keys: string | string[] | { [key: string]: any } | null,
8447
- callback: (items: { [key: string]: any }) => void,
8455
+ get<T = { [key: string]: any }>(
8456
+ keys: NoInferX<keyof T> | Array<NoInferX<keyof T>> | Partial<NoInferX<T>> | null,
8457
+ callback: (items: T) => void,
8448
8458
  ): void;
8449
8459
  /**
8450
8460
  * Sets the desired access level for the storage area. The default will be only trusted contexts.
@@ -8513,12 +8523,12 @@ declare namespace chrome.storage {
8513
8523
  extends chrome.events.Event<(changes: { [key: string]: StorageChange }) => void>
8514
8524
  {}
8515
8525
 
8516
- type AreaName = keyof Pick<typeof chrome.storage, "sync" | "local" | "managed" | "session">;
8526
+ export type AreaName = keyof Pick<typeof chrome.storage, "sync" | "local" | "managed" | "session">;
8517
8527
  export interface StorageChangedEvent
8518
8528
  extends chrome.events.Event<(changes: { [key: string]: StorageChange }, areaName: AreaName) => void>
8519
8529
  {}
8520
8530
 
8521
- type AccessLevel = keyof typeof AccessLevel;
8531
+ export type AccessLevel = keyof typeof AccessLevel;
8522
8532
 
8523
8533
  /** The storage area's access level. */
8524
8534
  export var AccessLevel: {
chrome/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/chrome",
3
- "version": "0.0.271",
3
+ "version": "0.0.272",
4
4
  "description": "TypeScript definitions for chrome",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chrome",
6
6
  "license": "MIT",
@@ -93,6 +93,6 @@
93
93
  "@types/filesystem": "*",
94
94
  "@types/har-format": "*"
95
95
  },
96
- "typesPublisherContentHash": "2d78bd0f0e42e12eb3a7a794724c743148b1befe10cc038d78381a0fdf1f7998",
96
+ "typesPublisherContentHash": "5b474140053b4529fdd4825afb57909288b0afe2b042653e768ea7056c68df63",
97
97
  "typeScriptVersion": "4.8"
98
98
  }