1// #22736 2declare class Write { 3 protected dummy: Write; 4} 5 6declare class Col<s, a> { 7 protected dummy: [Col<s, a>, s, a]; 8} 9 10declare class Table<Req, Def> { 11 protected dummy: [Table<Req, Def>, Req, Def]; 12} 13 14type MakeTable<T1 extends object, T2 extends object> = { 15 [P in keyof T1]: Col<Write, T1[P]>; 16} & { 17 [P in keyof T2]: Col<Write, T2[P]>; 18 }; 19 20declare class ConflictTarget<Cols> { 21 public static tableColumns<Cols>(cols: (keyof Cols)[]): ConflictTarget<Cols>; 22 protected dummy: [ConflictTarget<Cols>, Cols]; 23} 24 25 26 27const bookTable: Table<BookReq, BookDef> = null as any 28 29interface BookReq { 30 readonly title: string; 31 readonly serial: number; 32} 33 34interface BookDef { 35 readonly author: string; 36 readonly numPages: number | null; 37} 38 39 40function insertOnConflictDoNothing<Req extends object, Def extends object>(_table: Table<Req, Def>, _conflictTarget: ConflictTarget<Req & Def>): boolean { 41 throw new Error(); 42} 43 44function f() { 45 insertOnConflictDoNothing(bookTable, ConflictTarget.tableColumns(["serial"])); // <-- No error here; should use the type inferred for the return type of `tableColumns` 46} 47