Skip to content

Commit

Permalink
wip-fix: actionables type (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
jagnani73 authored Oct 23, 2024
1 parent f473998 commit 27a15d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
6 changes: 2 additions & 4 deletions src/utils/functions/actionable-wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { type ActionableType } from "../types/shared.types";
import { createElement } from "react";
import { createElement, type ElementType } from "react";

export const actionableWrapper = <
T extends keyof JSX.IntrinsicElements | React.ComponentType<any>,
>(
export const actionableWrapper = <T extends ElementType>(
actionable: ActionableType<T> | null,
children: React.ReactNode,
): React.ReactNode => {
Expand Down
33 changes: 18 additions & 15 deletions src/utils/types/shared.types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { type Option } from "@/utils/option";
import type {
NftApprovalsItem,
Pagination,
TokensApprovalItem,
Transaction,
} from "@covalenthq/client-sdk";
import { type Pagination, type Transaction } from "@covalenthq/client-sdk";
import {
type Column,
type ColumnDef,
type Row,
type SortingState,
import type {
Column,
ColumnDef,
Row,
SortingState,
} from "@tanstack/react-table";
import type { ComponentType } from "react";

export interface BalancePriceDeltaProps {
numerator: number;
Expand Down Expand Up @@ -99,12 +101,13 @@ export interface HeadingProps
size: 1 | 2 | 3 | 4;
}

export type ActionableType<
T extends
| keyof JSX.IntrinsicElements
| React.ComponentType<any> = keyof JSX.IntrinsicElements,
> =
| (T extends keyof JSX.IntrinsicElements
? { parent: T; parentProps: JSX.IntrinsicElements[T] }
: { parent: T; parentProps: React.ComponentProps<T> })
| null;
export type ElementType = keyof JSX.IntrinsicElements | ComponentType<any>;

export type ActionableType<T extends ElementType = ElementType> = {
parent: T;
parentProps: T extends keyof JSX.IntrinsicElements
? JSX.IntrinsicElements[T]
: T extends ComponentType<infer P>
? P
: never;
} | null;

0 comments on commit 27a15d0

Please sign in to comment.