From 587af33179e363b848db5bfb079ea292b7f7b913 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Fri, 14 Mar 2025 14:42:45 -0300 Subject: [PATCH] perf: Use built types for appRouter (#20083) * perf: Use built types for appRouter * Got it working just for server * Added dependency to turbo.json --- apps/web/app/_trpc/client.ts | 2 +- apps/web/app/_trpc/trpc-provider.tsx | 2 +- apps/web/components/apps/MultiDisconnectIntegration.tsx | 2 +- .../getting-started/steps-views/SetupAvailability.tsx | 2 +- .../ui/UsernameAvailability/PremiumTextfield.tsx | 2 +- .../ui/UsernameAvailability/UsernameTextfield.tsx | 2 +- apps/web/components/ui/UsernameAvailability/index.tsx | 2 +- apps/web/modules/settings/my-account/profile-view.tsx | 2 +- packages/trpc/tsconfig.json | 7 ++++--- turbo.json | 6 ++++-- 10 files changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/web/app/_trpc/client.ts b/apps/web/app/_trpc/client.ts index 6f1cb3a2eb..978570ed05 100644 --- a/apps/web/app/_trpc/client.ts +++ b/apps/web/app/_trpc/client.ts @@ -1,4 +1,4 @@ -import type { AppRouter } from "@calcom/trpc/server/routers/_app"; +import type { AppRouter } from "@calcom/trpc/types/server/routers/_app"; import { createTRPCReact } from "@trpc/react-query"; diff --git a/apps/web/app/_trpc/trpc-provider.tsx b/apps/web/app/_trpc/trpc-provider.tsx index 2b8f3b8c3b..9c0cbcd048 100644 --- a/apps/web/app/_trpc/trpc-provider.tsx +++ b/apps/web/app/_trpc/trpc-provider.tsx @@ -7,7 +7,7 @@ import { useState } from "react"; import superjson from "superjson"; import { ENDPOINTS } from "@calcom/trpc/react/shared"; -import type { AppRouter } from "@calcom/trpc/server/routers/_app"; +import type { AppRouter } from "@calcom/trpc/types/server/routers/_app"; import { httpBatchLink, httpLink, loggerLink, splitLink, TRPCClientError } from "@trpc/client"; diff --git a/apps/web/components/apps/MultiDisconnectIntegration.tsx b/apps/web/components/apps/MultiDisconnectIntegration.tsx index ad9d48b5ba..fdf09d3e44 100644 --- a/apps/web/components/apps/MultiDisconnectIntegration.tsx +++ b/apps/web/components/apps/MultiDisconnectIntegration.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; -import type { AppRouter } from "@calcom/trpc/server/routers/_app"; +import type { AppRouter } from "@calcom/trpc/types/server/routers/_app"; import { Button, Dropdown, diff --git a/apps/web/components/getting-started/steps-views/SetupAvailability.tsx b/apps/web/components/getting-started/steps-views/SetupAvailability.tsx index 8108537125..e077aa06de 100644 --- a/apps/web/components/getting-started/steps-views/SetupAvailability.tsx +++ b/apps/web/components/getting-started/steps-views/SetupAvailability.tsx @@ -4,7 +4,7 @@ import { Schedule } from "@calcom/features/schedules"; import { DEFAULT_SCHEDULE } from "@calcom/lib/availability"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; -import type { AppRouter } from "@calcom/trpc/server/routers/_app"; +import type { AppRouter } from "@calcom/trpc/types/server/routers/_app"; import { Button, Form } from "@calcom/ui"; import type { TRPCClientErrorLike } from "@trpc/client"; diff --git a/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx b/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx index ac9e0282db..ecfcf456a0 100644 --- a/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx +++ b/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx @@ -14,7 +14,7 @@ import { useDebounce } from "@calcom/lib/hooks/useDebounce"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import type { RouterOutputs } from "@calcom/trpc/react"; import { trpc } from "@calcom/trpc/react"; -import type { AppRouter } from "@calcom/trpc/server/routers/_app"; +import type { AppRouter } from "@calcom/trpc/types/server/routers/_app"; import { Button, Dialog, DialogClose, DialogContent, DialogFooter, Input, Label } from "@calcom/ui"; import { Icon } from "@calcom/ui"; diff --git a/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx b/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx index 0b472302fa..47502be4b8 100644 --- a/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx +++ b/apps/web/components/ui/UsernameAvailability/UsernameTextfield.tsx @@ -9,7 +9,7 @@ import { fetchUsername } from "@calcom/lib/fetchUsername"; import { useDebounce } from "@calcom/lib/hooks/useDebounce"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc/react"; -import type { AppRouter } from "@calcom/trpc/server/routers/_app"; +import type { AppRouter } from "@calcom/trpc/types/server/routers/_app"; import { Button, Dialog, DialogClose, DialogContent, TextField, DialogFooter, Tooltip } from "@calcom/ui"; import { Icon } from "@calcom/ui"; diff --git a/apps/web/components/ui/UsernameAvailability/index.tsx b/apps/web/components/ui/UsernameAvailability/index.tsx index 530ca656f8..820cf123ac 100644 --- a/apps/web/components/ui/UsernameAvailability/index.tsx +++ b/apps/web/components/ui/UsernameAvailability/index.tsx @@ -7,7 +7,7 @@ import { Controller, useForm } from "react-hook-form"; import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider"; import { WEBSITE_URL, IS_SELF_HOSTED } from "@calcom/lib/constants"; import { trpc } from "@calcom/trpc/react"; -import type { AppRouter } from "@calcom/trpc/server/routers/_app"; +import type { AppRouter } from "@calcom/trpc/types/server/routers/_app"; import useRouterQuery from "@lib/hooks/useRouterQuery"; diff --git a/apps/web/modules/settings/my-account/profile-view.tsx b/apps/web/modules/settings/my-account/profile-view.tsx index e049aba361..ae9f926a02 100644 --- a/apps/web/modules/settings/my-account/profile-view.tsx +++ b/apps/web/modules/settings/my-account/profile-view.tsx @@ -21,7 +21,7 @@ import turndown from "@calcom/lib/turndownService"; import { IdentityProvider } from "@calcom/prisma/enums"; import type { RouterOutputs } from "@calcom/trpc/react"; import { trpc } from "@calcom/trpc/react"; -import type { AppRouter } from "@calcom/trpc/server/routers/_app"; +import type { AppRouter } from "@calcom/trpc/types/server/routers/_app"; import { Alert, Button, diff --git a/packages/trpc/tsconfig.json b/packages/trpc/tsconfig.json index 4a192b93e4..101aeb3e01 100644 --- a/packages/trpc/tsconfig.json +++ b/packages/trpc/tsconfig.json @@ -21,9 +21,9 @@ "../types/tanstack-table.d.ts", "../types/next.d.ts", "../types/window.d.ts", - "react" + "./server" ], - "exclude": ["**/node_modules/**", "types/router.d.ts"], + "exclude": ["**/node_modules/**", "./react", "./server/**/*.test.ts", "./server/**/*.spec.ts"], "compilerOptions": { "isolatedModules": false, "noEmit": false, @@ -32,6 +32,7 @@ "experimentalDecorators": true, "declarationMap": false, "resolveJsonModule": true, - "outFile": "types/router.d.ts" + "declarationDir": "types/server", + "moduleResolution": "node" } } diff --git a/turbo.json b/turbo.json index 09cb06cd78..f725dea3eb 100644 --- a/turbo.json +++ b/turbo.json @@ -183,10 +183,12 @@ "outputs": ["dist/**", "build/**"] }, "type-check": { - "cache": false + "cache": false, + "dependsOn": ["@calcom/trpc#build"] }, "type-check:ci": { - "cache": false + "cache": false, + "dependsOn": ["@calcom/trpc#build"] }, "@calcom/prisma#db-reset": { "cache": false,