getClassPropertyDescriptor
Available since v0.9
Returns PropertyDescriptor
, from target's prototype that matches given property key.
It accepts the following arguments:
target: ConstructorOrAbstractConstructor
- The target class.key: PropertyKey
- Name of the property.
import { getClassPropertyDescriptor } from '@aedart/support/reflections';
class A {
set name(v) {}
get name() {}
}
getClassPropertyDescriptor(A, 'name'); // see "output"...
The above show example results in the given output:
const output = {
get: function () { /* ...Not shown... */ },
set: function (v) { /* ..Not shown... */ },
enumerable: false,
configurable: true
};
Note
getClassPropertyDescriptor()
returns undefined
if requested key does not exist in class' prototype.
Caution
getClassPropertyDescriptor()
throws TypeError
if target does not have a prototype
property.