Skip to content

Commit

Permalink
Improve T.Instance type
Browse files Browse the repository at this point in the history
  • Loading branch information
JAForbes committed Feb 22, 2024
1 parent 100fb8c commit 9b3081c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/index.ts
Expand Up @@ -225,11 +225,17 @@ export type UseGetNull<N extends string, D extends Definition> = {

type InternalValue<I extends (v: any) => any> = Parameters<I>[0]

export type Instance<A extends CoreAPI<any, any>> = InternalInstance<
A['type'],
A['definition'],
keyof A['definition']
>
export type Instance<A> =
A extends CoreAPI<any, any>
? InternalInstance<
A['type'],
A['definition'],
keyof A['definition']
>
// constructor
: A extends (x:any) => any
? ReturnType<A>
: never

export function either<Name extends string, Yes, No>(
name: Name,
Expand Down

0 comments on commit 9b3081c

Please sign in to comment.