Runtime Reflection
Reflection provides objects describing types and modules. You can use reflection to look up, dynamically import and create an instance of a type, list its properties, accessors, methods, constructors, decorators and other information. You can also get the type of existing object and/or statically check or compare types. If you are using decorators in your code, reflection enables you to access them and read their constant arguments.
Type objects are inheritors of the Type class that is narrowable by the set of type-guards.
Generic Type Parameters
You can get the real type of type parameter at runtime. Generic type parameter of type aliases, interfaces, functions, classes and methods are fully supported.
Static Type Checking
With Type objects you are able to validate types without value (or instance of object).
Every Type have method Type.is(type)
to compare that two types are the same Type.
Or for example the InterfaceType and the ClassType have method
Type.isDerivedFrom()
that checks if one type inherits from another.
Searchable Metadata Library of Project Types and Modules
Static metadata library of all the types and modules generated from a project accessible via API at runtime.
Let's have an Entity
interface from some ORM.
We want to find all the not-abstract classes implementing that interface and do something with them.
That is pretty simple task...
Vast Majority of Types Supported
Besides user defined functions, decorators, classes, interfaces and type aliases, reflection works with almost all native types. If there is a type we do not support, file an issue.
The Power of Reflection
Reflection is a very poweful feature that allows you to interact with your objects and types at runtime. To get the type of variable that is unknown beforehand by the programmer, or to find and instantiate a user defined class in a framework. It is an interesting feature that allows you to write highly abstract code.
Imagine you are creating an MVC framework. You want to let your users declare classes (controllers) decorated by predefined set of decorators which will setup the controller's behavior.
How would you do that? How to even discover those controllers? Using file-system, preloading all the modules? Force user to register all the controllers manually? Well, there are many dirty ways, but it is clear and simple job for reflection.
Works With 3rd Party Packages
Every package, using RTTIST or not, will work with your codebase. You can get type of any class, interface, type alias, function etc. imported from any package.
Packages using RTTIST can publish metadata along with source code which will reduce the time of your build in case you use types from those packages. If there is no metadata published, it will be generated.