Fix typedefs

This commit is contained in:
2026-06-06 19:06:52 -05:00
parent 9edb2aa0c1
commit 47a6f396fa
5 changed files with 51 additions and 68 deletions
+7 -29
View File
@@ -6,10 +6,7 @@
*/
/**
* CommonJS-style module loader. Accepts a single path or an array of paths.
*
* - Single string → returns that module's `exports`.
* - Array of strings → returns an array of `exports` in the same order.
* CommonJS-style module loader.
*
* Modules are cached after their first load. Subsequent calls with the same
* resolved path return the cached exports without re-executing the file.
@@ -20,41 +17,22 @@
*
* @example
* const NPC = require('./entities/NPC');
* const [NPC, Item] = require(['./entities/NPC', './entities/Item']);
*/
declare function require(path: string): any;
declare function require(paths: string[]): any[];
/**
* Asynchronous module loader. Accepts a single path or an array of paths.
* The asset file(s) are read in the background; once all are loaded and
* evaluated, `callback` is invoked.
* Asynchronous module loader. Loads the module at `path` in the background
* and returns a Promise that resolves to the module's `exports`.
*
* - Single string → `callback(exports)` — first argument is the module's
* `exports`, or `null` on load failure.
* - Array of strings → `callback(exportsArray)` — first argument is an array
* of `exports` values in the same order; failed entries are `null`.
* If the module is already cached it resolves immediately. On load failure
* the Promise is rejected.
*
* Cached modules resolve synchronously (callback fires on the same call).
* Path rules are identical to `require`.
*
* @example
* requireAsync('./entities/NPC', function(NPC) {
* if(NPC) NPC.init();
* });
*
* requireAsync(['./entities/NPC', './entities/Item'], function(mods) {
* const [NPC, Item] = mods;
* });
* const NPC = await requireAsync('./entities/NPC');
*/
declare function requireAsync(
path: string,
callback: (exports: any) => void
): void;
declare function requireAsync(
paths: string[],
callback: (exports: any[]) => void
): void;
declare function requireAsync(path: string): Promise<any>;
/**
* The module object for the currently executing script.