We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
makeStringUnionGuard is a method that returns a type guard that asserts that the candidate is a member of a given string union (see makeStringUnion).
values: readonly T[]
The values of your string union.
A type guard that asserts that the candidate passed to it is a member of the string union.
import { makeStringUnion, makeStringUnionGuard } from '@revolutionarygamesco/common' const testTypes = ['a', 'b', 'c'] as const type TestType = typeof testTypes[number] const isTestType = makeStringUnionGuard<TestType>(testTypes) isTestType('a') // true isTestType('b') // true isTestType('c') // true isTestType('d') // false isTestType('hello!') // false isTestType(42) // false isTestType(testTypes) // false because that's an array — `TestType[]`, not `TestType`