Skip to content

Commit 2d270e6

Browse files
authored
🤖 Merge PR DefinitelyTyped#74791 [Gimloader] Update types to v1.12 by @TheLazySquid
1 parent 59dc879 commit 2d270e6

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

types/gimloader/gimloader-tests.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ api.UI.showModal(document.createElement("div"), {
6565

6666
api.requestReload();
6767
GL.net.gamemode; // $ExpectType string
68+
api.UI.forceReactUpdate();
6869
api.net.gamemode; // $ExpectType string
6970
api.net.onLoad((type, gamemode) => {});
7071
api.net.modifyFetchRequest("/path/*/thing", (options) => null);
@@ -87,6 +88,11 @@ api.patcher.after(object, "b", (thisVal, args, returnVal) => {
8788
});
8889
// @ts-expect-error
8990
api.patcher.after(object, "a", () => {});
91+
api.patcher.swap(object, "b", function(arg1, args2) {
92+
arg1; // $ExpectType number
93+
args2; // $ExpectType string
94+
return false;
95+
});
9096

9197
// Test commands
9298
api.commands.addCommand({

types/gimloader/index.d.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,7 @@ declare global {
22732273
immediate?: boolean,
22742274
): () => void;
22752275
onChange(callback: () => void): () => void;
2276+
onRemove(callback: () => void): () => void;
22762277
};
22772278
type CollectionSchema<T, K> = ColyseusMethods & {
22782279
onAdd(callback: (value: T, index: K) => void, immediate?: boolean): () => void;
@@ -2874,6 +2875,8 @@ declare global {
28742875
class BaseUIApi {
28752876
/** Shows a customizable modal to the user */
28762877
showModal(element: HTMLElement | React$1.ReactElement, options?: ModalOptions): void;
2878+
/** Forces Gimkit's react tree to fully rerender */
2879+
forceReactUpdate(): void;
28772880
/**
28782881
* Gimkit's notification object, only available when joining or playing a game
28792882
*
@@ -2960,6 +2963,8 @@ declare global {
29602963
) => boolean | void;
29612964

29622965
type PatcherInsteadCallback<T> = (thisVal: any, args: T extends BaseFunction ? Parameters<T> : any[]) => any;
2966+
2967+
type PatcherSwapCallback<T> = (...args: T extends BaseFunction ? Parameters<T> : any[]) => any;
29632968
class PatcherApi {
29642969
/**
29652970
* Runs a callback after a function on an object has been run
@@ -2992,6 +2997,16 @@ declare global {
29922997
method: K,
29932998
callback: PatcherInsteadCallback<O[K]>,
29942999
): () => void;
3000+
/**
3001+
* Replaces a function on an object with another function
3002+
* @returns A function to remove the patch
3003+
*/
3004+
swap<O extends object, K extends FunctionKeys<O>>(
3005+
id: string,
3006+
object: O,
3007+
method: K,
3008+
callback: PatcherSwapCallback<O[K]>,
3009+
): () => void;
29953010
/** Removes all patches with a given id */
29963011
unpatchAll(id: string): void;
29973012
}
@@ -3025,10 +3040,19 @@ declare global {
30253040
method: K,
30263041
callback: PatcherInsteadCallback<O[K]>,
30273042
): () => void;
3043+
/**
3044+
* Replaces a function on an object with another function
3045+
* @returns A function to remove the patch
3046+
*/
3047+
swap<O extends object, K extends FunctionKeys<O>>(
3048+
object: O,
3049+
method: K,
3050+
callback: PatcherSwapCallback<O[K]>,
3051+
): () => void;
30283052
}
30293053

30303054
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
3031-
type RunInScopeCallback = (code: string, run: (evalCode: string) => void) => true | void;
3055+
type RunInScopeCallback = (code: string, run: (evalCode: string) => any, initial: boolean) => true | void;
30323056

30333057
interface Exposer {
30343058
check?: string;

types/gimloader/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/gimloader",
4-
"version": "1.11.9999",
4+
"version": "1.12.9999",
55
"nonNpm": "conflict",
66
"nonNpmDescription": "Types for the Gimloader global variables",
77
"projects": [

0 commit comments

Comments
 (0)