1
1
//// [thisTypeInFunctionsNegative.ts]
2
+ // @target es6
3
+
2
4
class C {
3
5
n : number ;
4
6
explicitThis ( this : this , m : number ) : number {
@@ -174,9 +176,13 @@ function initializer(this: C = new C()): number { return this.n; }
174
176
175
177
// can't name parameters 'this' in a lambda.
176
178
c . explicitProperty = ( this , m ) => m + this . n ;
179
+ const f2 = < T > (this: { n : number } , m: number) => m + this . n ;
180
+ const f3 = async ( this : { n : number } , m : number ) => m + this . n ;
181
+ const f4 = async < T > ( this : { n : number } , m : number ) => m + this . n ;
177
182
178
183
179
184
//// [thisTypeInFunctionsNegative.js]
185
+ // @target es6
180
186
var __extends = ( this && this . __extends ) || ( function ( ) {
181
187
var extendStatics = function ( d , b ) {
182
188
extendStatics = Object . setPrototypeOf ||
@@ -190,6 +196,41 @@ var __extends = (this && this.__extends) || (function () {
190
196
d . prototype = b === null ? Object . create ( b ) : ( __ . prototype = b . prototype , new __ ( ) ) ;
191
197
} ;
192
198
} ) ( ) ;
199
+ var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
200
+ return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
201
+ function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
202
+ function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
203
+ function step ( result ) { result . done ? resolve ( result . value ) : new P ( function ( resolve ) { resolve ( result . value ) ; } ) . then ( fulfilled , rejected ) ; }
204
+ step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
205
+ } ) ;
206
+ } ;
207
+ var __generator = ( this && this . __generator ) || function ( thisArg , body ) {
208
+ var _ = { label : 0 , sent : function ( ) { if ( t [ 0 ] & 1 ) throw t [ 1 ] ; return t [ 1 ] ; } , trys : [ ] , ops : [ ] } , f , y , t , g ;
209
+ return g = { next : verb ( 0 ) , "throw" : verb ( 1 ) , "return" : verb ( 2 ) } , typeof Symbol === "function" && ( g [ Symbol . iterator ] = function ( ) { return this ; } ) , g ;
210
+ function verb ( n ) { return function ( v ) { return step ( [ n , v ] ) ; } ; }
211
+ function step ( op ) {
212
+ if ( f ) throw new TypeError ( "Generator is already executing." ) ;
213
+ while ( _ ) try {
214
+ if ( f = 1 , y && ( t = op [ 0 ] & 2 ? y [ "return" ] : op [ 0 ] ? y [ "throw" ] || ( ( t = y [ "return" ] ) && t . call ( y ) , 0 ) : y . next ) && ! ( t = t . call ( y , op [ 1 ] ) ) . done ) return t ;
215
+ if ( y = 0 , t ) op = [ op [ 0 ] & 2 , t . value ] ;
216
+ switch ( op [ 0 ] ) {
217
+ case 0 : case 1 : t = op ; break ;
218
+ case 4 : _ . label ++ ; return { value : op [ 1 ] , done : false } ;
219
+ case 5 : _ . label ++ ; y = op [ 1 ] ; op = [ 0 ] ; continue ;
220
+ case 7 : op = _ . ops . pop ( ) ; _ . trys . pop ( ) ; continue ;
221
+ default :
222
+ if ( ! ( t = _ . trys , t = t . length > 0 && t [ t . length - 1 ] ) && ( op [ 0 ] === 6 || op [ 0 ] === 2 ) ) { _ = 0 ; continue ; }
223
+ if ( op [ 0 ] === 3 && ( ! t || ( op [ 1 ] > t [ 0 ] && op [ 1 ] < t [ 3 ] ) ) ) { _ . label = op [ 1 ] ; break ; }
224
+ if ( op [ 0 ] === 6 && _ . label < t [ 1 ] ) { _ . label = t [ 1 ] ; t = op ; break ; }
225
+ if ( t && _ . label < t [ 2 ] ) { _ . label = t [ 2 ] ; _ . ops . push ( op ) ; break ; }
226
+ if ( t [ 2 ] ) _ . ops . pop ( ) ;
227
+ _ . trys . pop ( ) ; continue ;
228
+ }
229
+ op = body . call ( thisArg , _ ) ;
230
+ } catch ( e ) { op = [ 6 , e ] ; y = 0 ; } finally { f = t = 0 ; }
231
+ if ( op [ 0 ] & 5 ) throw op [ 1 ] ; return { value : op [ 0 ] ? op [ 1 ] : void 0 , done : true } ;
232
+ }
233
+ } ;
193
234
var _this = this ;
194
235
var C = /** @class */ ( function ( ) {
195
236
function C ( ) {
@@ -360,5 +401,11 @@ number;
360
401
return this . n ;
361
402
}
362
403
// can't name parameters 'this' in a lambda.
363
- c . explicitProperty = ( this , m ) ;
364
- m + this . n ;
404
+ c . explicitProperty = function ( m ) { return m + _this . n ; } ;
405
+ var f2 = function ( m ) { return m + _this . n ; } ;
406
+ var f3 = function ( m ) { return __awaiter ( _this , void 0 , void 0 , function ( ) { return __generator ( this , function ( _a ) {
407
+ return [ 2 /*return*/ , m + this . n ] ;
408
+ } ) ; } ) ; } ;
409
+ var f4 = function ( m ) { return __awaiter ( _this , void 0 , void 0 , function ( ) { return __generator ( this , function ( _a ) {
410
+ return [ 2 /*return*/ , m + this . n ] ;
411
+ } ) ; } ) ; } ;
0 commit comments