Why
PostSchema and the manually-maintained Post type declare incompatible blocks fields, so changes to the schema do not propagate to the type and the mismatch is invisible until a runtime failure.
Current state
io/notion/schemas/post.ts line 44–45 defines blocks: z.array(z.unknown()) in PostSchema. Line 54 declares blocks: GroupedBlock[] on the hand-written Post type. PostSchema is exported but never imported in production code, making it dead code that cannot enforce its contract.
Ideal state
Post is inferred directly from PostSchema via z.infer<typeof PostSchema>.
- A single source of truth exists for the
Post shape.
- Any change to the schema is automatically reflected in the type; divergence is a compile error.
Starting points
io/notion/schemas/post.ts — lines 44–45 (PostSchema.blocks) and line 54 (the hand-written Post.blocks to remove)
QA plan
- Open
io/notion/schemas/post.ts and verify Post is declared as type Post = z.infer<typeof PostSchema> rather than a hand-written interface.
- Change
PostSchema.blocks to a stricter type — expect TypeScript to reflect the change in Post automatically.
- Run
tsc --noEmit — expect no type errors.
Done when
Post is inferred from PostSchema and no hand-written Post interface with a separate blocks declaration exists.
Why
PostSchemaand the manually-maintainedPosttype declare incompatibleblocksfields, so changes to the schema do not propagate to the type and the mismatch is invisible until a runtime failure.Current state
io/notion/schemas/post.tsline 44–45 definesblocks: z.array(z.unknown())inPostSchema. Line 54 declaresblocks: GroupedBlock[]on the hand-writtenPosttype.PostSchemais exported but never imported in production code, making it dead code that cannot enforce its contract.Ideal state
Postis inferred directly fromPostSchemaviaz.infer<typeof PostSchema>.Postshape.Starting points
io/notion/schemas/post.ts— lines 44–45 (PostSchema.blocks) and line 54 (the hand-writtenPost.blocksto remove)QA plan
io/notion/schemas/post.tsand verifyPostis declared astype Post = z.infer<typeof PostSchema>rather than a hand-written interface.PostSchema.blocksto a stricter type — expect TypeScript to reflect the change inPostautomatically.tsc --noEmit— expect no type errors.Done when
Postis inferred fromPostSchemaand no hand-writtenPostinterface with a separateblocksdeclaration exists.