@@ -2307,6 +2307,90 @@ interface Function {
2307
2307
/** Returns a string representation of this function. */
2308
2308
toString ( ) : string ;
2309
2309
}
2310
+
2311
+ /**
2312
+ * Extracts the type of the 'this' parameter of a function type, or 'unknown' if the function type has no 'this' parameter.
2313
+ */
2314
+ type ThisParameterType < T > = T extends ( this : infer U , ...args : never ) => any ? U : unknown ;
2315
+
2316
+ /**
2317
+ * Removes the 'this' parameter from a function type.
2318
+ */
2319
+ type OmitThisParameter < T > = unknown extends ThisParameterType < T > ? T : T extends ( ...args : infer A ) => infer R ? ( ...args : A ) => R : T ;
2320
+
2321
+ interface CallableFunction extends Function {
2322
+ /**
2323
+ * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
2324
+ * @param thisArg The object to be used as the this object.
2325
+ */
2326
+ apply < T , R > ( this : ( this : T ) => R , thisArg : T ) : R ;
2327
+
2328
+ /**
2329
+ * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
2330
+ * @param thisArg The object to be used as the this object.
2331
+ * @param args An array of argument values to be passed to the function.
2332
+ */
2333
+ apply < T , A extends any [ ] , R > ( this : ( this : T , ...args : A ) => R , thisArg : T , args : A ) : R ;
2334
+
2335
+ /**
2336
+ * Calls the function with the specified object as the this value and the specified rest arguments as the arguments.
2337
+ * @param thisArg The object to be used as the this object.
2338
+ * @param args Argument values to be passed to the function.
2339
+ */
2340
+ call < T , A extends any [ ] , R > ( this : ( this : T , ...args : A ) => R , thisArg : T , ...args : A ) : R ;
2341
+
2342
+ /**
2343
+ * For a given function, creates a bound function that has the same body as the original function.
2344
+ * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
2345
+ * @param thisArg The object to be used as the this object.
2346
+ */
2347
+ bind < T > ( this : T , thisArg : ThisParameterType < T > ) : OmitThisParameter < T > ;
2348
+
2349
+ /**
2350
+ * For a given function, creates a bound function that has the same body as the original function.
2351
+ * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
2352
+ * @param thisArg The object to be used as the this object.
2353
+ * @param args Arguments to bind to the parameters of the function.
2354
+ */
2355
+ bind < T , A extends any [ ] , B extends any [ ] , R > ( this : ( this : T , ...args : [ ...A , ...B ] ) => R , thisArg : T , ...args : A ) : ( ...args : B ) => R ;
2356
+ }
2357
+
2358
+ interface NewableFunction extends Function {
2359
+ /**
2360
+ * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
2361
+ * @param thisArg The object to be used as the this object.
2362
+ */
2363
+ apply < T > ( this : new ( ) => T , thisArg : T ) : void ;
2364
+ /**
2365
+ * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
2366
+ * @param thisArg The object to be used as the this object.
2367
+ * @param args An array of argument values to be passed to the function.
2368
+ */
2369
+ apply < T , A extends any [ ] > ( this : new ( ...args : A ) => T , thisArg : T , args : A ) : void ;
2370
+
2371
+ /**
2372
+ * Calls the function with the specified object as the this value and the specified rest arguments as the arguments.
2373
+ * @param thisArg The object to be used as the this object.
2374
+ * @param args Argument values to be passed to the function.
2375
+ */
2376
+ call < T , A extends any [ ] > ( this : new ( ...args : A ) => T , thisArg : T , ...args : A ) : void ;
2377
+
2378
+ /**
2379
+ * For a given function, creates a bound function that has the same body as the original function.
2380
+ * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
2381
+ * @param thisArg The object to be used as the this object.
2382
+ */
2383
+ bind < T > ( this : T , thisArg : any ) : T ;
2384
+
2385
+ /**
2386
+ * For a given function, creates a bound function that has the same body as the original function.
2387
+ * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
2388
+ * @param thisArg The object to be used as the this object.
2389
+ * @param args Arguments to bind to the parameters of the function.
2390
+ */
2391
+ bind < A extends any [ ] , B extends any [ ] , R > ( this : new ( ...args : [ ...A , ...B ] ) => R , thisArg : any , ...args : A ) : new ( ...args : B ) => R ;
2392
+ }
2393
+
2310
2394
interface IArguments { }
2311
2395
interface RegExp { }
2312
2396
0 commit comments