@kkdev92/vscode-ext-kit - v4.1.1
    Preparing search index...

    Variable settingConst

    setting: {
        boolean(options: SettingBaseOptions<boolean>): SettingSpec<boolean>;
        enum<const TValues extends readonly [string, string]>(
            options: SettingBaseOptions<TValues[number]> & { values: TValues },
        ): SettingSpec<TValues[number]>;
        integer(
            options: SettingBaseOptions<number> & {
                maximum?: number;
                minimum?: number;
            },
        ): SettingSpec<number>;
        nullable<T>(
            inner: SettingSpec<T>,
            options?: { default?: T | null },
        ): SettingSpec<T | null>;
        number(
            options: SettingBaseOptions<number> & {
                maximum?: number;
                minimum?: number;
            },
        ): SettingSpec<number>;
        string(options: SettingBaseOptions<string>): SettingSpec<string>;
        stringArray(
            options: SettingBaseOptions<readonly string[]> & {
                items?: { minLength?: number; pattern?: RegExp };
            },
        ): SettingSpec<readonly string[]>;
    } = ...

    Builders for common typed settings. They create definitions only and never read or write the workspace configuration.

    Type Declaration

    • boolean: function
    • enum: function
    • integer: function
    • nullable: function
      • Widens a setting to accept null as well.

        A setting that means "unset" is an ordinary VS Code pattern, and it is not something the other builders can express: the manifest has to say "type": ["integer", "null"] before the settings editor will accept a null default, and a spec whose validate rejects null makes every lenient read of an unset value fall back to the default instead.

        The default carries over from inner unless default is given. Say { default: null } for the setting whose unset state is the default; omit it for one that has a real default but tolerates being cleared.

        An enumerated inner spec gains null at the front of its values, which is where the manifest convention puts it — and enumDescriptions is positional, so the description of "unset" goes first too.

        Type Parameters

        • T

        Parameters

        Returns SettingSpec<T | null>

        const values = {
        // A real default, clearable.
        'resize.maxWidth': setting.nullable(setting.integer({ default: 1200 })),
        // Unset by default.
        'resize.preset': setting.nullable(
        setting.enum({ values: ['ai-optimized'], default: 'ai-optimized' }),
        { default: null }
        ),
        };
    • number: function
    • string: function
    • stringArray: function
      • A list of strings.

        items constrains each entry. Without it a user can put an empty string in a list of glob patterns and the extension will happily match everything — the kind of value that is better rejected than defaulted around. Patterns are tested as supplied; avoid stateful g or y flags.

        Parameters

        • options: SettingBaseOptions<readonly string[]> & {
              items?: { minLength?: number; pattern?: RegExp };
          }

        Returns SettingSpec<readonly string[]>

    const ProjectSettings = defineSettings({
    section: 'sample.projects',
    values: {
    enabled: setting.boolean({ default: true, scope: 'resource' }),
    interval: setting.number({ default: 30, minimum: 5 }),
    mode: setting.enum({ values: ['fast', 'thorough'], default: 'fast' }),
    },
    });