Type alias FilledString<T>

FilledString<T>: Strlen<T> extends 0
    ? Message<"must be non-empty string">
    : T

Check if a string is non-empty

Type Parameters

  • T extends string = string

Example

export function filledString<S extends string>(s: FilledString<S>) {
return s;
}
console.log(filledString('hello')); // Ok
console.log(filledString('')); // Error