TS4138: Rest element must be last in tuple type
Error message
A rest element must be last in a tuple type.
Quick summary
In a tuple type, the rest element (...) can only appear as the last element.
Why this happens
Rest element not at the end of a tuple type
Incorrect tuple type syntax
Minimal example
✗ Broken code
type Bad = [string, ...number[], boolean]; // TS4138✓ Fixed code
type Good = [string, boolean, ...number[]]; // ✅ rest at endMove the rest element to the end of the tuple type.
How to diagnose
Check the tuple type definition
Find the rest element and verify it's at the end
How to fix
Move the rest element to the end of the tuple
Restructure the tuple type