cf.completefrontend

ConceptMedium

Why does request(method) compile but request(other) doesn't?

The code
function request(method: "GET" | "POST", url: string) {  return `${method} ${url}`;} const method = "GET";let other = "GET"; request(method, "/users");request(other, "/users");

The answer

Answer it out loud first, the way you would in the interview. Then compare.

Checking your sign-in…