mirror of
https://github.com/SamyRai/tercul-frontend.git
synced 2025-12-27 04:51:34 +00:00
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:
parent
6b3304d059
commit
8e6df7d0cc
@ -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>;
|
||||||
|
|||||||
@ -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
13
tsconfig.node.json
Normal 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"]
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user