The runtime class/constructor that represents the property's type. For type aliases, use the base runtime class they resolve to.
// For direct class types:
class MaterialComponent {
@Optional(Rgb)
diffuseColor?: Rgb;
}
// For type aliases, use the base runtime class:
// type CollisionCallback = SerializableCallback<...>
class BoundingBoxComponent {
@Optional(SerializableCallback) // Use runtime class, not alias
onCollision?: CollisionCallback; // Type annotation can use alias
}
const material = new MaterialComponent();
getOptionalType(material, 'diffuseColor') // Returns Rgb
getOptionalType(material, 'onCollision') // Returns SerializableCallback
Decorator to register optional property types for runtime type inference. Enables type inference directly from class instances.
For type aliases, pass the resolved runtime class, not the alias itself. The ESLint rule
optional-decorator-type-consistencyenforces this automatically.