File: getSetAccessorContextualTyping.symbols

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (48 lines) | stat: -rw-r--r-- 1,991 bytes parent folder | download | duplicates (5)
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
=== tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts ===
// In the body of a get accessor with no return type annotation,
// if a matching set accessor exists and that set accessor has a parameter type annotation,
// return expressions are contextually typed by the type given in the set accessor's parameter type annotation.

class C {
>C : Symbol(C, Decl(getSetAccessorContextualTyping.ts, 0, 0))

    set X(x: number) { }
>X : Symbol(C.X, Decl(getSetAccessorContextualTyping.ts, 4, 9), Decl(getSetAccessorContextualTyping.ts, 5, 24))
>x : Symbol(x, Decl(getSetAccessorContextualTyping.ts, 5, 10))

    get X() {
>X : Symbol(C.X, Decl(getSetAccessorContextualTyping.ts, 4, 9), Decl(getSetAccessorContextualTyping.ts, 5, 24))

        return "string";  // Error; get contextual type by set accessor parameter type annotation
    }

    set Y(y) { }
>Y : Symbol(C.Y, Decl(getSetAccessorContextualTyping.ts, 8, 5), Decl(getSetAccessorContextualTyping.ts, 10, 16))
>y : Symbol(y, Decl(getSetAccessorContextualTyping.ts, 10, 10))

    get Y() {
>Y : Symbol(C.Y, Decl(getSetAccessorContextualTyping.ts, 8, 5), Decl(getSetAccessorContextualTyping.ts, 10, 16))

        return true;
    }

    set W(w) { }
>W : Symbol(C.W, Decl(getSetAccessorContextualTyping.ts, 13, 5), Decl(getSetAccessorContextualTyping.ts, 15, 16))
>w : Symbol(w, Decl(getSetAccessorContextualTyping.ts, 15, 10))

    get W(): boolean {
>W : Symbol(C.W, Decl(getSetAccessorContextualTyping.ts, 13, 5), Decl(getSetAccessorContextualTyping.ts, 15, 16))

        return true;
    }

    set Z(z: number) { }
>Z : Symbol(C.Z, Decl(getSetAccessorContextualTyping.ts, 18, 5), Decl(getSetAccessorContextualTyping.ts, 20, 24))
>z : Symbol(z, Decl(getSetAccessorContextualTyping.ts, 20, 10))

    get Z() {
>Z : Symbol(C.Z, Decl(getSetAccessorContextualTyping.ts, 18, 5), Decl(getSetAccessorContextualTyping.ts, 20, 24))

        return 1;
    }
}