TypeScript basicsbeginner
A type is a note to your future self that the compiler checks — annotating what goes in and what comes out is where most of the value is, before any advanced feature.
GET /orders returns whatever shape is lying around, and sorts the stored queue in place while it is at it. Make the response type a promise the compiler checks, and return the orders oldest first without changing what is stored.
The response type is enforced, the orders come back oldest first, and the stored queue is untouched.
Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.
A type is a note to your future self that the compiler checks — annotating what goes in and what comes out is where most of the value is, before any advanced feature.
sort() and reverse() change the array you gave them, which is how a filter quietly reorders the caller's data — copy first, and the bug never exists.