@@ -47,6 +47,42 @@ let p1: Point = {
47
47
}
48
48
} ;
49
49
50
+ let p2 : Point | null = {
51
+ x : 10 ,
52
+ y : 20 ,
53
+ moveBy ( dx , dy , dz ) {
54
+ this . x += dx ;
55
+ this . y += dy ;
56
+ if ( this . z && dz ) {
57
+ this . z += dz ;
58
+ }
59
+ }
60
+ } ;
61
+
62
+ let p3 : Point | undefined = {
63
+ x : 10 ,
64
+ y : 20 ,
65
+ moveBy ( dx , dy , dz ) {
66
+ this . x += dx ;
67
+ this . y += dy ;
68
+ if ( this . z && dz ) {
69
+ this . z += dz ;
70
+ }
71
+ }
72
+ } ;
73
+
74
+ let p4 : Point | null | undefined = {
75
+ x : 10 ,
76
+ y : 20 ,
77
+ moveBy ( dx , dy , dz ) {
78
+ this . x += dx ;
79
+ this . y += dy ;
80
+ if ( this . z && dz ) {
81
+ this . z += dz ;
82
+ }
83
+ }
84
+ } ;
85
+
50
86
declare function f1 ( p : Point ) : void ;
51
87
52
88
f1 ( {
61
97
}
62
98
} ) ;
63
99
100
+ declare function f2 ( p : Point | null | undefined ) : void ;
101
+
102
+ f2 ( {
103
+ x : 10 ,
104
+ y : 20 ,
105
+ moveBy ( dx , dy , dz ) {
106
+ this . x += dx ;
107
+ this . y += dy ;
108
+ if ( this . z && dz ) {
109
+ this . z += dz ;
110
+ }
111
+ }
112
+ } ) ;
113
+
64
114
// In methods of an object literal with a contextual type that includes some
65
115
// ThisType<T>, 'this' is of type T.
66
116
@@ -196,6 +246,7 @@ vue.hello;
196
246
//// [thisTypeInObjectLiterals2.js]
197
247
// In methods of an object literal with no contextual type, 'this' has the type
198
248
// of the object literal.
249
+ "use strict ";
199
250
var obj1 = {
200
251
a : 1 ,
201
252
f : function ( ) {
@@ -228,6 +279,39 @@ var p1 = {
228
279
}
229
280
}
230
281
} ;
282
+ var p2 = {
283
+ x : 10 ,
284
+ y : 20 ,
285
+ moveBy : function ( dx , dy , dz ) {
286
+ this . x += dx ;
287
+ this . y += dy ;
288
+ if ( this . z && dz ) {
289
+ this . z += dz ;
290
+ }
291
+ }
292
+ } ;
293
+ var p3 = {
294
+ x : 10 ,
295
+ y : 20 ,
296
+ moveBy : function ( dx , dy , dz ) {
297
+ this . x += dx ;
298
+ this . y += dy ;
299
+ if ( this . z && dz ) {
300
+ this . z += dz ;
301
+ }
302
+ }
303
+ } ;
304
+ var p4 = {
305
+ x : 10 ,
306
+ y : 20 ,
307
+ moveBy : function ( dx , dy , dz ) {
308
+ this . x += dx ;
309
+ this . y += dy ;
310
+ if ( this . z && dz ) {
311
+ this . z += dz ;
312
+ }
313
+ }
314
+ } ;
231
315
f1 ( {
232
316
x : 10 ,
233
317
y : 20 ,
@@ -239,6 +323,17 @@ f1({
239
323
}
240
324
}
241
325
} ) ;
326
+ f2 ( {
327
+ x : 10 ,
328
+ y : 20 ,
329
+ moveBy : function ( dx , dy , dz ) {
330
+ this . x += dx ;
331
+ this . y += dy ;
332
+ if ( this . z && dz ) {
333
+ this . z += dz ;
334
+ }
335
+ }
336
+ } ) ;
242
337
var x1 = makeObject ( {
243
338
data : { x : 0 , y : 0 } ,
244
339
methods : {
@@ -328,7 +423,11 @@ declare type Point = {
328
423
moveBy ( dx : number , dy : number , dz ? : number ) : void ;
329
424
} ;
330
425
declare let p1 : Point ;
426
+ declare let p2 : Point | null ;
427
+ declare let p3 : Point | undefined ;
428
+ declare let p4 : Point | null | undefined ;
331
429
declare function f1 ( p : Point ) : void ;
430
+ declare function f2 ( p : Point | null | undefined ) : void ;
332
431
declare type ObjectDescriptor < D , M > = {
333
432
data ?: D ;
334
433
methods ?: M & ThisType < D & M > ;
0 commit comments