babel-plugin-transform-modules-ui5 icon indicating copy to clipboard operation
babel-plugin-transform-modules-ui5 copied to clipboard

Custom metadata implementation

Open whitenrock opened this issue 4 years ago • 0 comments

With the third argument FNMetaImpl of Object.extend the constructor of a metadata class can be specified. Instances of that class will be used to represent metadata for the newly created class and for any subclass created from it:

sap.ui.base.Object.extend(sClassName, oClassInfo?, FNMetaImpl?) : function

With the changes of the pull request, it possible to set this metadata class with jsdoc or decorators :

Typescript

import UI5Object from "sap/ui/base/Object"
/** @metadata some.namespace.CustomMetadata */
class TestClass extends UI5Object {
   // implementation
}

Result

sap.ui.define(["some/namespace/CustomMetadata", "sap/ui/base/Object"], function(MetadataObject, Object) {
  const TestClass = UI5Object.extend("some.namespace.TestClass", {
    // implementation
  }, MetadataObject);
  return TestClass;
}

whitenrock avatar Aug 27 '21 12:08 whitenrock