Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve typescript definition (#28)
This commit improves the typescript definition of `hashValue()` by introducing a generic type argument and an explicit return type. This ensures that the inferred return type of the function matches the type of values in the provided `options` array. Before: ```ts const options1 = [1, 2, 3]; const options2 = ['a', 'b', 'c']; const options3 = ['a', 'b', 'c', 1, 2, 3]; const value1 = hashValue('str', options1); // tsc: type of `value1` is `unknown` const value2 = hashValue('str', options2); // tsc: type of `value2` is `unknown` const value3 = hashValue('str', options3); // tsc: type of `value3` is `unknown` ``` After: ```ts const options1 = [1, 2, 3]; const options2 = ['a', 'b', 'c']; const options3 = ['a', 'b', 'c', 1, 2, 3]; const value1 = hashValue('str', options1); // tsc: type of `value1` is `number` const value2 = hashValue('str', options2); // tsc: type of `value2` is `string` const value3 = hashValue('str', options3); // tsc: type of `value3` is `string | number` ```
- Loading branch information