Type alias ProjectConstants<MCs, Map>

ProjectConstants<MCs, Map>: ShallowResolve<{ [ K in InferUntaggedUnion<MCs> | keyof Map]: K extends keyof Map & InferUntaggedUnion<MCs> ? Map[K] : never }>

Given a MappableConstants type and a type which uses the untagged constants' types of the first as keys, forces the latter to use ALL AND ONLY the untagged constants' types of the first as keys

Returns

The Map if it satisfies the requirement, otherwise a projection which uses the untagged constants' types of the first as keys but containing never as constansts's type for both extraneous properties (properties of Map missing as constants' types of MCs) and missing ones (constants' types of MCs missing in Map)

Example

ProjectConstants<
ConstantsWrapper<{ a: "A", b: "B" }, "tag">,
{ A: 1, B: 2 }
>

is

{ A: 1, B: 2 }

Example

ProjectConstants<
ConstantsWrapper<{ a: "A", b: "B" }, "tag">,
{ A: 1 }
>

results in an error because "B" is missing as key into the Map type

Example

ProjectConstants<
ConstantsWrapper<{ a: "A", b: "B" }, "tag">,
{ A: 1, B: 2, C: 3 }
>

results in an error because "C" is an extraneous key

Type Parameters

Generated using TypeDoc