Closed caiodallecio closed 2 years ago
Hi @caiodallecio,
it is not possible now, but it is possible, PR is welcome. Getters & setters are returned with fields by Type.getProperties().
We can extend interface Property
by isSetter()
and isGetter()
and join that with #4 and add isPrivate()
, isProtected()
, isPublic()
and isReadOnly()
.
This means:
Accessor
{ Getter, Setter } to the runtime package (runtime/reflect.ts),AccessModifier
{ Private, Protected, Public }.PropertyDescription
by properties acs: Accessor
, am: AccessModifier
, ro: boolean
(is readonly)
https://github.com/Hookyns/ts-reflection/blob/1a93314179f739e91fb183dcb72cb95e13ca4aa7/runtime/reflect.ts#L120-L125
XxxDescription interfaces are for metadata generated by the transformer, so names are shortcuts to keep metadata small.Type
,PS: getter & setter example https://replit.com/@Hookyns/tst-reflect-example-getters-setters
Information about getters and setters is available from tst-reflect@0.6.0-alpha.5 and tst-reflect-transformer@0.8.5-alpha.0
PS: used in ./dev/class-info
example
Is it possible to check if a given property has/is a getter or setter? Would you be interested in a PR ?