Skip to content

Commit

Permalink
feat: support goto definition for slots
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton committed Oct 17, 2023
1 parent 651bbf7 commit 23f8e82
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ export type TVReturnProps<
variantKeys: TVVariantKeys<V, S>;
};

type HasSlots<S extends TVSlots, ES extends TVSlots> = S extends undefined
? ES extends undefined
? false
: true
: true;

export type TVReturnType<
V extends TVVariants<S>,
S extends TVSlots,
Expand All @@ -205,11 +211,19 @@ export type TVReturnType<
// @ts-expect-error
E extends TVReturnType = undefined,
> = {
(props?: TVProps<V, S, C, EV, ES>): ES extends undefined
? S extends undefined
? string
: {[K in TVSlotsWithBase<S, B>]: (slotProps?: TVProps<V, S, C, EV, ES>) => string}
: {[K in TVSlotsWithBase<ES & S, B>]: (slotProps?: TVProps<V, S, C, EV, ES>) => string};
(props?: TVProps<V, S, C, EV, ES>): HasSlots<S, ES> extends true
? {
[K in keyof (ES extends undefined ? {} : ES)]: (
slotProps?: TVProps<V, S, C, EV, ES>,
) => string;
} & {
[K in keyof (S extends undefined ? {} : S)]: (
slotProps?: TVProps<V, S, C, EV, ES>,
) => string;
} & {
[K in TVSlotsWithBase<{}, B>]: (slotProps?: TVProps<V, S, C, EV, ES>) => string;
}
: string;
} & TVReturnProps<V, S, B, EV, ES, E>;

export type TV = {
Expand Down

0 comments on commit 23f8e82

Please sign in to comment.