From 8e6df7d0ccfa0a34eb2680748a9a66b571b1594e Mon Sep 17 00:00:00 2001 From: Damir Mukimov Date: Sun, 30 Nov 2025 14:55:58 +0100 Subject: [PATCH] feat: Add missing shared schema types and fix TypeScript imports - Add AuthorWithStats and AnnotationWithUser schemas with relations - Add corresponding TypeScript type exports - Update tsconfig.json with @shared/* path mapping - Fix @shared/schema import issues across components - Resolve major TypeScript compilation errors Next: Fix remaining type mismatches and component prop issues --- shared/schema.ts | 21 +++++++++++++++++++++ tsconfig.json | 8 +++++--- tsconfig.node.json | 13 +++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 tsconfig.node.json diff --git a/shared/schema.ts b/shared/schema.ts index 4bdbdd2..099088e 100644 --- a/shared/schema.ts +++ b/shared/schema.ts @@ -522,6 +522,23 @@ export const updateTopicClusterSchema = createTopicClusterSchema.partial(); export const updateWorkStatsSchema = createWorkStatsSchema.partial(); export const updateUserStatsSchema = createUserStatsSchema.partial(); +// Schemas with relations +export const annotationWithUserSchema = annotationSchema.extend({ + user: z.object({ + name: z.string(), + avatar: z.string().optional(), + }), + likes: z.number().optional(), + liked: z.boolean().optional(), +}); + +export const authorWithStatsSchema = authorSchema.extend({ + works_count: z.coerce.number().int().optional(), + average_rating: z.coerce.number().optional(), + followers_count: z.coerce.number().int().optional(), + total_reads: z.coerce.number().int().optional(), +}); + // TypeScript types inferred from Zod schemas export type User = z.infer; export type Author = z.infer; @@ -554,6 +571,10 @@ export type TopicCluster = z.infer; export type WorkStats = z.infer; export type UserStats = z.infer; +// New types with relations +export type AnnotationWithUser = z.infer; +export type AuthorWithStats = z.infer; + // Input types export type CreateUser = z.infer; export type CreateAuthor = z.infer; diff --git a/tsconfig.json b/tsconfig.json index d0cf02c..35ed2cb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,10 +17,12 @@ "noFallthroughCasesInSwitch": true, "types": ["jest", "@testing-library/jest-dom"], "esModuleInterop": true, + "baseUrl": ".", "paths": { - "@/*": ["./client/src/*"] + "@/*": ["./client/src/*"], + "@shared/*": ["./shared/*"] } }, - "include": ["src", "**/*.ts", "**/*.tsx"], - "references": [{ "path": "./tsconfig.node.json" }] + "include": ["src", "client", "server", "shared", "playwright.config.ts"], + "exclude": ["node_modules", "dist"] } diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 0000000..820f222 --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "composite": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, + "strict": true, + "types": ["node"] + }, + "include": ["vite.config.ts", "server/**/*.ts", "shared/**/*.ts"] +}