typescript
项目的TypeScript规则。适用于匹配的文件:*.tsx,*.ts。
📖 中文导读:项目的TypeScript规则。适用于匹配的文件:*.tsx,*.ts。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
name: typescript description: Typescript rules for the project Applies to files matching: .tsx,.ts.
Typing Guidelines
- Avoid
anyat all cost. The types should work or they indicate a problem. - Never use
as "any"oras unknown asto solve/avoid type errors. The types should work or they indicate a problem. - Avoid using
asto cast to a specific type. The types should work or they indicate a problem.
Exports / Imports
- Never create index barrel files (index.ts, index.js)
- Always use direct imports with named exports
- Always use inline interfaces with function parameters
Examples
Good - Inline interface with function:
export function processData({
id,
name,
options,
}: {
id: string;
name: string;
options: ProcessingOptions;
}): ProcessedResult {
// implementation
}
Bad - Separated interface:
interface ProcessDataProps {
id: string;
name: string;
options: ProcessingOptions;
}
export function processDAta({
id,
name,
options,
}: ProcessDataProps): ProcessResult {
// Implementation
}