Checks if the provided value is a string.
Error if the value is not a string.
const fn = (x: unknown) => { assertIsString(x); // throws an error if x is not a string return x; // x has inferred type string}; Copy
const fn = (x: unknown) => { assertIsString(x); // throws an error if x is not a string return x; // x has inferred type string};
The value to check.
Checks if the provided value is a string.
Throws
Error if the value is not a string.
Example