I'm assuming I'm missing something because this feels like a basic type but I haven't figured out how I can replicate this functionality with the built in Utility types or any of the types in typefest.
It's basically just a type intersection with better error reporting.
A couple of examples of when this could be useful:
// Type-safe string union subset
type AllowedValues = 'foo' | 'bar' | 'baz';
// we get eager type errors if one of the values specified in
// this string union does not appear in AllowedValues.
type RestrictedAllowedValues = ExtendsFrom<AllowedValues, 'foo' | 'bar'>
// Constraining config value types
type ConfigKeys = 'blah' | 'blah2';
type AllowedValue = string | boolean | number;
type BaseConfig = {
[key in ConfigKeys]: AllowedValue
}
type Config = ExtendsFrom<BaseConfig, {
blah: string,
blah2: boolean,
}>
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too