Libraries v5.0.0
    Preparing search index...

    Function defineMetadataMethod

    • Define an immutable metadata-only method for use inside defineExtension().

      Unlike ordinary extension methods, its stored value is also available through InferExtensionMetadata<S>. Repeated writes replace the value for that key. The method does not validate input or change the schema's inferred value type. Methods are installed only on factories returned by withExtensions().

      Type Parameters

      • const K extends string

      Parameters

      • key: K

        Runtime introspection key, independent of the fluent method name.

      Returns MetadataMethodBuilder<K>

      const labels = defineExtension({
      string: {
      label: defineMetadataMethod('label').argument<string>(),
      internal: defineMetadataMethod('visibility').value('internal')
      }
      });
      const s = withExtensions(labels).string().label('Title').optional();
      type Label = InferExtensionMetadata<typeof s>['label']; // 'Title'