import { Checking, type Test } from "hry-types"; import type { IfExtends } from "hry-types/src/Any/IfExtends"; import type { ComponentDoc } from "../api/DefineComponent/ReturnType/ComponentDoc"; // import type { ComponentDoc } from "../api/DefineComponent/CreateDoc/ComponentDoc"; type _ReplacePrefix = { [k in keyof O as k extends `${string}_${infer L}` ? `${TPrefix}_${L}` : k]: O[k]; }; /** * 更改文档前缀 * @param TComponentDoc - ComponentDoc * @returns ComponentDoc */ export type ReplacePrefix = & IfExtends< unknown, TComponentDoc["properties"], {}, { properties: _ReplacePrefix; } > & IfExtends< unknown, TComponentDoc["customEvents"], {}, { customEvents: _ReplacePrefix } >; type Test1 = ReplacePrefix<{ properties: { xxx_name: string } }, "xxxDaa">; type Test1Expect = { properties: { xxxDaa_name: string } }; Checking; type Test2 = ReplacePrefix<{ customEvents: { xxx_name: string } }, "xxxDaa">; type Test2Expect = { customEvents: { xxxDaa_name: string } }; Checking; type Test3 = ReplacePrefix<{}, "xxxDaa">; type Test3Expect = {}; Checking;