Skip to content
Advertisement

Use typescript to extract all element type(s) from array except first

Say I have the type

JavaScript

How could I extract the type 2 | boolean when the array could be of an unknown length?

Advertisement

Answer

You can infer all elements but first. Use spread tuple operator: ..., just like in plain javascript

JavaScript
Advertisement