@@ -430,3 +430,81 @@ declare type LuaLength<TOperand, TReturn> = ((operand: TOperand) => TReturn) & L
430430 * @param TReturn The resulting (return) type of the operation.
431431 */
432432declare type LuaLengthMethod < TReturn > = ( ( ) => TReturn ) & LuaExtension < "__luaLengthMethodBrand" > ;
433+
434+ /**
435+ * Calls to functions with this type are translated to `table[key]`.
436+ * For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
437+ *
438+ * @param TTable The type to access as a Lua table.
439+ * @param TKey The type of the key to use to access the table.
440+ * @param TValue The type of the value stored in the table.
441+ */
442+ declare type LuaTableGet < TTable extends object , TKey extends { } , TValue > = ( ( table : TTable , key : TKey ) => TValue ) &
443+ LuaExtension < "__luaTableGetBrand" > ;
444+
445+ /**
446+ * Calls to methods with this type are translated to `table[key]`, where `table` is the object with the method.
447+ * For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
448+ *
449+ * @param TKey The type of the key to use to access the table.
450+ * @param TValue The type of the value stored in the table.
451+ */
452+ declare type LuaTableGetMethod < TKey extends { } , TValue > = ( ( key : TKey ) => TValue ) &
453+ LuaExtension < "__luaTableGetMethodBrand" > ;
454+
455+ /**
456+ * Calls to functions with this type are translated to `table[key] = value`.
457+ * For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
458+ *
459+ * @param TTable The type to access as a Lua table.
460+ * @param TKey The type of the key to use to access the table.
461+ * @param TValue The type of the value to assign to the table.
462+ */
463+ declare type LuaTableSet < TTable extends object , TKey extends { } , TValue > = ( (
464+ table : TTable ,
465+ key : TKey ,
466+ value : TValue
467+ ) => void ) &
468+ LuaExtension < "__luaTableSetBrand" > ;
469+
470+ /**
471+ * Calls to methods with this type are translated to `table[key] = value`, where `table` is the object with the method.
472+ * For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
473+ *
474+ * @param TKey The type of the key to use to access the table.
475+ * @param TValue The type of the value to assign to the table.
476+ */
477+ declare type LuaTableSetMethod < TKey extends { } , TValue > = ( ( key : TKey , value : TValue ) => void ) &
478+ LuaExtension < "__luaTableSetMethodBrand" > ;
479+
480+ /**
481+ * A convenience type for working directly with a Lua table.
482+ * For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
483+ *
484+ * @param TKey The type of the keys used to access the table.
485+ * @param TValue The type of the values stored in the table.
486+ */
487+ declare interface LuaTable < TKey extends { } = { } , TValue = any > {
488+ length : LuaLengthMethod < number > ;
489+ get : LuaTableGetMethod < TKey , TValue > ;
490+ set : LuaTableSetMethod < TKey , TValue > ;
491+ }
492+
493+ /**
494+ * A convenience type for working directly with a Lua table.
495+ * For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
496+ *
497+ * @param TKey The type of the keys used to access the table.
498+ * @param TValue The type of the values stored in the table.
499+ */
500+ declare type LuaTableConstructor = ( new < TKey extends { } = { } , TValue = any > ( ) => LuaTable < TKey , TValue > ) &
501+ LuaExtension < "__luaTableNewBrand" > ;
502+
503+ /**
504+ * A convenience type for working directly with a Lua table.
505+ * For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
506+ *
507+ * @param TKey The type of the keys used to access the table.
508+ * @param TValue The type of the values stored in the table.
509+ */
510+ declare const LuaTable : LuaTableConstructor ;
0 commit comments