nxy666-common-map-typescript-instructions.ocm.json json Copy{
"ocm": "1",
"id": "nxy666-common-map-typescript-instructions",
"kind": "skill",
"name": "typescript",
"description": "// 正确 function processData(data: string, maxLength: number = 100) { if (data.length > maxLength) { // ... } } ```",
"publisher": "NXY666",
"version": "1.0.0",
"capabilities": {
"domains": [
"coding"
],
"tags": [
"skill-md",
"github-instructions"
],
"languages": [
"en"
]
},
"quality_prior": 0.6,
"examples": [
"// 正确 function processData(data: string, maxLength: number = 100) { if (data.length > maxLength) { // ... } } ```"
],
"primary": false,
"metadata": {
"source": {
"provider": "github-instructions",
"repository": "https://github.com/NXY666/common-map",
"path": ".github/instructions/typescript.instructions.md",
"ref": "347fe666bf967834fe8820b2b2d25a2d91f4ac8c",
"url": "https://github.com/NXY666/common-map/blob/347fe666bf967834fe8820b2b2d25a2d91f4ac8c/.github/instructions/typescript.instructions.md",
"key": "NXY666/common-map/.github/instructions/typescript.instructions.md"
},
"applies_to": "**/*.ts"
},
"instructions": "# TypeScript 的项目编码标准\n\n## TypeScript 指南\n- 除非明确要求,所有新代码均使用 TypeScript,而不是 JavaScript。\n- 尽可能遵循函数式编程原则\n- 优先使用不可变数据 (const, readonly)\n- 使用可选链式调用 (?.) 和空值合并 (??) 运算符\n- 除非该变量确实允许赋值任意类型,否则永远禁止使用 any 和 unknown 。如果你不知道如何解决,请直接不加类型,报错没关系。\n- 禁止在未经允许的情况下将数字、字符串等提取为常量。如\n ```typescript\n // 禁止\n const MAX_LENGTH = 100;\n function processData(data: string) {\n if (data.length > MAX_LENGTH) {\n // ...\n }\n }\n \n // 正确\n function processData(data: string, maxLength: number = 100) {\n if (data.length > maxLength) {\n // ...\n }\n }\n ```",
"cost": {
"context_tokens": 139
}
}