Microsoft/TypeScript
Type narrowing not working correctly with Uppercase<string> & Lowercase<string>
Aberta
#63.724 aberto em 6 de ago. de 2026
BugDomain: check: Control FlowHelp Wanted
Métricas do repositório
- Stars
- (108.860 estrelas)
- Métricas de merge de PR
- (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)
Description
🔎 Search Terms
"narrowing lowercase" "narrowing uppercase"
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about Common Bugs and Type System Behavior
⏯ Playground Link
💻 Code
let countryCode: "BE" | "LU" | "NL";
const prefix = "be".toUpperCase() as Uppercase<string>;
if (prefix === "BE" || prefix === "LU" || prefix === "NL") {
countryCode = prefix;
// ^
// Type 'Uppercase<string>' is not assignable to type '"BE" | "LU" | "NL"'.
// Type 'string' is not assignable to type '"BE" | "LU" | "NL"'.
}
🙁 Actual behavior
TypeScript cannot narrow down an Uppercase<string> or Lowercase<string> type after explicitly comparing against specific values.
🙂 Expected behavior
TypeScript should accept the code above as "BE" | "LU" | "NL" is strictly a sub-type of Uppercase<string>.
Additional information about the issue
No response