Use An Array Check For Type Narrowing
PreviousType Narrowing With Similarly Shaped ObjectsNextZero-Config Environments For Trying Out Types
Last updated
Was this helpful?
Last updated
Was this helpful?
If you are typing a concatenation function for melding two values together into a single array, you may end up with a function signature like this:
That first argument can be an individual value or an array of values. You'll need to handle both scenarios in the function implementation. Using the function as a type guard, you can check differentiate between those two cases.
This is a form of .