|
| 1 | +//// [tests/cases/compiler/variancePropagation.ts] //// |
| 2 | + |
| 3 | +=== variancePropagation.ts === |
| 4 | +// https://github.com/microsoft/TypeScript/issues/62606 |
| 5 | + |
| 6 | +interface DerivedTable<S extends { base: any; new: any }> { |
| 7 | +>DerivedTable : Symbol(DerivedTable, Decl(variancePropagation.ts, 0, 0)) |
| 8 | +>S : Symbol(S, Decl(variancePropagation.ts, 2, 23)) |
| 9 | +>base : Symbol(base, Decl(variancePropagation.ts, 2, 34)) |
| 10 | +>new : Symbol(new, Decl(variancePropagation.ts, 2, 45)) |
| 11 | + |
| 12 | + // Error disappears when these property declarations are reversed |
| 13 | + schema: S["base"] & S["new"] |
| 14 | +>schema : Symbol(DerivedTable.schema, Decl(variancePropagation.ts, 2, 59)) |
| 15 | +>S : Symbol(S, Decl(variancePropagation.ts, 2, 23)) |
| 16 | +>S : Symbol(S, Decl(variancePropagation.ts, 2, 23)) |
| 17 | + |
| 18 | + readonlySchema: Readonly<S["base"] & S["new"]> |
| 19 | +>readonlySchema : Symbol(DerivedTable.readonlySchema, Decl(variancePropagation.ts, 4, 32)) |
| 20 | +>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --)) |
| 21 | +>S : Symbol(S, Decl(variancePropagation.ts, 2, 23)) |
| 22 | +>S : Symbol(S, Decl(variancePropagation.ts, 2, 23)) |
| 23 | +} |
| 24 | + |
| 25 | +interface Base { baseProp: number; } |
| 26 | +>Base : Symbol(Base, Decl(variancePropagation.ts, 6, 1)) |
| 27 | +>baseProp : Symbol(Base.baseProp, Decl(variancePropagation.ts, 8, 16)) |
| 28 | + |
| 29 | +interface New { newProp: boolean; } |
| 30 | +>New : Symbol(New, Decl(variancePropagation.ts, 8, 36)) |
| 31 | +>newProp : Symbol(New.newProp, Decl(variancePropagation.ts, 9, 16)) |
| 32 | + |
| 33 | +declare const source: DerivedTable<{ base: Base, new: New }> |
| 34 | +>source : Symbol(source, Decl(variancePropagation.ts, 11, 13)) |
| 35 | +>DerivedTable : Symbol(DerivedTable, Decl(variancePropagation.ts, 0, 0)) |
| 36 | +>base : Symbol(base, Decl(variancePropagation.ts, 11, 36)) |
| 37 | +>Base : Symbol(Base, Decl(variancePropagation.ts, 6, 1)) |
| 38 | +>new : Symbol(new, Decl(variancePropagation.ts, 11, 48)) |
| 39 | +>New : Symbol(New, Decl(variancePropagation.ts, 8, 36)) |
| 40 | + |
| 41 | +const destination: DerivedTable<{ base: Base; new: New & Base }> = source; // Error |
| 42 | +>destination : Symbol(destination, Decl(variancePropagation.ts, 12, 5)) |
| 43 | +>DerivedTable : Symbol(DerivedTable, Decl(variancePropagation.ts, 0, 0)) |
| 44 | +>base : Symbol(base, Decl(variancePropagation.ts, 12, 33)) |
| 45 | +>Base : Symbol(Base, Decl(variancePropagation.ts, 6, 1)) |
| 46 | +>new : Symbol(new, Decl(variancePropagation.ts, 12, 45)) |
| 47 | +>New : Symbol(New, Decl(variancePropagation.ts, 8, 36)) |
| 48 | +>Base : Symbol(Base, Decl(variancePropagation.ts, 6, 1)) |
| 49 | +>source : Symbol(source, Decl(variancePropagation.ts, 11, 13)) |
| 50 | + |
0 commit comments