Skip to content

Commit 1a882a5

Browse files
committed
refactor(memoization): drop unused Result type parameter from MemoizeOptions
`MemoizeOptions<Args, _Result>` had a second type parameter that was declared but never referenced in the type body — the underscore prefix advertised "intentionally unused", but the parameter had no purpose and misled readers into thinking the options were result-type-aware. Callers (`Memoize` decorator, `memoize`, `memoizeAsync`) all passed their own `Result` generic through, which was silently discarded. Drop the parameter and update the three call sites. No runtime change; no API change for consumers who wrote `MemoizeOptions<[string]>` (the default `= unknown` covered them); consumers who explicitly wrote `MemoizeOptions<Args, Result>` need to drop the second argument. The type was public but the second parameter was never load-bearing for anyone.
1 parent fcea2c0 commit 1a882a5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/memoization.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const cacheRegistry: Array<() => void> = []
1313
/**
1414
* Options for memoization behavior.
1515
*/
16-
export type MemoizeOptions<Args extends unknown[], _Result = unknown> = {
16+
export type MemoizeOptions<Args extends unknown[]> = {
1717
/** Custom cache key generator (defaults to JSON.stringify) */
1818
keyGen?: (...args: Args) => string
1919
/** Maximum cache size (LRU eviction when exceeded) */
@@ -99,7 +99,7 @@ export function clearAllMemoizationCaches(): void {
9999
* }
100100
* }
101101
*/
102-
export function Memoize(options: MemoizeOptions<unknown[], unknown> = {}) {
102+
export function Memoize(options: MemoizeOptions<unknown[]> = {}) {
103103
return (
104104
_target: unknown,
105105
propertyKey: string,
@@ -137,7 +137,7 @@ export function Memoize(options: MemoizeOptions<unknown[], unknown> = {}) {
137137
*/
138138
export function memoize<Args extends unknown[], Result>(
139139
fn: (...args: Args) => Result,
140-
options: MemoizeOptions<Args, Result> = {},
140+
options: MemoizeOptions<Args> = {},
141141
): (...args: Args) => Result {
142142
const {
143143
keyGen = (...args) => defaultKeyGen(args),
@@ -244,7 +244,7 @@ export function memoize<Args extends unknown[], Result>(
244244
*/
245245
export function memoizeAsync<Args extends unknown[], Result>(
246246
fn: (...args: Args) => Promise<Result>,
247-
options: MemoizeOptions<Args, Result> = {},
247+
options: MemoizeOptions<Args> = {},
248248
): (...args: Args) => Promise<Result> {
249249
const {
250250
keyGen = (...args) => defaultKeyGen(args),

0 commit comments

Comments
 (0)