Type for a non-empty ArrayLike, object or string.
ArrayLike
object
string
This type is useful for cases where you want to ensure that a value is not empty. For example, if you have an array that should always have at least one element, you could type it as NotEmpty<ArrayLike<ElementType>>.
NotEmpty<ArrayLike<ElementType>>
const notEmptyString: NotEmpty<string> = "🟢";const notEmptyArray: NotEmpty<ReadOnlyArray> = ["🟢", "🟩"];const notEmptyRecord: NotEmpty<ReadOnlyRecord> = { "🟢": "🟩" }; Copy
const notEmptyString: NotEmpty<string> = "🟢";const notEmptyArray: NotEmpty<ReadOnlyArray> = ["🟢", "🟩"];const notEmptyRecord: NotEmpty<ReadOnlyRecord> = { "🟢": "🟩" };
Empty
The type to check.
Type for a non-empty
ArrayLike
,object
orstring
.Remarks
This type is useful for cases where you want to ensure that a value is not empty. For example, if you have an array that should always have at least one element, you could type it as
NotEmpty<ArrayLike<ElementType>>
.Example
See
Empty