Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Builtin for case-insensitive literals and unions #6743

Closed
motiz88 opened this issue Aug 15, 2018 · 0 comments
Closed

Feature request: Builtin for case-insensitive literals and unions #6743

motiz88 opened this issue Aug 15, 2018 · 0 comments

Comments

@motiz88
Copy link
Contributor

motiz88 commented Aug 15, 2018

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":
// ...
}
@SamChou19815 SamChou19815 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants