PopClip JavaScript API Reference
    Preparing search index...

    Type Alias InferOptions<T>

    InferOptions: {
        readonly [K in T[number]["identifier"] as Extract<
            T[number],
            { identifier: K },
        > extends { type: "string" | "secret" | "multiple" | "boolean" }
            ? K
            : never]: Extract<T[number], { identifier: K }> extends {
            type: "boolean";
        }
            ? boolean
            : string
    }

    The type of the options object, derived from an options array. Pass it as the type parameter of defineExtension so that action functions and the population function see the real option identifiers and value types, instead of the generic Options.

    The array must be declared as const, so that the identifiers and types are literal. heading and password options carry no value and are omitted.

    Type Parameters

    const options = [
    { identifier: "prefix", type: "string", defaultValue: ">" },
    { identifier: "loud", type: "boolean", defaultValue: false },
    ] as const;

    // { readonly prefix: string; readonly loud: boolean }
    type MyOptions = InferOptions<typeof options>;

    defineExtension<MyOptions>({ options, action: (input, options) => { ... } });