Skip to content

Commit 92c7359

Browse files
authored
🤖 Merge PR DefinitelyTyped#74648 [Gimloader] Add types for schema by @TheLazySquid
1 parent e2657f5 commit 92c7359

2 files changed

Lines changed: 344 additions & 67 deletions

File tree

types/gimloader/gimloader-tests.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ new GL(); // $ExpectType Api
2424
api.React; // $ExpectType typeof React
2525
api.UI; // $ExpectType Readonly<ScopedUIApi>
2626
api.hotkeys; // $ExpectType Readonly<ScopedHotkeysApi>
27-
api.libs; // $ExpectType Readonly<LibsApi>
27+
api.libs; // $ExpectType Readonly<ScopedLibsApi>
2828
api.net; // $ExpectType Readonly<ScopedNetApi>
2929
api.patcher; // $ExpectType Readonly<ScopedPatcherApi>
30-
api.plugins; // $ExpectType Readonly<PluginsApi>
30+
api.plugins; // $ExpectType Readonly<ScopedPluginsApi>
3131
api.rewriter; // $ExpectType Readonly<ScopedRewriterApi>
3232
api.storage; // $ExpectType Readonly<ScopedStorageApi>
3333
api.commands; // $ExpectType Readonly<ScopedCommandsApi>
@@ -64,8 +64,6 @@ api.UI.showModal(document.createElement("div"), {
6464
});
6565

6666
api.requestReload();
67-
api.patcher.before({}, "foo", () => {});
68-
api.patcher.before({}, "foo", () => true);
6967
GL.net.gamemode; // $ExpectType string
7068
api.net.gamemode; // $ExpectType string
7169
api.net.onLoad((type, gamemode) => {});
@@ -80,6 +78,17 @@ api.rewriter.exposeVar("App", {
8078
multiple: false,
8179
});
8280

81+
// Test patcher
82+
let object = { a: true, b: (arg1: number, arg2: string) => true };
83+
api.patcher.after(object, "b", (thisVal, args, returnVal) => {
84+
args[0]; // $ExpectType number
85+
args[1]; // $ExpectType string
86+
returnVal; // $ExpectType boolean
87+
});
88+
// @ts-expect-error
89+
api.patcher.after(object, "a", () => {});
90+
91+
// Test commands
8392
api.commands.addCommand({
8493
text: "test",
8594
hidden: () => false,
@@ -112,6 +121,7 @@ api.commands.addCommand({
112121

113122
api.commands.addCommand({ text: () => "something" }, () => {});
114123

124+
// Test stores
115125
GL.stores.phaser; // $ExpectType PhaserStore
116126
window.stores.phaser; // $ExpectType PhaserStore
117127
let worldManagerInstance!: Gimloader.Stores.WorldManager;
@@ -145,6 +155,13 @@ worldManager.physics.bodies.staticBodies; // $ExpectType Set<string>
145155
worldManager.devices.interactives.findClosestInteractiveDevice([], 0, 0); // $ExpectType Device | undefined
146156
worldManager.inGameTerrainBuilder.clearPreviewLayer();
147157

158+
// Test colyseus state
159+
api.net.state.characters["..."].x; // $ExpectType number
160+
api.net.state.characters.get("...")!.x; // $ExpectType number
161+
api.net.state.teams[0].characters[0]; // $ExpectType string
162+
api.net.state.mapSettings; // $ExpectType string
163+
164+
// Test settings
148165
api.settings.something;
149166
api.settings.somethingElse;
150167
api.settings.something = 123;

0 commit comments

Comments
 (0)