Question #259

Author: admin
tags: TypeScript  
function getSomething(x: string): 5
function getSomething(x: number): 10
function getSomething(x: string | number): 5 | 10 {
  if (typeof x === 'string') return 5;
  if (typeof x === 'number') return 10;
  throw new Error('Wrong param');
}

const x = getSomething('abc');
What is the type of the x variable?
5
5 | 10
number
any
This TS code will not be compiled into JS code
Rate the difficulty of the question:
easyhard