diff --git a/core/global.d.ts b/core/global.d.ts index e8652c1..d4d2556 100644 --- a/core/global.d.ts +++ b/core/global.d.ts @@ -20,16 +20,21 @@ declare const _VERSION: 'Lua 5.1' | 'Lua 5.2' | 'Lua 5.3' | 'Lua 5.4'; */ declare const _G: typeof globalThis; + /** * 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!" */ -declare function assert(v: V): Exclude; -declare function assert( +declare const assert: AssertFunction; + +interface AssertFunction { + (v: V): Exclude; + ( v: V, ...args: A -): LuaMultiReturn<[Exclude, ...A]>; + ): LuaMultiReturn<[Exclude, ...A]>; +} /** * This function is a generic interface to the garbage collector. It performs @@ -125,7 +130,7 @@ declare function getmetatable(object: T): LuaMetatable | undefined; * first nil value. */ declare function ipairs( - t: Record + t: Record ): LuaIterable]>>; /** @@ -145,7 +150,10 @@ declare function ipairs( * value to a non-existent field in the table. You may however modify existing * fields. In particular, you may clear existing fields. */ -declare function next(table: object, index?: any): LuaMultiReturn<[any, any] | []>; +declare function next( + table: object, + index?: any +): LuaMultiReturn<[any, any] | []>; /** * If t has a metamethod __pairs, calls it with t as argument and returns the @@ -160,7 +168,7 @@ declare function next(table: object, index?: any): LuaMultiReturn<[any, any] | [ * traversal. */ declare function pairs( - t: LuaTable + t: LuaTable ): LuaIterable]>>; declare function pairs(t: T): LuaIterable]>>; @@ -173,14 +181,14 @@ declare function pairs(t: T): LuaIterable( - f: (this: This, ...args: Args) => R, - context: This, - ...args: Args + f: (this: This, ...args: Args) => R, + context: This, + ...args: Args ): LuaMultiReturn<[true, R] | [false, string]>; declare function pcall( - f: (this: void, ...args: A) => R, - ...args: A + f: (this: void, ...args: A) => R, + ...args: A ): LuaMultiReturn<[true, R] | [false, string]>; /** @@ -202,7 +210,10 @@ declare function rawequal(v1: T, v2: T): boolean; * Gets the real value of table[index], without invoking the __index metamethod. * table must be a table; index may be any value. */ -declare function rawget(table: T, index: K): T[K]; +declare function rawget( + table: T, + index: K +): T[K]; /** * Returns the length of the object v, which must be a table or a string, @@ -217,7 +228,11 @@ declare function rawlen(v: object | string): number; * * This function returns table. */ -declare function rawset(table: T, index: K, value: T[K]): T; +declare function rawset( + table: T, + index: K, + value: T[K] +): T; /** * If index is a number, returns all arguments after argument number index; a @@ -243,17 +258,15 @@ declare function select(index: '#', ...args: T[]): number; * * This function returns table. */ -declare function setmetatable< - T extends object, - TIndex extends object | ((this: T, key: any) => any) | undefined = undefined ->( - table: T, - metatable?: LuaMetatable | null +declare function setmetatable any) | undefined = undefined>( + table: T, + metatable?: LuaMetatable | null ): TIndex extends (this: T, key: infer TKey) => infer TValue - ? T & { [K in TKey & string]: TValue } - : TIndex extends object - ? T & TIndex - : T; + ? T & { [K in TKey & string]: TValue } + : TIndex extends object + ? T & TIndex + : T; /** * When called with no base, tonumber tries to convert its argument to a number. @@ -288,5 +301,5 @@ declare function tostring(v: any): string; * Returns the type of its only argument, coded as a string. */ declare function type( - v: any + v: any ): 'nil' | 'number' | 'string' | 'boolean' | 'table' | 'function' | 'thread' | 'userdata';