Skip to content

isString

Jason Godesky edited this page Jul 11, 2026 · 2 revisions

isString is a type guard that lets Typescript know that the variable passed in is a string.

Parameters

candidate: unknown

Supply any variable to test if it’s a string or not.

Returns

A type predicate for a string (candidate is string).

Examples

import { isString } from '@revolutionarygamesco/common'

isString('hello!') // true
isString(42) // false
isString(['hello!']) // false
isString({ a: 'hello!' }) // false

Clone this wiki locally