`EmptyArray` type
silverwind opened this issue · 2 comments
silverwind commented
There is EmptyObject
, and I think a EmptyArray
type for a strictly empty array would be useful.
One use case of empty array with React to avoid re-renders because of unstable default prop:
const defaultArr = [];
const Component = ({arr = defaultArr}) => arr.join(",");
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- The funding will be given to active contributors.
- Thank you in advance for helping prioritize & fund our backlog.
sindresorhus commented
You could do it with [] as const
, but it could be nice to have a type for this too, for discoverability.
We already have https://github.com/sindresorhus/type-fest/blob/main/source/non-empty-tuple.d.ts
silverwind commented
Yeah I guess this type would mostly be for completeness sake. I guess EmptyObject
has a reason for existence because of the mentioned problems surrounding the {}
type that []
hopefully doesn't have.