File: thisTypeInFunctions4.symbols

package info (click to toggle)
node-typescript 5.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 497,488 kB
  • sloc: javascript: 2,107,274; makefile: 6; sh: 1
file content (49 lines) | stat: -rw-r--r-- 2,216 bytes parent folder | download
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/conformance/types/thisType/thisTypeInFunctions4.ts] ////

=== thisTypeInFunctions4.ts ===
type WrongObject = {value: number};
>WrongObject : Symbol(WrongObject, Decl(thisTypeInFunctions4.ts, 0, 0))
>value : Symbol(value, Decl(thisTypeInFunctions4.ts, 0, 20))

type CorrectObject = {name: string};
>CorrectObject : Symbol(CorrectObject, Decl(thisTypeInFunctions4.ts, 0, 35))
>name : Symbol(name, Decl(thisTypeInFunctions4.ts, 1, 22))

declare function isCorrect(obj: any): obj is CorrectObject
>isCorrect : Symbol(isCorrect, Decl(thisTypeInFunctions4.ts, 1, 36))
>obj : Symbol(obj, Decl(thisTypeInFunctions4.ts, 3, 27))
>obj : Symbol(obj, Decl(thisTypeInFunctions4.ts, 3, 27))
>CorrectObject : Symbol(CorrectObject, Decl(thisTypeInFunctions4.ts, 0, 35))

declare function callsCallback(cb: (name: string)=>void)
>callsCallback : Symbol(callsCallback, Decl(thisTypeInFunctions4.ts, 3, 58))
>cb : Symbol(cb, Decl(thisTypeInFunctions4.ts, 5, 31))
>name : Symbol(name, Decl(thisTypeInFunctions4.ts, 5, 36))

function problemFunction(this: CorrectObject | WrongObject): void {
>problemFunction : Symbol(problemFunction, Decl(thisTypeInFunctions4.ts, 5, 56))
>this : Symbol(this, Decl(thisTypeInFunctions4.ts, 7, 25))
>CorrectObject : Symbol(CorrectObject, Decl(thisTypeInFunctions4.ts, 0, 35))
>WrongObject : Symbol(WrongObject, Decl(thisTypeInFunctions4.ts, 0, 0))

    //check type
    if (!isCorrect(this)) return;
>isCorrect : Symbol(isCorrect, Decl(thisTypeInFunctions4.ts, 1, 36))
>this : Symbol(this, Decl(thisTypeInFunctions4.ts, 7, 25))

    callsCallback((name)=>{
>callsCallback : Symbol(callsCallback, Decl(thisTypeInFunctions4.ts, 3, 58))
>name : Symbol(name, Decl(thisTypeInFunctions4.ts, 11, 19))

        this.name = name; //should not error
>this.name : Symbol(name, Decl(thisTypeInFunctions4.ts, 1, 22))
>this : Symbol(this, Decl(thisTypeInFunctions4.ts, 7, 25))
>name : Symbol(name, Decl(thisTypeInFunctions4.ts, 1, 22))
>name : Symbol(name, Decl(thisTypeInFunctions4.ts, 11, 19))

        type T = typeof this;
>T : Symbol(T, Decl(thisTypeInFunctions4.ts, 12, 25))
>this : Symbol(this, Decl(thisTypeInFunctions4.ts, 7, 25))

    });
}