@rxap/xml-parser
Version:
Provides a set of decorators and services for parsing and serializing XML documents into TypeScript classes. It simplifies the process of mapping XML elements and attributes to class properties, handling data validation, and serializing objects back into
28 lines • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ElementExtends = ElementExtends;
const reflect_metadata_1 = require("@rxap/reflect-metadata");
const metadata_keys_1 = require("./metadata-keys");
/**
* A decorator factory that marks a class as extending a specific type of parsed element.
* This is used in scenarios where elements are parsed and need to inherit or extend
* properties from a parent parsed element.
*
* @typeparam Parent - The base class type that the target is extending. Must extend from `ParsedElement`.
* @param elementType - The type of the parent element that the target class will extend.
* @returns A class decorator that adds metadata to the class indicating the type of the parent element it extends.
*
* ### Example
* ```typescript
* @ElementExtends(SomeBaseElement)
* class MyCustomElement extends SomeBaseElement {
* // class implementation here
* }
* ```
*/
function ElementExtends(elementType) {
return function (target) {
(0, reflect_metadata_1.addToMetadata)(metadata_keys_1.ElementParserMetaData.EXTENDS, target, elementType);
};
}
//# sourceMappingURL=element-extends.js.map