DEV Community

Discussion on: Advanced TypeScript: reinventing lodash.get

Collapse
 
krumpet profile image
Ran Lottem

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']?