mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
131 lines
5.7 KiB
Plaintext
131 lines
5.7 KiB
Plaintext
//// [tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts] ////
|
|
|
|
=== assignmentCompatWithNumericIndexer2.ts ===
|
|
// Derived type indexer must be subtype of base type indexer
|
|
|
|
interface Base { foo: string; }
|
|
>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0))
|
|
>foo : Symbol(Base.foo, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 16))
|
|
|
|
interface Derived extends Base { bar: string; }
|
|
>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 31))
|
|
>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0))
|
|
>bar : Symbol(Derived.bar, Decl(assignmentCompatWithNumericIndexer2.ts, 3, 32))
|
|
|
|
interface Derived2 extends Derived { baz: string; }
|
|
>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer2.ts, 3, 47))
|
|
>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 31))
|
|
>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithNumericIndexer2.ts, 4, 36))
|
|
|
|
interface A {
|
|
>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer2.ts, 4, 51))
|
|
|
|
[x: number]: Base;
|
|
>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 7, 5))
|
|
>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0))
|
|
}
|
|
|
|
declare var a: A;
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 10, 11))
|
|
>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer2.ts, 4, 51))
|
|
|
|
declare var b: { [x: number]: Derived; }
|
|
>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 11, 11))
|
|
>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 11, 18))
|
|
>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 31))
|
|
|
|
a = b;
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 10, 11))
|
|
>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 11, 11))
|
|
|
|
b = a; // error
|
|
>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 11, 11))
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 10, 11))
|
|
|
|
declare var b2: { [x: number]: Derived2; }
|
|
>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 15, 11))
|
|
>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 15, 19))
|
|
>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer2.ts, 3, 47))
|
|
|
|
a = b2;
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 10, 11))
|
|
>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 15, 11))
|
|
|
|
b2 = a; // error
|
|
>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 15, 11))
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 10, 11))
|
|
|
|
namespace Generics {
|
|
>Generics : Symbol(Generics, Decl(assignmentCompatWithNumericIndexer2.ts, 17, 7))
|
|
|
|
interface A<T extends Base> {
|
|
>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer2.ts, 19, 20))
|
|
>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer2.ts, 20, 16))
|
|
>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0))
|
|
|
|
[x: number]: T;
|
|
>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 21, 9))
|
|
>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer2.ts, 20, 16))
|
|
}
|
|
|
|
interface B extends A<Base> {
|
|
>B : Symbol(B, Decl(assignmentCompatWithNumericIndexer2.ts, 22, 5))
|
|
>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer2.ts, 19, 20))
|
|
>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0))
|
|
|
|
[x: number]: Derived; // ok
|
|
>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 25, 9))
|
|
>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 31))
|
|
}
|
|
|
|
function foo<T extends Base>() {
|
|
>foo : Symbol(foo, Decl(assignmentCompatWithNumericIndexer2.ts, 26, 5))
|
|
>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer2.ts, 28, 17))
|
|
>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0))
|
|
|
|
var a!: A<T>;
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11))
|
|
>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer2.ts, 19, 20))
|
|
>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer2.ts, 28, 17))
|
|
|
|
var b!: { [x: number]: Derived; }
|
|
>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 30, 11))
|
|
>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 30, 19))
|
|
>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 31))
|
|
|
|
a = b; // error
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11))
|
|
>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 30, 11))
|
|
|
|
b = a; // error
|
|
>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 30, 11))
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11))
|
|
|
|
var b2!: { [x: number]: Derived2; }
|
|
>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 34, 11))
|
|
>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 34, 20))
|
|
>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer2.ts, 3, 47))
|
|
|
|
a = b2; // error
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11))
|
|
>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 34, 11))
|
|
|
|
b2 = a; // error
|
|
>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 34, 11))
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11))
|
|
|
|
var b3!: { [x: number]: T; }
|
|
>b3 : Symbol(b3, Decl(assignmentCompatWithNumericIndexer2.ts, 38, 11))
|
|
>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 38, 20))
|
|
>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer2.ts, 28, 17))
|
|
|
|
a = b3; // ok
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11))
|
|
>b3 : Symbol(b3, Decl(assignmentCompatWithNumericIndexer2.ts, 38, 11))
|
|
|
|
b3 = a; // ok
|
|
>b3 : Symbol(b3, Decl(assignmentCompatWithNumericIndexer2.ts, 38, 11))
|
|
>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11))
|
|
}
|
|
}
|