Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions types/gimloader/gimloader-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ new GL(); // $ExpectType Api
api.React; // $ExpectType typeof React
api.UI; // $ExpectType Readonly<ScopedUIApi>
api.hotkeys; // $ExpectType Readonly<ScopedHotkeysApi>
api.libs; // $ExpectType Readonly<LibsApi>
api.libs; // $ExpectType Readonly<ScopedLibsApi>
api.net; // $ExpectType Readonly<ScopedNetApi>
api.patcher; // $ExpectType Readonly<ScopedPatcherApi>
api.plugins; // $ExpectType Readonly<PluginsApi>
api.plugins; // $ExpectType Readonly<ScopedPluginsApi>
api.rewriter; // $ExpectType Readonly<ScopedRewriterApi>
api.storage; // $ExpectType Readonly<ScopedStorageApi>
api.commands; // $ExpectType Readonly<ScopedCommandsApi>
Expand Down Expand Up @@ -64,8 +64,6 @@ api.UI.showModal(document.createElement("div"), {
});

api.requestReload();
api.patcher.before({}, "foo", () => {});
api.patcher.before({}, "foo", () => true);
GL.net.gamemode; // $ExpectType string
api.net.gamemode; // $ExpectType string
api.net.onLoad((type, gamemode) => {});
Expand All @@ -80,6 +78,17 @@ api.rewriter.exposeVar("App", {
multiple: false,
});

// Test patcher
let object = { a: true, b: (arg1: number, arg2: string) => true };
api.patcher.after(object, "b", (thisVal, args, returnVal) => {
args[0]; // $ExpectType number
args[1]; // $ExpectType string
returnVal; // $ExpectType boolean
});
// @ts-expect-error
api.patcher.after(object, "a", () => {});

// Test commands
api.commands.addCommand({
text: "test",
hidden: () => false,
Expand Down Expand Up @@ -112,6 +121,7 @@ api.commands.addCommand({

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

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

// Test colyseus state
api.net.state.characters["..."].x; // $ExpectType number
api.net.state.characters.get("...")!.x; // $ExpectType number
api.net.state.teams[0].characters[0]; // $ExpectType string
api.net.state.mapSettings; // $ExpectType string

// Test settings
api.settings.something;
api.settings.somethingElse;
api.settings.something = 123;
Expand Down
Loading