Skip to content

Types - IndicesIndexSettingsKeys should allow for null values #2000

Closed
@diogoalmiro

Description

@diogoalmiro

🐛 Bug Report

According to the documentation, to revert an index setting to the default value we should set its value to null.

To Reproduce

There is no runtime error using null, running the following code:

import { Client } from "@elastic/elasticsearch";

let client = new Client({...});

client.indices.putSettings({
    index: "...",
    settings: {
        refresh_interval: null
    }
}).then(console.log)

It prints { acknowledged: true } and it removes refresh_interval setting if it was set to something. However, according to the IDE and the typescript compiler this is an error:

src/util/example.ts:8:9 - error TS2769: No overload matches this call.
  Overload 1 of 3, '(this: That, params: import(".../node_modules/@elastic/elasticsearch/lib/api/types").IndicesPutSettingsRequest | import(".../node_modules/@elastic/elasticsearch/lib/api/typesWithBodyKey").IndicesPutSettingsRequest, options?: TransportRequestOptionsWithOutMeta | undefined): Promise<...>', gave the following error.
    Type 'null' is not assignable to type 'Duration | undefined'.
  Overload 2 of 3, '(this: That, params: import(".../node_modules/@elastic/elasticsearch/lib/api/types").IndicesPutSettingsRequest | import(".../node_modules/@elastic/elasticsearch/lib/api/typesWithBodyKey").IndicesPutSettingsRequest, options?: TransportRequestOptionsWithMeta | undefined): Promise<...>', gave the following error.
    Type 'null' is not assignable to type 'Duration | undefined'.
  Overload 3 of 3, '(this: That, params: import(".../node_modules/@elastic/elasticsearch/lib/api/types").IndicesPutSettingsRequest | import(".../node_modules/@elastic/elasticsearch/lib/api/typesWithBodyKey").IndicesPutSettingsRequest, options?: TransportRequestOptions | undefined): Promise<...>', gave the following error.
    Type 'null' is not assignable to type 'Duration | undefined'.

8         refresh_interval: null

Expected behavior

No typescript or IDE errors when setting any setting to null.

Your Environment

  • node version: v20.5.1
  • @elastic/elasticsearch version: 8.9.0
  • os: Mac

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions