mirror of
https://github.com/denoland/deno.git
synced 2024-12-20 22:34:46 -05:00
19 lines
404 B
TypeScript
19 lines
404 B
TypeScript
|
import { createContext } from "npm:@denotest/types-pkg-json-import";
|
||
|
import { useContext } from "npm:@denotest/types-pkg-json-import/hooks";
|
||
|
|
||
|
export interface Foo {
|
||
|
foo: string;
|
||
|
}
|
||
|
|
||
|
export const CTX = createContext<Foo | undefined>(undefined);
|
||
|
|
||
|
function unwrap(foo: Foo) {}
|
||
|
|
||
|
export function useCSP() {
|
||
|
const foo = useContext(CTX);
|
||
|
// previously this was erroring
|
||
|
if (foo) {
|
||
|
unwrap(foo);
|
||
|
}
|
||
|
}
|