Great read!
To tell arrays apart from tuples - arrays have a length property of type 'number' whereas for a tuple the length property is a specific number. After checking that T is either an array or a tuple (using T extends unknown[], maybe?), it should be possible to tell them apart using number extends T['length']?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great read!
To tell arrays apart from tuples - arrays have a
length
property of type 'number' whereas for a tuple the length property is a specific number. After checking that T is either an array or a tuple (usingT extends unknown[]
, maybe?), it should be possible to tell them apart usingnumber extends T['length']?