File: nonPrimitiveNarrow.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 (47 lines) | stat: -rw-r--r-- 1,426 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
=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveNarrow.ts ===
class Narrow {
>Narrow : Symbol(Narrow, Decl(nonPrimitiveNarrow.ts, 0, 0))

    narrowed: boolean
>narrowed : Symbol(Narrow.narrowed, Decl(nonPrimitiveNarrow.ts, 0, 14))
}

var a: object
>a : Symbol(a, Decl(nonPrimitiveNarrow.ts, 4, 3))

if (a instanceof Narrow) {
>a : Symbol(a, Decl(nonPrimitiveNarrow.ts, 4, 3))
>Narrow : Symbol(Narrow, Decl(nonPrimitiveNarrow.ts, 0, 0))

    a.narrowed; // ok
>a.narrowed : Symbol(Narrow.narrowed, Decl(nonPrimitiveNarrow.ts, 0, 14))
>a : Symbol(a, Decl(nonPrimitiveNarrow.ts, 4, 3))
>narrowed : Symbol(Narrow.narrowed, Decl(nonPrimitiveNarrow.ts, 0, 14))

    a = 123; // error
>a : Symbol(a, Decl(nonPrimitiveNarrow.ts, 4, 3))
}

if (typeof a === 'number') {
>a : Symbol(a, Decl(nonPrimitiveNarrow.ts, 4, 3))

    a.toFixed(); // error, never
>a : Symbol(a, Decl(nonPrimitiveNarrow.ts, 4, 3))
}

var b: object | null
>b : Symbol(b, Decl(nonPrimitiveNarrow.ts, 15, 3))

if (typeof b === 'object') {
>b : Symbol(b, Decl(nonPrimitiveNarrow.ts, 15, 3))

   b.toString(); // ok, object | null
>b.toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))
>b : Symbol(b, Decl(nonPrimitiveNarrow.ts, 15, 3))
>toString : Symbol(Object.toString, Decl(lib.es5.d.ts, --, --))

} else {
   b.toString(); // error, never
>b : Symbol(b, Decl(nonPrimitiveNarrow.ts, 15, 3))
}