Skip to content

Commit

Permalink
Types
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Oct 13, 2021
1 parent a3d77c5 commit ef347dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions types/helpers/helpers.options.d.ts
Expand Up @@ -52,3 +52,10 @@ export function resolve<T, C>(
index?: number,
info?: { cacheable?: boolean }
): T | undefined;


/**
* Create a context inheriting parentContext
* @since 3.6.0
*/
export function createContext<P, T>(parentContext: P, context: T): P extends null ? T : P & T;
10 changes: 10 additions & 0 deletions types/tests/helpers/options.ts
@@ -0,0 +1,10 @@
import { createContext } from '../../helpers/helpers.options';

const context1 = createContext(null, { type: 'test1', parent: true });
const context2 = createContext(context1, { type: 'test2' });

const sSest: string = context1.type + context2.type;
const bTest: boolean = context1.parent && context2.parent;

// @ts-expect-error Property 'notThere' does not exist on type '{ type: string; parent: boolean; } & { type: string; }'
context2.notThere = '';

0 comments on commit ef347dd

Please sign in to comment.