tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.ts(33,5): error TS2322: Type '{ type: T; localChannelId: string; }' is not assignable to type 'NewChannel | ChannelOfType>'. Type '{ type: T; localChannelId: string; }' is not assignable to type 'Pick | ChannelOfType, "type">'. Types of property 'type' are incompatible. Type 'T' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. Type '"text"' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. Type '"text"' is not assignable to type 'ChannelOfType["type"]'. Type 'T' is not assignable to type 'ChannelOfType["type"]'. Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"]'. Type '"text"' is not assignable to type 'ChannelOfType["type"]'. Type '"text"' is not assignable to type 'T & "text"'. Type 'T' is not assignable to type 'T & "text"'. Type '"text" | "email"' is not assignable to type 'T & "text"'. Type '"text"' is not assignable to type 'T & "text"'. Type '"text"' is not assignable to type 'T'. '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. Type 'T' is not assignable to type '"text"'. Type '"text" | "email"' is not assignable to type '"text"'. Type '"email"' is not assignable to type '"text"'. ==== tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.ts (1 errors) ==== interface TextChannel { id: string; type: 'text'; phoneNumber: string; } interface EmailChannel { id: string; type: 'email'; addres: string; } type Channel = TextChannel | EmailChannel; export type ChannelType = Channel extends { type: infer R } ? R : never; type Omit = Pick< T, ({ [P in keyof T]: P } & { [P in K]: never } & { [x: string]: never })[keyof T] >; type ChannelOfType = A extends { type: T } ? A : never; export type NewChannel = Pick & Partial> & { localChannelId: string }; export function makeNewChannel(type: T): NewChannel> { const localChannelId = `blahblahblah`; return { type, localChannelId }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ type: T; localChannelId: string; }' is not assignable to type 'NewChannel | ChannelOfType>'. !!! error TS2322: Type '{ type: T; localChannelId: string; }' is not assignable to type 'Pick | ChannelOfType, "type">'. !!! error TS2322: Types of property 'type' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. !!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. !!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. !!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType["type"]'. !!! error TS2322: Type 'T' is not assignable to type 'ChannelOfType["type"]'. !!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"]'. !!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType["type"]'. !!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. !!! error TS2322: Type 'T' is not assignable to type 'T & "text"'. !!! error TS2322: Type '"text" | "email"' is not assignable to type 'T & "text"'. !!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'. !!! error TS2322: Type '"text"' is not assignable to type 'T'. !!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. !!! error TS2322: Type 'T' is not assignable to type '"text"'. !!! error TS2322: Type '"text" | "email"' is not assignable to type '"text"'. !!! error TS2322: Type '"email"' is not assignable to type '"text"'. } const newTextChannel = makeNewChannel('text'); // This should work newTextChannel.phoneNumber = '613-555-1234'; const newTextChannel2 : NewChannel = makeNewChannel('text'); // Compare with this, which ofc works. newTextChannel2.phoneNumber = '613-555-1234';