Enforce stronger types for ArrayBuffers and storage

This commit is contained in:
Fedor Indutny 2021-06-14 17:09:37 -07:00 committed by GitHub
parent 61ac79e9ae
commit 8f5086227a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 748 additions and 675 deletions

View file

@ -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);
}