Enforce stronger types for ArrayBuffers and storage
This commit is contained in:
parent
61ac79e9ae
commit
8f5086227a
56 changed files with 748 additions and 675 deletions
|
@ -1,13 +1,16 @@
|
|||
// Copyright 2019-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { StorageAccessType } from '../types/Storage.d';
|
||||
|
||||
// Matching window.storage.put API
|
||||
// eslint-disable-next-line max-len
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
||||
export function put(key: string, value: any): void {
|
||||
export function put<K extends keyof StorageAccessType>(
|
||||
key: K,
|
||||
value: StorageAccessType[K]
|
||||
): void {
|
||||
window.storage.put(key, value);
|
||||
}
|
||||
|
||||
export async function remove(key: string): Promise<void> {
|
||||
export async function remove(key: keyof StorageAccessType): Promise<void> {
|
||||
await window.storage.remove(key);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue