You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 13, 2023. It is now read-only.
It'd be useful to have a method to determine the type of objects created by Roact in order to validate them more rigorously.
We can expose this through a feature we already have internally, Type. The public API would be:
Roact.typeOf(object) -> RoactType | nil
Roact.Type, an enum with these variants, taken from Type.lua:
Binding
Element
HostChangeEvent
HostEvent
StatefulComponentClass
StatefulComponentInstance
VirtualNode -- objects of this type aren't currently exposed to users
VirtualTree
We should be careful not to expose the actual Type symbol that we use as a key for these types, which would allow users to impersonate Roact instances.
Alternatively, we could have this function return strings instead of enum variants. This would let us keep the set of types we expose open (potentially aiding modularity), but introduce the potential for typos from our users. This has precedent in Lua's type and Roblox's typeof functions.