isFunction: difference with lodash
hi, isFunction in lodash is also working as "type guard", meaning that typescript knows that inside an if(isFunction(f)) then "f" is a function. This is not happening with 'es-toolkit/compat'.
I'm going to just replace it with typeof f === 'function', but you may want to consider it to get 100% compatibility.
Type guard works in my code, can you give your code please?
i must specify that i'm using typescript 4.9.5
import { MutableRefObject } from 'react'
type FunctionRef<T=HTMLElement> = (instance: (T | null)) => void
export function passRef<T=any>(el: T, ...refs: (MutableRefObject<T> | FunctionRef<T>)[]) {
for (const ref of refs)
if (_.isFunction(ref))
ref(el)
else if (ref)
ref.current = el
}
when i switch to es-toolkit, i get a typescript error on the "ref.current" line, saying it can be a function and thus doesn't have "current"
+1
Is there any plan to fix it?
This is fixed in the latest version of our library.