react-native-async-storage / async-storage

An asynchronous, persistent, key-value storage system for React Native.
https://react-native-async-storage.github.io/async-storage/
MIT License
4.61k stars 458 forks source link

multiSet should expect a readonly input #1101

Closed geoffreytools closed 2 weeks ago

geoffreytools commented 3 weeks ago

What happened?

At current, (readonly [string, string])[] is going to be rejected by multiSet because its function signature is the following:

(keyValuePairs: [string, string][], callback?: MultiCallback) => Promise<void>

It should be the following:

(keyValuePairs: ReadonlyArray<readonly [string, string]>, callback?: MultiCallback) => Promise<void>

Version

1.23.1

What platforms are you seeing this issue on?

System Information

Irrelevant

Steps to Reproduce

const entries = [['key', 'val']].map(([k, v]) => [k, v] as const)
AsyncStorage.multiSet(entries);
//                    ~~~~~~~
// Argument of type '(readonly [string, string])[]' is not assignable to parameter of type '[string, string][]'.
//  The type 'readonly [string, string]' is 'readonly' and cannot be assigned to the mutable type '[string, string]'