Casts a string to NonEmptyString after checking that it has at least one
character.
NonEmptyString is an alias of MinLengthString<1>, so this is the
length-1 specialization of asMinLengthString. Use this instead of
writing s as unknown as NonEmptyString: the length is verified at
runtime, and the original string type (e.g. literal types) is preserved
via intersection.
Type Parameters
Sextendsstring
The input string type (literal types are preserved).
Casts a string to
NonEmptyStringafter checking that it has at least one character.NonEmptyStringis an alias ofMinLengthString<1>, so this is the length-1 specialization of asMinLengthString. Use this instead of writings as unknown as NonEmptyString: the length is verified at runtime, and the original string type (e.g. literal types) is preserved via intersection.