File: baseIndexSignatureResolution.symbols

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (49 lines) | stat: -rw-r--r-- 1,971 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
=== tests/cases/compiler/baseIndexSignatureResolution.ts ===
class Base { private a: string; }
>Base : Symbol(Base, Decl(baseIndexSignatureResolution.ts, 0, 0))
>a : Symbol(Base.a, Decl(baseIndexSignatureResolution.ts, 0, 12))

class Derived extends Base { private b: string; }
>Derived : Symbol(Derived, Decl(baseIndexSignatureResolution.ts, 0, 33))
>Base : Symbol(Base, Decl(baseIndexSignatureResolution.ts, 0, 0))
>b : Symbol(Derived.b, Decl(baseIndexSignatureResolution.ts, 1, 28))

// Note - commmenting "extends Foo" prevents the error
interface Foo {
>Foo : Symbol(Foo, Decl(baseIndexSignatureResolution.ts, 1, 49))

    [i: number]: Base;
>i : Symbol(i, Decl(baseIndexSignatureResolution.ts, 5, 5))
>Base : Symbol(Base, Decl(baseIndexSignatureResolution.ts, 0, 0))
}
interface FooOf<TBase extends Base> extends Foo {
>FooOf : Symbol(FooOf, Decl(baseIndexSignatureResolution.ts, 6, 1))
>TBase : Symbol(TBase, Decl(baseIndexSignatureResolution.ts, 7, 16))
>Base : Symbol(Base, Decl(baseIndexSignatureResolution.ts, 0, 0))
>Foo : Symbol(Foo, Decl(baseIndexSignatureResolution.ts, 1, 49))

    [i: number]: TBase;
>i : Symbol(i, Decl(baseIndexSignatureResolution.ts, 8, 5))
>TBase : Symbol(TBase, Decl(baseIndexSignatureResolution.ts, 7, 16))
}
var x: FooOf<Derived> = null;
>x : Symbol(x, Decl(baseIndexSignatureResolution.ts, 10, 3))
>FooOf : Symbol(FooOf, Decl(baseIndexSignatureResolution.ts, 6, 1))
>Derived : Symbol(Derived, Decl(baseIndexSignatureResolution.ts, 0, 33))

var y: Derived = x[0];
>y : Symbol(y, Decl(baseIndexSignatureResolution.ts, 11, 3))
>Derived : Symbol(Derived, Decl(baseIndexSignatureResolution.ts, 0, 33))
>x : Symbol(x, Decl(baseIndexSignatureResolution.ts, 10, 3))

/*
// Note - the equivalent for normal interface methods works fine:
interface A {
    foo(): Base;
}
interface B<TBase extends Base> extends A {
    foo(): TBase;
}
var b: B<Derived> = null;
var z: Derived = b.foo();
*/