Type alias ProjectTaggedConstants<MTCs, Map>

ProjectTaggedConstants<MTCs, Map>: ShallowResolve<{ [ K in RemoveTag<InferUnion<MTCs>> | keyof Map]: K extends keyof Map & RemoveTag<InferUnion<MTCs>> ? Map[K] : never }>

Given a record type containing only tagged PropertyKeys and a type which uses the untagged properties' types of the first as keys, forces the latter to use ALL AND ONLY the untagged properties' types of the first as keys

Returns

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

Example

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

is

{ A: 1, B: 2 }

Example

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

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

Example

ProjectTaggedConstants<
InferTaggedConstants<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