Difficulty: 5/10union types, function overloads, type guardsA TypeScript function can take in parameters of multiple, predefined types using union types.javascriptCopyScenario Questions0-2 years experience1We have a utility function `formatValue` that should accept either a string or a number and return a string. How would you write its TypeScript signature?2If you call `formatValue(true)`, what error does TypeScript give and why?2-5 years experience1You need to implement a `parseInput` function that can take either a JSON string, a Buffer, or an object conforming to an interface `User`. How would you type its parameter and ensure correct handling inside the function?Follow-up QuestionsWhat would happen if you later needed to support a boolean type?How does your approach affect IDE autocomplete for callers?Can you describe how you’d test that the type guards work as intended?Suggest Improvement