Универсальные (динамические) типы

function dynamicReturn(i: number): any
{
    switch (i) {
        case 1:
            return 3.14
        case 2:
            return "any"
        case 3:
            return true
        default:
            return null
    }
}

let pi = dynamicReturn(1)
//pi is 3.14
let s = dynamicReturn(2)
//s is "any"
let b = dynamicReturn(3)
//b is True

console.log(`pi is ${pi}`)
console.log(`s is "${s}"`)
console.log(`b is ${b}`)