mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-13 02:01:51 +00:00
Bind this for method overriding JSDoc (#1352)
This commit is contained in:
parent
509c01f642
commit
8dcb5faf5f
@ -31,6 +31,12 @@ import { BaseHUDPart } from "../game/hud/base_hud_part";
|
||||
* @typedef {{new(...args: any[]): any, prototype: any}} constructable
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template {(...args: any) => any} F The function
|
||||
* @template {object} T The value of this
|
||||
* @typedef {(this: T, ...args: Parameters<F>) => ReturnType<F>} bindThis
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template {(...args: any[]) => any} F
|
||||
* @template P
|
||||
@ -400,7 +406,7 @@ export class ModInterface {
|
||||
* @template {extendsPrams<P[M]>} O the method that will override the old one
|
||||
* @param {C} classHandle
|
||||
* @param {M} methodName
|
||||
* @param {beforePrams<O, P[M]>} override
|
||||
* @param {bindThis<beforePrams<O, P[M]>, InstanceType<C>>} override
|
||||
*/
|
||||
replaceMethod(classHandle, methodName, override) {
|
||||
const oldMethod = classHandle.prototype[methodName];
|
||||
@ -418,7 +424,7 @@ export class ModInterface {
|
||||
* @template {extendsPrams<P[M]>} O the method that will run before the old one
|
||||
* @param {C} classHandle
|
||||
* @param {M} methodName
|
||||
* @param {O} executeBefore
|
||||
* @param {bindThis<O, InstanceType<C>>} executeBefore
|
||||
*/
|
||||
runBeforeMethod(classHandle, methodName, executeBefore) {
|
||||
const oldHandle = classHandle.prototype[methodName];
|
||||
@ -437,7 +443,7 @@ export class ModInterface {
|
||||
* @template {extendsPrams<P[M]>} O the method that will run before the old one
|
||||
* @param {C} classHandle
|
||||
* @param {M} methodName
|
||||
* @param {O} executeAfter
|
||||
* @param {bindThis<O, InstanceType<C>>} executeAfter
|
||||
*/
|
||||
runAfterMethod(classHandle, methodName, executeAfter) {
|
||||
const oldHandle = classHandle.prototype[methodName];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user