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
This commit is contained in:
Damir Mukimov 2025-11-30 14:55:58 +01:00
parent 6b3304d059
commit 8e6df7d0cc
No known key found for this signature in database
GPG Key ID: 42996CC7C73BC750
3 changed files with 39 additions and 3 deletions

View File

@ -522,6 +522,23 @@ export const updateTopicClusterSchema = createTopicClusterSchema.partial();
export const updateWorkStatsSchema = createWorkStatsSchema.partial(); export const updateWorkStatsSchema = createWorkStatsSchema.partial();
export const updateUserStatsSchema = createUserStatsSchema.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 // TypeScript types inferred from Zod schemas
export type User = z.infer<typeof userSchema>; export type User = z.infer<typeof userSchema>;
export type Author = z.infer<typeof authorSchema>; export type Author = z.infer<typeof authorSchema>;
@ -554,6 +571,10 @@ export type TopicCluster = z.infer<typeof topicClusterSchema>;
export type WorkStats = z.infer<typeof workStatsSchema>; export type WorkStats = z.infer<typeof workStatsSchema>;
export type UserStats = z.infer<typeof userStatsSchema>; export type UserStats = z.infer<typeof userStatsSchema>;
// New types with relations
export type AnnotationWithUser = z.infer<typeof annotationWithUserSchema>;
export type AuthorWithStats = z.infer<typeof authorWithStatsSchema>;
// Input types // Input types
export type CreateUser = z.infer<typeof createUserSchema>; export type CreateUser = z.infer<typeof createUserSchema>;
export type CreateAuthor = z.infer<typeof createAuthorSchema>; export type CreateAuthor = z.infer<typeof createAuthorSchema>;

View File

@ -17,10 +17,12 @@
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"types": ["jest", "@testing-library/jest-dom"], "types": ["jest", "@testing-library/jest-dom"],
"esModuleInterop": true, "esModuleInterop": true,
"baseUrl": ".",
"paths": { "paths": {
"@/*": ["./client/src/*"] "@/*": ["./client/src/*"],
"@shared/*": ["./shared/*"]
} }
}, },
"include": ["src", "**/*.ts", "**/*.tsx"], "include": ["src", "client", "server", "shared", "playwright.config.ts"],
"references": [{ "path": "./tsconfig.node.json" }] "exclude": ["node_modules", "dist"]
} }

13
tsconfig.node.json Normal file
View File

@ -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"]
}