Conditional types with Generics in TypeScript
问题 What I want to achieve can be best explained in code: Given shoe and dress class: class Shoe { constructor(public size: number){} } class Dress { constructor(public style: string){} } Have a generic box that can only contain Shoe or Dress. Can't contain both: class Box <T extends Shoe | Dress > { } Then have a utility class that takes care of moving shoes: class ShoeMover { constructor(public size: number[]){} } Also, a utility class for moving Dresses: class DressPacker { constructor(public