Closed
Description
TypeScript Version: 2.2.2
Code
type Eg = { foo: string, bar: number }
type VariantRec<T> = {[K in keyof T]: { type: K, value: T[K] }}
type Alpha1 = VariantRec<Eg>[keyof Eg]
type VariantType<T> = VariantRec<T>[keyof T]
type Alpha2 = VariantType<Eg>
const assignable12: Alpha2 = null as Alpha1
const assignable21: Alpha1 = null as Alpha2
Expected behavior:
Types Alpha1
and Alpha2
should be the identical.
Actual behavior:
Alpha2
incorrectly becomes: { type: 'foo' | 'bar', value: string | number }
It should be: { type: 'foo', value: string } | { type: 'bar', value: number }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment