Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: AssemblyScript/assemblyscript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.27.12
Choose a base ref
...
head repository: AssemblyScript/assemblyscript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.27.13
Choose a head ref
  • 1 commit
  • 2 files changed
  • 2 contributors

Commits on Oct 10, 2023

  1. fix: introduce CallableFunction and NewableFunction from typescript/l…

    …ib/lib.es5.d.ts (#2712)
    
    Co-authored-by: Xinquan XU <Xinquan.XU@partner.bmw.com>
    XMadrid and Xinquan XU authored Oct 10, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c22c078 View commit details
Showing with 85 additions and 0 deletions.
  1. +1 −0 NOTICE
  2. +84 −0 std/assembly/index.d.ts
1 change: 1 addition & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ under the licensing terms detailed in LICENSE:
* CountBleck <Mr.YouKnowWhoIAm@protonmail.com>
* Abdul Rauf <abdulraufmujahid@gmail.com>
* Bach Le <bach@bullno1.com>
* Xinquan Xu <xinquan0203@163.com>

Portions of this software are derived from third-party works licensed under
the following terms:
84 changes: 84 additions & 0 deletions std/assembly/index.d.ts
Original file line number Diff line number Diff line change
@@ -2307,6 +2307,90 @@ interface Function {
/** Returns a string representation of this function. */
toString(): string;
}

/**
* Extracts the type of the 'this' parameter of a function type, or 'unknown' if the function type has no 'this' parameter.
*/
type ThisParameterType<T> = T extends (this: infer U, ...args: never) => any ? U : unknown;

/**
* Removes the 'this' parameter from a function type.
*/
type OmitThisParameter<T> = unknown extends ThisParameterType<T> ? T : T extends (...args: infer A) => infer R ? (...args: A) => R : T;

interface CallableFunction extends Function {
/**
* Calls the function with the specified object as the this value and the elements of specified array as the arguments.
* @param thisArg The object to be used as the this object.
*/
apply<T, R>(this: (this: T) => R, thisArg: T): R;

/**
* Calls the function with the specified object as the this value and the elements of specified array as the arguments.
* @param thisArg The object to be used as the this object.
* @param args An array of argument values to be passed to the function.
*/
apply<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R;

/**
* Calls the function with the specified object as the this value and the specified rest arguments as the arguments.
* @param thisArg The object to be used as the this object.
* @param args Argument values to be passed to the function.
*/
call<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, ...args: A): R;

/**
* For a given function, creates a bound function that has the same body as the original function.
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
* @param thisArg The object to be used as the this object.
*/
bind<T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;

/**
* For a given function, creates a bound function that has the same body as the original function.
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
* @param thisArg The object to be used as the this object.
* @param args Arguments to bind to the parameters of the function.
*/
bind<T, A extends any[], B extends any[], R>(this: (this: T, ...args: [...A, ...B]) => R, thisArg: T, ...args: A): (...args: B) => R;
}

interface NewableFunction extends Function {
/**
* Calls the function with the specified object as the this value and the elements of specified array as the arguments.
* @param thisArg The object to be used as the this object.
*/
apply<T>(this: new () => T, thisArg: T): void;
/**
* Calls the function with the specified object as the this value and the elements of specified array as the arguments.
* @param thisArg The object to be used as the this object.
* @param args An array of argument values to be passed to the function.
*/
apply<T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void;

/**
* Calls the function with the specified object as the this value and the specified rest arguments as the arguments.
* @param thisArg The object to be used as the this object.
* @param args Argument values to be passed to the function.
*/
call<T, A extends any[]>(this: new (...args: A) => T, thisArg: T, ...args: A): void;

/**
* For a given function, creates a bound function that has the same body as the original function.
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
* @param thisArg The object to be used as the this object.
*/
bind<T>(this: T, thisArg: any): T;

/**
* For a given function, creates a bound function that has the same body as the original function.
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
* @param thisArg The object to be used as the this object.
* @param args Arguments to bind to the parameters of the function.
*/
bind<A extends any[], B extends any[], R>(this: new (...args: [...A, ...B]) => R, thisArg: any, ...args: A): new (...args: B) => R;
}

interface IArguments {}
interface RegExp {}