File tree 1 file changed +51
-3
lines changed
tests/cases/conformance/types/thisType 1 file changed +51
-3
lines changed Original file line number Diff line number Diff line change 1
1
// @declaration : true
2
- // @strictNullChecks : true
3
- // @noImplicitAny : true
4
- // @noImplicitThis : true
2
+ // @strict : true
5
3
// @target : es5
6
4
7
5
// In methods of an object literal with no contextual type, 'this' has the type
@@ -51,6 +49,42 @@ let p1: Point = {
51
49
}
52
50
} ;
53
51
52
+ let p2 : Point | null = {
53
+ x : 10 ,
54
+ y : 20 ,
55
+ moveBy ( dx , dy , dz ) {
56
+ this . x += dx ;
57
+ this . y += dy ;
58
+ if ( this . z && dz ) {
59
+ this . z += dz ;
60
+ }
61
+ }
62
+ } ;
63
+
64
+ let p3 : Point | undefined = {
65
+ x : 10 ,
66
+ y : 20 ,
67
+ moveBy ( dx , dy , dz ) {
68
+ this . x += dx ;
69
+ this . y += dy ;
70
+ if ( this . z && dz ) {
71
+ this . z += dz ;
72
+ }
73
+ }
74
+ } ;
75
+
76
+ let p4 : Point | null | undefined = {
77
+ x : 10 ,
78
+ y : 20 ,
79
+ moveBy ( dx , dy , dz ) {
80
+ this . x += dx ;
81
+ this . y += dy ;
82
+ if ( this . z && dz ) {
83
+ this . z += dz ;
84
+ }
85
+ }
86
+ } ;
87
+
54
88
declare function f1 ( p : Point ) : void ;
55
89
56
90
f1 ( {
65
99
}
66
100
} ) ;
67
101
102
+ declare function f2 ( p : Point | null | undefined ) : void ;
103
+
104
+ f2 ( {
105
+ x : 10 ,
106
+ y : 20 ,
107
+ moveBy ( dx , dy , dz ) {
108
+ this . x += dx ;
109
+ this . y += dy ;
110
+ if ( this . z && dz ) {
111
+ this . z += dz ;
112
+ }
113
+ }
114
+ } ) ;
115
+
68
116
// In methods of an object literal with a contextual type that includes some
69
117
// ThisType<T>, 'this' is of type T.
70
118
You can’t perform that action at this time.
0 commit comments