-
-
Notifications
You must be signed in to change notification settings - Fork 571
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
feat: add IsXLiteral
types
#563
feat: add IsXLiteral
types
#563
Conversation
Thinking about it some more, I’m not sure if there’s even really a reason to check for |
See https://github.com/sindresorhus/type-fest/pull/562/files#diff-e50dff1575d9cd1e723da9f89c4f438d9b5e9c3120d93a41a8139a2f869d05e4R1 for inspiration for docs comments. |
Lets just drop |
Should the category be |
0eca438
to
04e690a
Compare
Had to force push because I committed on the wrong user. |
Currently, type IsLiteral<T extends Primitive> = // ... This means that testing types that aren't assignable to type ShouldBeFalse = IsLiteral<unknown>;
//=> Type 'unknown' does not satisfy the constraint 'Primitive'. The other |
Seems like these aren't being used as type guards either. The following errors at type CapitalizedString<T> = IsStringLiteral<T> extends true ? Capitalize<T> : string;
// (type parameter) T in type CapitalizedString<T>
// Type 'T' does not satisfy the constraint 'string'. ts(2344) Not sure what I'm doing wrong. |
Currently just missing examples for |
All types are now documented with examples. |
👍 And maybe also a new one: |
|
Makes it sound like it's a special type, not a type of type. Let's go with |
Looks great :) |
Closes #541, closes #339.
Adds types to check if a given type is a
Primitive
literal:IsLiteral
IsStringLiteral
IsNumericLiteral
IsBooleanLiteral
IsSymbolLiteral
IsNullLiteral
IsUndefinedLiteral
Marking as draft as I still need to add documentation comments to the types.
Info About Removed Types
I'm not sure if it's possible to check for
null
orundefined
literals without also allowing their values, e.g:Marking as draft as I still need to figure out the above issue and add documentation comments to the types. Currently the test cases for
_null
and_undefined
values are commented out.