From 2cb50334868773b418cc6ef1b0463ed911a8caab Mon Sep 17 00:00:00 2001 From: Felipe Coutinho Date: Mon, 16 Mar 2026 01:24:04 +0000 Subject: [PATCH] fix: corrige tipagem compartilhada e compatibilidade do typecheck --- src/app/(landing-page)/page.tsx | 12 +++---- src/db/schema.ts | 5 +-- .../components/category-history-widget.tsx | 2 +- .../income-expense-balance-widget.tsx | 2 +- .../components/category-report-chart.tsx | 21 +++++++---- .../components/shared/anticipation-card.tsx | 2 +- src/shared/components/ui/chart.tsx | 35 ++++++++++++------- src/shared/components/ui/currency-input.tsx | 1 + src/shared/components/ui/spinner.tsx | 5 ++- .../lib/installments/anticipation-types.ts | 2 +- 10 files changed, 55 insertions(+), 32 deletions(-) diff --git a/src/app/(landing-page)/page.tsx b/src/app/(landing-page)/page.tsx index a1d3371..c625f7c 100644 --- a/src/app/(landing-page)/page.tsx +++ b/src/app/(landing-page)/page.tsx @@ -231,7 +231,7 @@ export default async function Page() {
- + Projeto Open Source @@ -378,7 +378,7 @@ export default async function Page() {
- + Conheça as telas

@@ -430,7 +430,7 @@ export default async function Page() {
- + O que tem aqui

@@ -514,7 +514,7 @@ export default async function Page() {
{/* Text content */}
- + App Android @@ -625,7 +625,7 @@ export default async function Page() {
- + Stack técnica

@@ -748,7 +748,7 @@ export default async function Page() {
- + Como usar

diff --git a/src/db/schema.ts b/src/db/schema.ts index b0c2f4e..a73d04a 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -1,5 +1,6 @@ import { relations, sql } from "drizzle-orm"; import { + type AnyPgColumn, boolean, date, index, @@ -536,7 +537,7 @@ export const installmentAnticipations = pgTable( .default("0"), transactionId: uuid("lancamento_id") .notNull() - .references(() => transactions.id, { onDelete: "cascade" }), + .references((): AnyPgColumn => transactions.id, { onDelete: "cascade" }), payerId: uuid("pagador_id").references(() => payers.id, { onDelete: "cascade", }), @@ -585,7 +586,7 @@ export const transactions = pgTable( isDivided: boolean("dividido").default(false), isAnticipated: boolean("antecipado").default(false), anticipationId: uuid("antecipacao_id").references( - () => installmentAnticipations.id, + (): AnyPgColumn => installmentAnticipations.id, { onDelete: "set null" }, ), createdAt: timestamp("created_at", { diff --git a/src/features/dashboard/components/category-history-widget.tsx b/src/features/dashboard/components/category-history-widget.tsx index 4cbaaf4..0bef612 100644 --- a/src/features/dashboard/components/category-history-widget.tsx +++ b/src/features/dashboard/components/category-history-widget.tsx @@ -387,7 +387,7 @@ export function CategoryHistoryWidget({ data }: CategoryHistoryWidgetProps) { return (
diff --git a/src/features/dashboard/components/income-expense-balance-widget.tsx b/src/features/dashboard/components/income-expense-balance-widget.tsx index 536eff1..d364d09 100644 --- a/src/features/dashboard/components/income-expense-balance-widget.tsx +++ b/src/features/dashboard/components/income-expense-balance-widget.tsx @@ -91,7 +91,7 @@ export function IncomeExpenseBalanceWidget({ return (
) { +function AreaTooltip({ + active, + payload, + label, +}: Partial>) { if (!active || !payload?.length) return null; const items = payload - .filter((entry) => Number(entry.value) > 0) - .sort((a, b) => Number(b.value) - Number(a.value)); + .filter((entry: TooltipPayloadEntry) => Number(entry.value) > 0) + .sort( + (a: TooltipPayloadEntry, b: TooltipPayloadEntry) => + Number(b.value) - Number(a.value), + ); if (items.length === 0) return null; @@ -50,9 +59,9 @@ function AreaTooltip({ active, payload, label }: TooltipProps) { {label}

- {items.map((entry) => ( + {items.map((entry: TooltipPayloadEntry) => (
diff --git a/src/features/transactions/components/shared/anticipation-card.tsx b/src/features/transactions/components/shared/anticipation-card.tsx index 8427d42..2c51c2f 100644 --- a/src/features/transactions/components/shared/anticipation-card.tsx +++ b/src/features/transactions/components/shared/anticipation-card.tsx @@ -34,7 +34,7 @@ export function AnticipationCard({ }: AnticipationCardProps) { const [isPending, startTransition] = useTransition(); - const isSettled = anticipation.transaction.isSettled === true; + const isSettled = anticipation.transaction?.isSettled === true; const canCancel = !isSettled; const formatDate = (date: Date) => { diff --git a/src/shared/components/ui/chart.tsx b/src/shared/components/ui/chart.tsx index 58ed675..37850c5 100644 --- a/src/shared/components/ui/chart.tsx +++ b/src/shared/components/ui/chart.tsx @@ -1,6 +1,13 @@ "use client"; import * as React from "react"; +import type { + LegendPayload as RechartsLegendPayload, + LegendProps as RechartsLegendProps, + TooltipContentProps as RechartsTooltipContentProps, + TooltipPayloadEntry, + TooltipValueType, +} from "recharts"; import * as RechartsPrimitive from "recharts"; import { cn } from "@/shared/utils/ui"; @@ -134,7 +141,7 @@ function ChartTooltipContent({ color, nameKey, labelKey, -}: React.ComponentProps & +}: Partial> & React.ComponentProps<"div"> & { hideLabel?: boolean; hideIndicator?: boolean; @@ -197,21 +204,21 @@ function ChartTooltipContent({
{payload .filter((item) => item.type !== "none") - .map((item, index) => { + .map((item: TooltipPayloadEntry, index) => { const key = `${nameKey || item.name || item.dataKey || "value"}`; const itemConfig = getPayloadConfigFromPayload(config, item, key); const indicatorColor = color || item.payload.fill || item.color; return (
svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5", indicator === "dot" && "items-center", )} > {formatter && item?.value !== undefined && item.name ? ( - formatter(item.value, item.name, item, index, item.payload) + formatter(item.value, item.name, item, index, payload) ) : ( <> {itemConfig?.icon ? ( @@ -250,7 +257,7 @@ function ChartTooltipContent({ {itemConfig?.label || item.name}
- {item.value && ( + {item.value !== undefined && item.value !== null && ( {item.value.toLocaleString()} @@ -274,12 +281,14 @@ function ChartLegendContent({ payload, verticalAlign = "bottom", nameKey, -}: React.ComponentProps<"div"> & - Pick & { - hideIcon?: boolean; - nameKey?: string; - }) { +}: React.ComponentProps<"div"> & { + payload?: ReadonlyArray; + verticalAlign?: RechartsLegendProps["verticalAlign"]; + hideIcon?: boolean; + nameKey?: string; +}) { const { config } = useChart(); + type LegendPayloadEntry = RechartsLegendPayload; if (!payload?.length) { return null; @@ -294,14 +303,14 @@ function ChartLegendContent({ )} > {payload - .filter((item) => item.type !== "none") - .map((item) => { + .filter((item: LegendPayloadEntry) => item.type !== "none") + .map((item: LegendPayloadEntry) => { const key = `${nameKey || item.dataKey || "value"}`; const itemConfig = getPayloadConfigFromPayload(config, item, key); return (
svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3", )} diff --git a/src/shared/components/ui/currency-input.tsx b/src/shared/components/ui/currency-input.tsx index 5bd2d55..cc4f105 100644 --- a/src/shared/components/ui/currency-input.tsx +++ b/src/shared/components/ui/currency-input.tsx @@ -63,6 +63,7 @@ export interface CurrencyInputProps > { value: string; onValueChange: (value: string) => void; + onChange?: React.ComponentProps["onChange"]; } export const CurrencyInput = React.forwardRef< diff --git a/src/shared/components/ui/spinner.tsx b/src/shared/components/ui/spinner.tsx index 8ce86e3..898a578 100644 --- a/src/shared/components/ui/spinner.tsx +++ b/src/shared/components/ui/spinner.tsx @@ -1,7 +1,10 @@ import { RiLoader4Line } from "@remixicon/react"; import { cn } from "@/shared/utils/ui"; -function Spinner({ className, ...props }: React.ComponentProps<"svg">) { +function Spinner({ + className, + ...props +}: React.ComponentProps) { return (