-
Notifications
You must be signed in to change notification settings - Fork 725
Closed as not planned
Labels
Description
🐛 Bug Report
using a readonly string[] in where string[] is expected gives error. just Using filter_path as an example, I have an array of common values stored. These will never change so wanted to follow best practice to use Object.freeze(). This changed the datatype from string[] to readonly string[].
Filing this as bugreport to request elasticsearch to add readonly values in such case. Let me know if this is omitted by design and may cause errors that I may not know of.
To Reproduce
Steps to reproduce the behavior:
Paste the results here:
const ELASTICSEARCH_COMMON_FILTER_PATH = Object.freeze(['hits.total.value', 'hits.hits._source', 'hits.hits._score']);
const elasticSearchKeywordQuery: estypes.SearchRequest = {
index: ELASTICSEARCH_INDEX,
_source: Object.keys(getProperties),
filter_path: ELASTICSEARCH_COMMON_FILTER_PATH, // Here is the Error
query: {...
// rest of the query is not relevant to this issue
Error Message
(property) SpecUtilsCommonQueryParameters.filter_path?: string | string[]
Type 'readonly string[]' is not assignable to type 'string | string[]'.ts(2322)
types.d.ts(15093, 5): The expected type comes from property 'filter_path' which is declared here on type 'SearchRequest'
Expected behavior
readonly datatypeX should work everywhere datatypeX works.
Your Environment
- node version: 16
@elastic/elasticsearchversion: >=8.2.1- os: Mac,
gregoirechauvet