Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define global WithNullValue<T> type #2497

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>>
Loading