typescript by lobehub/lobe-chat
npx skills add https://github.com/lobehub/lobe-chat --skill typescriptany;必要时显式声明类型Record<PropertyKey, unknown> 而非 object 或 anyinterface;对于联合/交叉类型使用 typeas const satisfies XyzInterface 而非普通的 as const@ts-expect-error > > 广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
@ts-ignoreas anydeclare module '...')而非 namespace;不要引入基于 namespace 的扩展模式PipelineContext.metadata 这样的包内可扩展性模式,在读取或写入它们的处理器/提供者/插件旁边定义元数字段async/await 而非回调或 .then() 链*Sync)import { readFile } from 'fs/promises'Promise.all、Promise.race 处理并发操作本项目使用 simple-import-sort/imports 和 consistent-type-imports(fixStyle: 'separate-type-imports')
分离类型导入:对于仅类型导入,始终使用 import type { ... },不要使用 import { type ... } 内联语法
当文件中已存在来自某个包的 import type { ... } 且你需要添加一个值导入时,请将它们保持为两条独立的语句:
import type { ChatTopicBotContext } from '@lobechat/types';
import { RequestTrigger } from '@lobechat/types';
在每个导入语句内部,导入项按名称字母顺序排序
@lobehub/ui、Ant Design 组件而非原始 HTML 标签antd-style 令牌系统而非硬编码的颜色for…of 循环而非基于索引的 for 循环packages/utils 中的现有工具函数或已安装的 npm 包Date.now() 赋值给一个常量并复用以保持一致性import { log } from 'debug'(会记录到控制台)console.error 而非 debug 包.catch() 回调中记录错误——静默的 .catch(() => fallback) 会吞掉失败信息,使调试变得不可能每周安装量
218
代码仓库
GitHub 星标数
74.2K
首次出现
2026年1月24日
安全审计
安装于
claude-code191
opencode181
gemini-cli167
cursor164
codex156
antigravity153
any; explicitly type when necessaryRecord<PropertyKey, unknown> over object or anyinterface for object shapes (e.g., React props); use type for unions/intersectionsas const satisfies XyzInterface over plain as const@ts-expect-error over @ts-ignore over as anydeclare module '...') over namespace; do not introduce namespace-based extension patternsPipelineContext.metadata, define the metadata fields next to the processor/provider/plugin that reads or writes themasync/await over callbacks or .then() chains*Sync)import { readFile } from 'fs/promises'Promise.all, Promise.race for concurrent operations where safeThis project uses simple-import-sort/imports and consistent-type-imports (fixStyle: 'separate-type-imports')
Separate type imports : always use import type { ... } for type-only imports, NOT import { type ... } inline syntax
When a file already has import type { ... } from a package and you need to add a value import, keep them as two separate statements :
import type { ChatTopicBotContext } from '@lobechat/types';
import { RequestTrigger } from '@lobechat/types';
Within each import statement, specifiers are sorted alphabetically by name
@lobehub/ui, Ant Design components instead of raw HTML tagsantd-style token system instead of hard-coded colorsfor…of loops over index-based for loopspackages/utils or installed npm packagesDate.now() to a constant once and reuse for consistencyimport { log } from 'debug' directly (logs to console)console.error in catch blocks instead of debug package.catch() callbacks — silent .catch(() => fallback) swallows failures and makes debugging impossibleWeekly Installs
218
Repository
GitHub Stars
74.2K
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code191
opencode181
gemini-cli167
cursor164
codex156
antigravity153
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
109,600 周安装