File: nonPrimitiveAssignError.types

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 (103 lines) | stat: -rw-r--r-- 1,476 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveAssignError.ts ===
var x = {};
>x : {}
>{} : {}

var y = {foo: "bar"};
>y : { foo: string; }
>{foo: "bar"} : { foo: string; }
>foo : string
>"bar" : "bar"

var a: object;
>a : object

x = a;
>x = a : object
>x : {}
>a : object

y = a; // expect error
>y = a : object
>y : { foo: string; }
>a : object

a = x;
>a = x : {}
>a : object
>x : {}

a = y;
>a = y : { foo: string; }
>a : object
>y : { foo: string; }

var n = 123;
>n : number
>123 : 123

var b = true;
>b : boolean
>true : true

var s = "fooo";
>s : string
>"fooo" : "fooo"

a = n; // expect error
>a = n : number
>a : object
>n : number

a = b; // expect error
>a = b : true
>a : object
>b : true

a = s; // expect error
>a = s : string
>a : object
>s : string

n = a; // expect error
>n = a : object
>n : number
>a : object

b = a; // expect error
>b = a : object
>b : boolean
>a : object

s = a; // expect error
>s = a : object
>s : string
>a : object

var numObj: Number = 123;
>numObj : Number
>123 : 123

var boolObj: Boolean = true;
>boolObj : Boolean
>true : true

var strObj: String = "string";
>strObj : String
>"string" : "string"

a = numObj; // ok
>a = numObj : Number
>a : object
>numObj : Number

a = boolObj; // ok
>a = boolObj : Boolean
>a : object
>boolObj : Boolean

a = strObj; // ok
>a = strObj : String
>a : object
>strObj : String