-
-
Notifications
You must be signed in to change notification settings - Fork 184
Closed
Labels
Description
Missing members of ES keyed collections API:
delete(key: K): void (statement) -> table[key] = nil
has(key: K): boolean (expression) -> table[key] ~= nil
(it's also missing iteration methods, but we have decided to prefer pairs/ipairs instead).
Few utility methods that may be worthy to consider:
unwrap(): Partial<Record<K, V>>;
static wrap<K extends {}, V>(table: Partial<Record<K, V>>): LuaTable<K, V>;These are purely type helpers, so LuaTable.of(table) -> table, table.unwrap() -> table.
We also may consider to make it an interface instead of a class, since it's not a real class and doesn't have a .prototype:
/** @luaTable */
interface LuaTable<K extends {}, V> {
readonly length: number;
set(key: K, value: V | undefined): void;
get(key: K): V | undefined;
}
interface LuaTableConstructor {
new(): LuaTable<{}, any>;
new<K extends {}, V>(): LuaTable<K, V>;
}
/** @luaTable */
declare const LuaTable: LuaTableConstructor;Reactions are currently unavailable