Open emmbm opened 1 week ago
Sounds useful, but the name is slightly confusing. The type extracts the inferred guard type, but a name like Predicate
makes it sound like it's for making predicates. Maybe something like GuardType
or ExtractGuard
?
I agree Predicate
is probably not the best naming, but I don't think derivatives of Guard
sound right either since the guard is technically the check, not it's resulting assertion. Maybe GuardedType
or just Guarded
?
This type would be similar to ReturnType
so maybe it should follow its naming.
Type description + examples
With typescript now supporting predicate inference for guard functions without the need for explicitly specifying a
is
clause, it could be interesting to provide a simple helper that allows to get the inferred predicate for any guard function.Ex.:
Type source
Search existing types and issues first
Upvote & Fund