1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-15 11:11:51 +00:00

Bind this for method overriding JSDoc (#1352)

This commit is contained in:
Bagel03 2022-01-23 11:14:03 -05:00 committed by GitHub
parent 509c01f642
commit 8dcb5faf5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,12 @@ import { BaseHUDPart } from "../game/hud/base_hud_part";
* @typedef {{new(...args: any[]): any, prototype: any}} constructable * @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 {(...args: any[]) => any} F
* @template P * @template P
@ -400,7 +406,7 @@ export class ModInterface {
* @template {extendsPrams<P[M]>} O the method that will override the old one * @template {extendsPrams<P[M]>} O the method that will override the old one
* @param {C} classHandle * @param {C} classHandle
* @param {M} methodName * @param {M} methodName
* @param {beforePrams<O, P[M]>} override * @param {bindThis<beforePrams<O, P[M]>, InstanceType<C>>} override
*/ */
replaceMethod(classHandle, methodName, override) { replaceMethod(classHandle, methodName, override) {
const oldMethod = classHandle.prototype[methodName]; 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 * @template {extendsPrams<P[M]>} O the method that will run before the old one
* @param {C} classHandle * @param {C} classHandle
* @param {M} methodName * @param {M} methodName
* @param {O} executeBefore * @param {bindThis<O, InstanceType<C>>} executeBefore
*/ */
runBeforeMethod(classHandle, methodName, executeBefore) { runBeforeMethod(classHandle, methodName, executeBefore) {
const oldHandle = classHandle.prototype[methodName]; 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 * @template {extendsPrams<P[M]>} O the method that will run before the old one
* @param {C} classHandle * @param {C} classHandle
* @param {M} methodName * @param {M} methodName
* @param {O} executeAfter * @param {bindThis<O, InstanceType<C>>} executeAfter
*/ */
runAfterMethod(classHandle, methodName, executeAfter) { runAfterMethod(classHandle, methodName, executeAfter) {
const oldHandle = classHandle.prototype[methodName]; const oldHandle = classHandle.prototype[methodName];