Question #257

Author: admin
tags: TypeScript  
function getX(num: 1|2) {
  if (num === 1) return String(Math.random());
  if (num === 2) return Math.random();
  throw new Error('Wrong num');
}

const x = getX(1); // ??
What is the type of the x variable?
any
string
number
string | number
never
Rate the difficulty of the question:
easyhard