Function: isString()
isString(
val
):val is string
Type guard to check if a value is a string.
Parameters
val
unknown
The value to check
Returns
val is string
True if the value is a string
Example
typescript
const value: unknown = 'hello world'
if (isString(value)) {
// TypeScript knows value is a string
console.log(value.toUpperCase()) // 'HELLO WORLD'
}