Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I havesearched for related issues and found none that match my proposal.
- I have searched thecurrent rule list and found no rules that match my proposal.
- I haveread the FAQ and my problem is not listed.
Relevant Package
typescript-estree
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Description
Continuing from#6404 (comment): we've been talking off-and-on for ages now about adding a thin layer of caching around TypeScript's type checking APIs.
do we want to do a weakmap memo on these? Eg
functionmemoize<TNode,TRet>(fn:(node:TNode)=>TRet):(node:TNode)=>TRet{constcache=newWeakMap<TNode,TRet>();return(node)=>{constcachedRet=cache.get(node);if(cachedRet){returncachedRet;}constnewRet=fn(node);cachedRet=cache.set(node,newRet);returnnewRet;};}That would allow us to enforce that if two rules request the exact same node then we'll 100% use a fast path.
Doing a quick look at the implementation of
getTypeAtLocation
- it doesn't do any fast caching, so it does do a bunch of work.IDK if this sort of thing would actually save any real time though - would be worth a test. Maybe we can file an issue to look at this later?
Additional Info
This'll require performance testing. Does it actually speed things up? Does it cause out-of-memory issues on our repo? Let's find out!
Strong candidate for including in thev6
betas. I'd like to get real world user testing to make sure this doesn't explode anybody.