Type Parameters
- S extends string
- MaxLength extends ArgStr
Returns s is string & Readonly<
{
MaxLength: RelaxedExclude<
IndexOfTupleImpl<
[...MakeTupleImpl<0, `${MaxLength}`, []>[], 0],
keyof [...MakeTupleImpl<0, `${MaxLength}`, []>[], 0],
>,
never,
>;
},
> & Readonly<
{
"TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3": unknown;
},
> & S
true if s.length <= maxLength, false otherwise. When true,
TypeScript narrows s to MaxLengthString<MaxLength> & S.
Type guard that checks if a string has at most
maxLengthcharacters.The length is measured in UTF-16 code units (the same unit as
String.prototype.length), so characters outside the Basic Multilingual Plane (e.g. emoji) count as 2.Type Narrowing Behavior:
MaxLengthString<MaxLength>while preserving the original string type (e.g. literal types) via intersection.MaxLengthString<16>is assignable toMaxLengthString<32>.