Instruction file imported from tjx666/lobe-chat-vercel-test (
.cursor/rules/typescript.mdc). Copyright stays with the author.
description: globs: .ts,.tsx,*.mts alwaysApply: false
TypeScript Code Style Guide:
- Avoid explicit type annotations when TypeScript can infer types.
- Avoid defining
anytype variables (e.g.,let a: number;instead oflet a;). - Use the most accurate type possible (e.g., use
Record<PropertyKey, unknown>instead ofobject). - Prefer
interfaceovertype(e.g., define react component props). - Use
as const satisfies XyzInterfaceinstead ofas constwhen suitable - import index.ts module(directory module) like
@/db/indexinstead of@/db - Instead of calling Date.now() multiple times, assign it to a constant once and reuse it. This ensures consistency and improves readability
- Always refactor repeated logic into a reusable function
- Don't remove meaningful code comments, be sure to keep original comments when providing applied code
- Update the code comments when needed after you modify the related code
- Please respect my prettier preferences when you provide code
- Prefer object destructuring when accessing and using properties
- Prefer async version api than sync version, eg: use readFile from 'fs/promises' instead of 'fs'