HardPro challengeJavaScriptTypeScript

Conditional Types & infer (TypeScript)

TypeScriptTypesConditional Types

Implement these TypeScript utility types:

1. ReturnType<F> — extract the return type of a function.
2. Flatten<T> — if T is an array, return its element type; otherwise T.
3. Awaited<T> — unwrap a Promise<T> to T (one level).

Then implement solve(input) which validates the types at runtime.

Sample tests

Test #1Type labels for string, number, boolean
Input: [["hello",42,true]]
Output: "string-number-boolean"
Test #2Different values, same types
Input: [["world",0,false]]
Output: "string-number-boolean"
Test #3Empty string, 1, true
Input: [["",1,true]]
Output: "string-number-boolean"
Test #4Verify consistent type labeling
Input: [["ts",99,false]]
Output: "string-number-boolean"
Test #5Negative number
Input: [["x",-1,true]]
Output: "string-number-boolean"