required-react-context
Version:
A simple React Context wrapper that throws an error if it is used without being provided
14 lines (11 loc) • 553 B
text/typescript
import { N as Names, a as NamedContextUtils } from './types-DCc2LRKd.cjs';
export { U as UNSET_VALUE } from './types-DCc2LRKd.cjs';
import 'react';
declare const notSet: (caller: string, providerName: string) => string;
declare function createRequiredContext<T>(): {
with: <const N extends Names>(names: N) => NamedContextUtils<T, N>;
};
declare function createOptionalContext<T>(defaultValue: T): {
with: <const N extends Names>(names: N) => NamedContextUtils<T, N, false>;
};
export { createOptionalContext, createRequiredContext, notSet };