Typescript: Why is the result of the "typeof" operator correctly compared with literals and incorrectly with constants?
function foo(param: string) { }
const s = 'string';
function test(param: string | number) {
if (typeof (param) == 'string') foo(param); // ok
if (typeof (param) == s) foo(param); // error
}
Error message: "Argument of type 'string | number' is not assignable to parameter of type 'string'. Type 'number' is not assignable to type 'string'."