Skip to content

Commit bdd6543

Browse files
committed
feat: small global function improvements
1 parent 11b96ba commit bdd6543

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

core/global.d.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ type __LUA_TODO__ = any;
44
type LuaThread = { readonly __internal__: unique symbol };
55
type LuaUserdata = { readonly __internal__: unique symbol };
66

7+
/**
8+
* A global variable (not a function) that holds the global environment (see §2.2). Lua itself does not use this variable; changing its value does not affect any environment, nor vice versa.
9+
*/
10+
declare const _G: any;
11+
712
/**
813
* Calls error if the value of its argument v is false (i.e., nil or false); otherwise, returns all its arguments. In case of error, message is the error object; when absent, it defaults to "assertion failed!"
914
*/
10-
declare function assert(v: boolean, message?: string): void;
15+
declare function assert<T>(v: T, message?: string): Exclude<T, false | null | undefined>;
1116

1217
/**
1318
* This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt.
@@ -61,12 +66,7 @@ declare function dofile(filename?: string): any;
6166
*
6267
* Usually, error adds some information about the error position at the beginning of the message, if the message is a string. The level argument specifies how to get the error position. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to where the function that called error was called; and so on. Passing a level 0 avoids the addition of error position information to the message.
6368
*/
64-
declare function error(message: string, level?: 0 | 1 | 2): never;
65-
66-
/**
67-
* A global variable (not a function) that holds the global environment (see §2.2). Lua itself does not use this variable; changing its value does not affect any environment, nor vice versa.
68-
*/
69-
declare const _G: { [key: string]: any };
69+
declare function error(message: string, level?: number): never;
7070

7171
/**
7272
* If object does not have a metatable, returns nil. Otherwise, if the object's metatable has a __metatable field, returns the associated value. Otherwise, returns the metatable of the given object.
@@ -174,10 +174,10 @@ declare function tonumber(e: any, base?: number): number | null;
174174
*
175175
* If the metatable of v has a __tostring field, then tostring calls the corresponding value with v as argument, and uses the result of the call as its result.
176176
*/
177-
declare function tostring(v): string;
177+
declare function tostring(v: any): string;
178178

179179
/**
180-
* Returns the type of its only argument, coded as a string. The possible results of this function are "nil" (a string, not the value nil), "number", "string", "boolean", "table", "function", "thread", and "userdata".
180+
* Returns the type of its only argument, coded as a string.
181181
*/
182182
declare function type(
183183
v: any,

0 commit comments

Comments
 (0)