Skip to content

Commit

Permalink
Define global WithNullValue<T> type (#2497)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedrazb authored Apr 9, 2024
1 parent 3860792 commit 17b7bcb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion specification/_spec_utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ import { Stringified } from '@spec_utils/Stringified'
*/
export type NullValue = null

/**
* `WithNullValue<T>` allows for explicit null assignments in contexts where `null` should be interpreted as an
* actual value.
*/
export type WithNullValue<T> = T | NullValue

/**
* Settings in Elasticsearch are values that can be reset to their default by setting them to the `null` value.
*
* @es_quirk Because of how they are implemented internally, settings are always returned as strings, even
* if their value has been set using a primitive type.
*/
export type Setting<T> = Stringified<T> | NullValue
export type Setting<T> = WithNullValue<Stringified<T>>

0 comments on commit 17b7bcb

Please sign in to comment.