-
-
Notifications
You must be signed in to change notification settings - Fork 572
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: IsStringLiteral
#541
Comments
What are some real-world use-cases for it? |
In one of my projects, I'm using a library like I already have this type util in my project, but I was wondering if other people in the community wanted to use it too. If you find it useful, feel free to add it to this awesome project! |
In Related, a better way to write this type would be: type IsStringLiteral<T> =
T extends string
? string extends T
? false
: true
: false; Would adding types to check for other literals be useful? E.g. import type {Primitive} from 'type-fest';
type IsLiteral<T extends Primitive> =
| IsStringLiteral<T>
| IsNumericLiteral<T>
| IsBooleanLiteral<T>
| IsSymbolLiteral<T>
// ... I'd be open to adding a PR. Other use cases of |
👍 It would make sense to do these too for completeness. |
This is now accepted. Pull request welcome. |
What do you think of adding a type that can say if a string is a string literal (like
'foo/bar'
) and not a regularstring
?The text was updated successfully, but these errors were encountered: