hasStateProperty
hasStateProperty<
S,K>(state,key):key is K & keyof S
Defined in: src/util/types.ts:77
Type guard to check if a state property exists and narrow its type.
Type Parameters
Section titled “Type Parameters”S extends Record<string, any>
K extends string
Parameters
Section titled “Parameters”S
K
Returns
Section titled “Returns”key is K & keyof S
Example
Section titled “Example”if (hasStateProperty(ctx, 'userId')) { // ctx.state.userId is now typed as defined (not undefined) console.log(ctx.state.userId);}