You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { exampleA } from 'fileA'; //memoize.cache = WeakMap
import { exampleB } from 'fileB'; //memoize.cache = WeakMap
console.log(exampleB('this.will.throw.error')); // throws: Uncaught TypeError: Invalid value used as weak map key
fileD.ts:
import { exampleB } from 'fileB'; //memoize.cache = Map
import { exampleA } from 'fileA'; //memoize.cache = WeakMap
console.log(exampleB('this.will.not.throw.error')); // Note the inconsistent behavior of exampleB all due to the order of import
Observations based off the given files
Inconsistent cache type based off of order of import (fileC.ts vs fileD.ts)
Can create bugs by one location changing the global memoize.cache and break other locations
It has been a few years since #3319 was labeled as "wont fix".
Is there any reconsideration to actual add the ability pass the cache object type to
memoize
rather then setting it at a global level?Reasons to pass it in:
memoize.cache
Given the following files:
fileA.ts:
fileB.ts:
fileC.ts:
fileD.ts:
Observations based off the given files
fileC.ts
vsfileD.ts
)memoize.cache
and break other locationsThe text was updated successfully, but these errors were encountered: