IsSymbolLiteral<T>
IsSymbolLiteral<
T
> =LiteralCheck
<T
,symbol
>
Defined in: packages/react-querybuilder/src/types/type-fest/is-literal.ts:243
Returns a boolean for whether the given type is a symbol
literal type.
Useful for:
- providing strongly-typed functions when given literal arguments
- type utilities, such as when constructing parsers and ASTs
Type Parameters
Type Parameter |
---|
T |
Example
import type {IsSymbolLiteral} from 'type-fest';
type Get<Obj extends Record<symbol, number>, Key extends keyof Obj> =
IsSymbolLiteral<Key> extends true
? Obj[Key]
: number;
function get<Obj extends Record<symbol, number>, Key extends keyof Obj>(o: Obj, key: Key) {
return o[key] as Get<Obj, Key>;
}
const symbolLiteral = Symbol('literal');
const symbolValue: symbol = Symbol('value');
get({[symbolLiteral]: 1} as const, symbolLiteral);
//=> 1
get({[symbolValue]: 1} as const, symbolValue);
//=> number
caution
API documentation is generated from the latest commit on the main
branch. It may be somewhat inconsistent with official releases of React Query Builder.