Discriminating typescript union by parameter that is a union itself
I have an object that can have multiple types that can be discriminated through the “type” property. I want to write a function that would take a type as a parameter and return correctly typed item or undefined, depending if the initial object is currently the correct type, as follows:
Union of tuples deconstruction in typescript
While rewriting an old JS file to TypeScript, I ran onto a problem with a function that is supposed to transform data from one format to another, as follows: