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
In v5, the cacheKey arguments were automatically typed based on the method signature. In v6, the cacheKey arguments extend unknown instead of getting them from the original function.
Example error:
constexample=mem((str: string,strArray: string[])=>{/* do stuff */},{// Typescript error on strArray: // TS2461: Type 'unknown' is not an array type.cacheKey: ([str,strArray])=>[str, ...strArray].join()// ^^^^^^^^^^^ <- Example error});
Workaround:
constexample=mem((str: string,strArray: string[])=>{/* do stuff */},{// Repeat the types of the arguments inside of [ ].cacheKey: ([str,strArray]: [string,string[]])=>[str, ...strArray].join()// ^^^^^^^^^^^^^^^^^^^^ <- Example workaround});
I'm not sure if this can be fixed using generics, so it might just be some documentation for those confused when upgrading.
The text was updated successfully, but these errors were encountered:
In v5, the cacheKey arguments were automatically typed based on the method signature. In v6, the cacheKey arguments extend
unknown
instead of getting them from the original function.Example error:
Workaround:
I'm not sure if this can be fixed using generics, so it might just be some documentation for those confused when upgrading.
The text was updated successfully, but these errors were encountered: