Skip to content

Conversation

@pquentin
Copy link
Member

Added by @davidkyle in elastic/elasticsearch#139530. I initially wanted to do this instead:

export enum SortType {
  _doc,
  _geo_distance,
  _score,
  _script,
  field_sort,
}

sort?: Dictionary<SortType, long>

However, typescript-generator converts that to a Record which expects all keys to be present:

case 'dictionary_of': {
const result = `Record<${buildValue(type.key, openGenerics)}, ${buildValue(type.value, openGenerics)}>`
return type.singleKey ? `Partial<${result}>` : result
}

Interestingly, SingleKeyDictionary uses Partial which makes validation pass, but that's wrong. Since search usage is highly dynamic instead, I've opted for string.

@pquentin pquentin added the skip-backport This pull request should not be backported label Dec 19, 2025
@github-actions
Copy link
Contributor

Following you can find the validation changes against the target branch for the API.

API Status Request Response
cluster.stats 🔴 → 🟢 27/27 0/27 → 27/27

You can validate this API yourself by using the make validate target.

Copy link
Member

@davidkyle davidkyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @pquentin I didn't think to update the spec for my change

@flobernd
Copy link
Member

However, typescript-generator converts that to a Record which expects all keys to be present:

Mhh, I wonder if this is intended and if we should really prefer string vs. a proper enum just because of that technical constraint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-backport This pull request should not be backported specification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants