Motivated by the desire to model case-insensitive DOM attribute values, the idea is to create a builtin, perhaps called $CaseInsensitive, that would make the following possible:
const valid: $CaseInsensitive<"foo" | "bar"> = "Foo"; // OK
const invalid: $CaseInsensitive<"foo" | "bar"> = "baz"; // Error
I imagine this would also come with intrinsic understanding of constructs such as
let x: $CaseInsensitive<"foo" | "bar"> = /* ... */;
if (x.toLowerCase() === "foo") {
// ...
}
switch (x.toLowerCase()) {
case "foo":
// ...
case "bar":
// ...
}