TSTL Class
Functions
Section titled “Functions”getTSTLClassConstructor()
Section titled “getTSTLClassConstructor()”getTSTLClassConstructor(
object): {name:string;prototype:Readonly<LuaMetatable<LuaMap<AnyNotNil,unknown>>>; } |undefined
Defined in: packages/isaacscript-common/src/functions/tstlClass.ts:13
Helper function to get the constructor from an instantiated TypeScriptToLua class, which is located on the metatable.
Returns undefined if passed a non-table or if the provided table does not have a metatable.
Parameters
Section titled “Parameters”object
Section titled “object”unknown
Returns
Section titled “Returns”{ name: string; prototype: Readonly<LuaMetatable<LuaMap<AnyNotNil, unknown>>>; } | undefined
getTSTLClassName()
Section titled “getTSTLClassName()”getTSTLClassName(
object):string|undefined
Defined in: packages/isaacscript-common/src/functions/tstlClass.ts:38
Helper function to get the name of a TypeScriptToLua class from the instantiated class object.
TSTL classes are Lua tables created with the __TS__Class Lua function from the TSTL lualib.
Their name is contained within “constructor.name” metatable key.
For example, a Map class is has a name of “Map”.
Returns undefined if passed a non-table or if the provided table does not have a metatable.
Parameters
Section titled “Parameters”object
Section titled “object”unknown
Returns
Section titled “Returns”string | undefined
isDefaultMap()
Section titled “isDefaultMap()”isDefaultMap(
object):object is DefaultMap<AnyNotNil, unknown, []>
Defined in: packages/isaacscript-common/src/functions/tstlClass.ts:53
Helper function to determine if a given object is a DefaultMap from isaacscript-common.
It is not reliable to use the instanceof operator to determine this because each Lua module has
their own copies of the entire lualib and thus their own instantiated version of a DefaultMap.
Parameters
Section titled “Parameters”object
Section titled “object”unknown
Returns
Section titled “Returns”object is DefaultMap<AnyNotNil, unknown, []>
isTSTLClass()
Section titled “isTSTLClass()”isTSTLClass(
object):object is TSTLClass
Defined in: packages/isaacscript-common/src/functions/tstlClass.ts:61
Helper function to check if a given table is a class table created by TypeScriptToLua.
Parameters
Section titled “Parameters”object
Section titled “object”unknown
Returns
Section titled “Returns”object is TSTLClass
isTSTLMap()
Section titled “isTSTLMap()”isTSTLMap(
object):object is Map<AnyNotNil, unknown>
Defined in: packages/isaacscript-common/src/functions/tstlClass.ts:73
Helper function to determine if a given object is a TypeScriptToLua Map.
It is not reliable to use the instanceof operator to determine this because each Lua module
might have their own copy of the entire lualib and thus their own instantiated version of a
Map.
Parameters
Section titled “Parameters”object
Section titled “object”unknown
Returns
Section titled “Returns”object is Map<AnyNotNil, unknown>
isTSTLSet()
Section titled “isTSTLSet()”isTSTLSet(
object):object is Set<AnyNotNil>
Defined in: packages/isaacscript-common/src/functions/tstlClass.ts:85
Helper function to determine if a given object is a TypeScriptToLua Set.
It is not reliable to use the instanceof operator to determine this because each Lua module
might have their own copy of the entire lualib and thus their own instantiated version of a
Set.
Parameters
Section titled “Parameters”object
Section titled “object”unknown
Returns
Section titled “Returns”object is Set<AnyNotNil>
newTSTLClass()
Section titled “newTSTLClass()”newTSTLClass(
oldClass):TSTLClass
Defined in: packages/isaacscript-common/src/functions/tstlClass.ts:96
Initializes a new TypeScriptToLua class in the situation where you do not know what kind of class it is. This function requires that you provide an instantiated class of the same type, as it will use the class constructor that is present on the other object’s metatable to initialize the new class.
