Subscribe on changes!

why not remove any and define a function type instead of T ?

avatar
Feb 25th 2021

What problem does this feature solve?

https://github.com/vuejs/vue-next/blob/4a965802e883107a2af00301a59fb7f403b6acf7/packages/shared/src/index.ts#L104-L110 simplify code and remove any

What does the proposed API look like?

type strFunc = (str: string) => string
const cacheStringFunction = (fn: strFunc ): strFunc => {
  const cache: Record<string, string> = Object.create(null)
  return ((str: string) => {
    const hit = cache[str]
    return hit || (cache[str] = fn(str))
  }) 
}
avatar
Feb 25th 2021

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server or StackOverflow.