|
| 1 | +=== tests/cases/compiler/inferenceUnionOfObjectsMappedContextualType.ts === |
| 2 | +type Entity = { |
| 3 | +>Entity : Symbol(Entity, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 0, 0)) |
| 4 | + |
| 5 | + someDate: Date | null; |
| 6 | +>someDate : Symbol(someDate, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 0, 15)) |
| 7 | +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) |
| 8 | + |
| 9 | +} & ({ id: string; } | { id: number; }) |
| 10 | +>id : Symbol(id, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 2, 6)) |
| 11 | +>id : Symbol(id, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 2, 24)) |
| 12 | + |
| 13 | +type RowRendererMeta<TInput extends {}> = { |
| 14 | +>RowRendererMeta : Symbol(RowRendererMeta, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 2, 39)) |
| 15 | +>TInput : Symbol(TInput, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 4, 21)) |
| 16 | + |
| 17 | + [key in keyof TInput]: { key: key; caption: string; formatter?: (value: TInput[key]) => string; }; |
| 18 | +>key : Symbol(key, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 5, 5)) |
| 19 | +>TInput : Symbol(TInput, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 4, 21)) |
| 20 | +>key : Symbol(key, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 5, 28)) |
| 21 | +>key : Symbol(key, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 5, 5)) |
| 22 | +>caption : Symbol(caption, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 5, 38)) |
| 23 | +>formatter : Symbol(formatter, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 5, 55)) |
| 24 | +>value : Symbol(value, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 5, 69)) |
| 25 | +>TInput : Symbol(TInput, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 4, 21)) |
| 26 | +>key : Symbol(key, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 5, 5)) |
| 27 | +} |
| 28 | + |
| 29 | +type RowRenderer<TInput extends {}> = RowRendererMeta<TInput>[keyof RowRendererMeta<TInput>]; |
| 30 | +>RowRenderer : Symbol(RowRenderer, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 6, 1)) |
| 31 | +>TInput : Symbol(TInput, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 8, 17)) |
| 32 | +>RowRendererMeta : Symbol(RowRendererMeta, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 2, 39)) |
| 33 | +>TInput : Symbol(TInput, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 8, 17)) |
| 34 | +>RowRendererMeta : Symbol(RowRendererMeta, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 2, 39)) |
| 35 | +>TInput : Symbol(TInput, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 8, 17)) |
| 36 | + |
| 37 | +const test: RowRenderer<Entity> = { |
| 38 | +>test : Symbol(test, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 10, 5)) |
| 39 | +>RowRenderer : Symbol(RowRenderer, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 6, 1)) |
| 40 | +>Entity : Symbol(Entity, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 0, 0)) |
| 41 | + |
| 42 | + key: 'someDate', |
| 43 | +>key : Symbol(key, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 10, 35)) |
| 44 | + |
| 45 | + caption: 'My Date', |
| 46 | +>caption : Symbol(caption, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 11, 20)) |
| 47 | + |
| 48 | + formatter: (value) => value ? value.toString() : '-' // value: any |
| 49 | +>formatter : Symbol(formatter, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 12, 23)) |
| 50 | +>value : Symbol(value, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 13, 16)) |
| 51 | +>value : Symbol(value, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 13, 16)) |
| 52 | +>value.toString : Symbol(Date.toString, Decl(lib.es5.d.ts, --, --)) |
| 53 | +>value : Symbol(value, Decl(inferenceUnionOfObjectsMappedContextualType.ts, 13, 16)) |
| 54 | +>toString : Symbol(Date.toString, Decl(lib.es5.d.ts, --, --)) |
| 55 | +} |
| 56 | + |
0 commit comments