Function optional

  • Marks a class property as optional in the generated schema. Optional properties can be undefined or omitted when creating instances.

    Returns PropertyDecorator

    A property decorator

    class UserSettings {
    @optional()
    @description("Preferred theme (defaults to system)")
    theme?: 'light' | 'dark';

    @optional()
    @example("en-US")
    language?: string;
    }