function foo ( arg ) { if ( typeof arg === "string" ) { console . log ( arg . toUpperCase ( ) ) ; } } type Shape = { kind : "circle" ; radius : number ; } | { kind : "square" ; sideLength : number ; } ; function area ( shape ) { if ( shape . kind === "circle" ) { return Math . PI * shape . radius ** 2 ; } else { return shape . sideLength ** 2 ; } } function area2 ( shape ) { if ( shape . kind === "circle" ) { return Math . PI * shape . radius ** 2 ; } else { return shape . sideLength ** 2 ; } } function f ( x ) { const isString = typeof x === "string" ; const isNumber = typeof x === "number" ; const isStringOrNumber = isString || isNumber ; if ( isStringOrNumber ) { x ; } else { x ; } }