diff --git a/CHANGELOG.md b/CHANGELOG.md index 1354047c3..b6b4e7f94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Deprecated ### Removed ### Fixed +- Make optional fields optional in `MappingGenericProperty` ### Security ## [2.5.0] diff --git a/api/types.d.ts b/api/types.d.ts index 6628ce5da..a5be4da5a 100644 --- a/api/types.d.ts +++ b/api/types.d.ts @@ -3907,17 +3907,17 @@ export interface MappingFloatRangeProperty extends MappingRangePropertyBase { } export interface MappingGenericProperty extends MappingDocValuesPropertyBase { - analyzer: string; - boost: double; - fielddata: IndicesStringFielddata; - ignore_malformed: boolean; - index: boolean; - index_options: MappingIndexOptions; - norms: boolean; - null_value: string; - position_increment_gap: integer; - search_analyzer: string; - term_vector: MappingTermVectorOption; + analyzer?: string; + boost?: double; + fielddata?: IndicesStringFielddata; + ignore_malformed?: boolean; + index?: boolean; + index_options?: MappingIndexOptions; + norms?: boolean; + null_value?: string; + position_increment_gap?: integer; + search_analyzer?: string; + term_vector?: MappingTermVectorOption; type: string; } diff --git a/test/types/types.test-d.ts b/test/types/types.test-d.ts new file mode 100644 index 000000000..8f2a80823 --- /dev/null +++ b/test/types/types.test-d.ts @@ -0,0 +1,10 @@ +import { expectAssignable } from 'tsd'; +import { MappingProperty } from '../../api/types'; + +// https://github.com/opensearch-project/opensearch-js/issues/703 +// only manifested when value is in a variable, so the following would *not* catch it: +// +// expectAssignable({ type: 'date' }); + +const x = { type: 'date' }; +expectAssignable(x);