{"_id":"typescript-api-pro","_rev":"4127014","name":"typescript-api-pro","description":"A comprehensive TypeScript type utility library","dist-tags":{"beta":"1.0.0-beta.1","latest":"1.0.1"},"maintainers":[{"name":"jsonlee_12138","email":""}],"time":{"modified":"2026-03-01T18:25:32.000Z","created":"2025-03-25T17:01:31.537Z","1.0.1":"2025-10-30T06:19:41.054Z","1.0.0":"2025-08-11T10:00:35.834Z","1.0.0-beta.1":"2025-08-11T09:44:27.962Z","0.0.8":"2025-07-14T03:40:49.449Z","0.0.7":"2025-05-26T15:25:32.261Z","0.0.6":"2025-05-04T15:25:57.034Z","0.0.5":"2025-04-17T03:36:41.188Z","0.0.3":"2025-04-11T12:52:57.838Z","0.0.2":"2025-03-28T01:33:44.202Z","0.0.1":"2025-03-25T17:01:31.537Z"},"users":{},"author":"","repository":{"type":"git","url":"git+https://github.com/JsonLee12138/typescript-api-pro.git"},"versions":{"1.0.1":{"name":"typescript-api-pro","version":"1.0.1","description":"A comprehensive TypeScript type utility library","types":"types/index.d.ts","type":"module","repository":{"type":"git","url":"git+https://github.com/JsonLee12138/typescript-api-pro.git"},"bugs":{"url":"https://github.com/JsonLee12138/typescript-api-pro/issues","email":"lijunsong2@gmail.com"},"homepage":"https://jsonlee12138.github.io/typescript-api-pro/","scripts":{"publish:beta":"npm publish --tag beta","publish:release":"npm publish","check":"tsc --noEmit","test":"tsc --noEmit","oxlint":"oxlint","test:ui":"vitest --ui","lint:fix":"eslint --fix .","lint":"eslint ."},"keywords":[],"author":"","license":"MIT","devDependencies":{"@jsonlee/tsconfig":"workspace:^","oxlint":"^1.8.0","rolldown":"1.0.0-beta.29","rolldown-plugin-dts":"^0.14.1","typescript":"~5.6.2","happy-dom":"^14.0.0","@vitest/ui":"^2.0.0","vitest":"^2.0.0"},"_id":"typescript-api-pro@1.0.1","gitHead":"9f1bcb2a2352f489da09ec2cda78a5fc3424750d","_nodeVersion":"20.19.5","_npmVersion":"10.8.2","dist":{"shasum":"0e93b21c95cdb11081a2a12774b1c84500215e89","size":11877,"noattachment":false,"key":"/typescript-api-pro/-/typescript-api-pro-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/typescript-api-pro/download/typescript-api-pro-1.0.1.tgz"},"_npmUser":{"name":"jsonlee_12138","email":"lijunsong2@gmail.com"},"directories":{},"maintainers":[{"name":"jsonlee_12138","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-api-pro_1.0.1_1761805180823_0.7516605619033474"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-10-30T06:19:41.054Z","publish_time":1761805181054,"_source_registry_name":"default","_cnpm_publish_time":1761805181054},"1.0.0":{"name":"typescript-api-pro","version":"1.0.0","description":"A comprehensive TypeScript type utility library","types":"types/index.d.ts","type":"module","repository":{"type":"git","url":"git+https://github.com/JsonLee12138/typescript-api-pro.git"},"bugs":{"url":"https://github.com/JsonLee12138/typescript-api-pro/issues","email":"lijunsong2@gmail.com"},"homepage":"https://jsonlee12138.github.io/typescript-api-pro/","scripts":{"publish:beta":"npm publish --tag beta","publish:release":"npm publish","check":"tsc --noEmit","test":"tsc --noEmit","oxlint":"oxlint","test:ui":"vitest --ui","lint:fix":"eslint --fix .","lint":"eslint ."},"keywords":[],"author":"","license":"MIT","devDependencies":{"@jsonlee/tsconfig":"workspace:^","oxlint":"^1.8.0","rolldown":"1.0.0-beta.29","rolldown-plugin-dts":"^0.14.1","typescript":"~5.6.2","happy-dom":"^14.0.0","@vitest/ui":"^2.0.0","vitest":"^2.0.0"},"_id":"typescript-api-pro@1.0.0","gitHead":"719d89f33d24578d08c2a7a8f67385071dcd0635","_nodeVersion":"20.19.4","_npmVersion":"10.8.2","dist":{"shasum":"20f631c2b2250f53b2dbc7b8f6347f1d40def11d","size":10183,"noattachment":false,"key":"/typescript-api-pro/-/typescript-api-pro-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/typescript-api-pro/download/typescript-api-pro-1.0.0.tgz"},"_npmUser":{"name":"jsonlee_12138","email":"lijunsong2@gmail.com"},"directories":{},"maintainers":[{"name":"jsonlee_12138","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-api-pro_1.0.0_1754906435635_0.6612519572415865"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-08-11T10:00:35.834Z","publish_time":1754906435834,"_source_registry_name":"default","_cnpm_publish_time":1754906435834},"1.0.0-beta.1":{"name":"typescript-api-pro","version":"1.0.0-beta.1","description":"A comprehensive TypeScript type utility library","types":"types/index.d.ts","type":"module","repository":{"type":"git","url":"git+https://github.com/JsonLee12138/typescript-api-pro.git"},"bugs":{"url":"https://github.com/JsonLee12138/typescript-api-pro/issues","email":"lijunsong2@gmail.com"},"homepage":"https://jsonlee12138.github.io/hook-fetch/","scripts":{"publish:beta":"npm publish --tag beta","publish:release":"npm publish","check":"tsc --noEmit","test":"tsc --noEmit","oxlint":"oxlint","test:ui":"vitest --ui","lint:fix":"eslint --fix .","lint":"eslint ."},"keywords":[],"author":"","license":"MIT","devDependencies":{"@jsonlee/tsconfig":"workspace:^","oxlint":"^1.8.0","rolldown":"1.0.0-beta.29","rolldown-plugin-dts":"^0.14.1","typescript":"~5.6.2","happy-dom":"^14.0.0","@vitest/ui":"^2.0.0","vitest":"^2.0.0"},"_id":"typescript-api-pro@1.0.0-beta.1","readmeFilename":"README.md","gitHead":"7377bc9446721e67de4772b81261153cd6e3590e","_nodeVersion":"20.19.4","_npmVersion":"10.8.2","dist":{"shasum":"c55eac6b8558e82e83e66cd5ade559a8d76535f6","size":10191,"noattachment":false,"key":"/typescript-api-pro/-/typescript-api-pro-1.0.0-beta.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/typescript-api-pro/download/typescript-api-pro-1.0.0-beta.1.tgz"},"_npmUser":{"name":"jsonlee_12138","email":"lijunsong2@gmail.com"},"directories":{},"maintainers":[{"name":"jsonlee_12138","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-api-pro_1.0.0-beta.1_1754905467777_0.7284717688029783"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-08-11T09:44:27.962Z","publish_time":1754905467962,"_source_registry_name":"default","_cnpm_publish_time":1754905467962},"0.0.8":{"name":"typescript-api-pro","version":"0.0.8","description":"A comprehensive TypeScript type utility library","types":"types/index.d.ts","repository":{"type":"git","url":"git+https://github.com/JsonLee12138/typescript-api-pro.git"},"bugs":{"url":"https://github.com/JsonLee12138/typescript-api-pro/issues","email":"lijunsong2@gmail.com"},"scripts":{"test":"tsc --noEmit","check":"tsc --noEmit","ci:publish":"npm publish --access public","ci:beta":"npm publish --tag beta --access public"},"keywords":["typescript","types","utilities","type-utils"],"author":"","license":"MIT","_id":"typescript-api-pro@0.0.8","gitHead":"85ed162ddafeeb85d7e4b3f7c11e7625f1759823","homepage":"https://github.com/JsonLee12138/typescript-api-pro#readme","_nodeVersion":"20.19.3","_npmVersion":"10.8.2","dist":{"shasum":"fbcd1a93287cf8b23f784bdea27ecaad406df027","size":6805,"noattachment":false,"key":"/typescript-api-pro/-/typescript-api-pro-0.0.8.tgz","tarball":"http://registry.cnpm.dingdandao.com/typescript-api-pro/download/typescript-api-pro-0.0.8.tgz"},"_npmUser":{"name":"jsonlee_12138","email":"lijunsong2@gmail.com"},"directories":{},"maintainers":[{"name":"jsonlee_12138","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-api-pro_0.0.8_1752464449158_0.43247987742225513"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-07-14T03:40:49.449Z","publish_time":1752464449449,"_source_registry_name":"default","_cnpm_publish_time":1752464449449},"0.0.7":{"name":"typescript-api-pro","version":"0.0.7","description":"A comprehensive TypeScript type utility library","types":"types/index.d.ts","repository":{"type":"git","url":"git+https://github.com/JsonLee12138/typescript-api-pro.git"},"bugs":{"url":"https://github.com/JsonLee12138/typescript-api-pro/issues","email":"lijunsong2@gmail.com"},"scripts":{"test":"tsc --noEmit","check":"tsc --noEmit"},"keywords":["typescript","types","utilities","type-utils"],"author":"","license":"MIT","_id":"typescript-api-pro@0.0.7","gitHead":"aeee6b6c56c624e605b98ae89d1b832981dd9716","homepage":"https://github.com/JsonLee12138/typescript-api-pro#readme","_nodeVersion":"20.18.0","_npmVersion":"11.0.0","dist":{"shasum":"abdc35602770b83b4edc145e20be3494880937ba","size":6427,"noattachment":false,"key":"/typescript-api-pro/-/typescript-api-pro-0.0.7.tgz","tarball":"http://registry.cnpm.dingdandao.com/typescript-api-pro/download/typescript-api-pro-0.0.7.tgz"},"_npmUser":{"name":"jsonlee_12138","email":"lijunsong2@gmail.com"},"directories":{},"maintainers":[{"name":"jsonlee_12138","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-api-pro_0.0.7_1748273132078_0.7512176824933392"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-05-26T15:25:32.261Z","publish_time":1748273132261,"_source_registry_name":"default","_cnpm_publish_time":1748273132261},"0.0.6":{"name":"typescript-api-pro","version":"0.0.6","description":"A comprehensive TypeScript type utility library","types":"types/index.d.ts","repository":{"type":"git","url":"git+https://github.com/JsonLee12138/typescript-api-pro.git"},"bugs":{"url":"https://github.com/JsonLee12138/typescript-api-pro/issues","email":"lijunsong2@gmail.com"},"scripts":{"test":"tsc --noEmit","check":"tsc --noEmit"},"keywords":["typescript","types","utilities","type-utils"],"author":"","license":"MIT","_id":"typescript-api-pro@0.0.6","gitHead":"521e5fc894dd37060a8c82f3bb7d62f980e05ad0","homepage":"https://github.com/JsonLee12138/typescript-api-pro#readme","_nodeVersion":"20.18.0","_npmVersion":"11.0.0","dist":{"shasum":"f67517336695128c8954edc3bccaca60aa6c000a","size":5746,"noattachment":false,"key":"/typescript-api-pro/-/typescript-api-pro-0.0.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/typescript-api-pro/download/typescript-api-pro-0.0.6.tgz"},"_npmUser":{"name":"jsonlee_12138","email":"lijunsong2@gmail.com"},"directories":{},"maintainers":[{"name":"jsonlee_12138","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-api-pro_0.0.6_1746372356844_0.5240720411408244"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-05-04T15:25:57.034Z","publish_time":1746372357034,"_source_registry_name":"default","_cnpm_publish_time":1746372357034},"0.0.5":{"name":"typescript-api-pro","version":"0.0.5","description":"A comprehensive TypeScript type utility library","types":"types/index.d.ts","scripts":{"test":"tsc --noEmit","check":"tsc --noEmit"},"keywords":["typescript","types","utilities","type-utils"],"author":"","license":"MIT","_id":"typescript-api-pro@0.0.5","gitHead":"550812f3e6403b7d74d1b916c067e0e366ef2e42","_nodeVersion":"20.18.0","_npmVersion":"11.0.0","dist":{"shasum":"a361e6f1125111a68a4a9c72b50854c39ce5b166","size":5611,"noattachment":false,"key":"/typescript-api-pro/-/typescript-api-pro-0.0.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/typescript-api-pro/download/typescript-api-pro-0.0.5.tgz"},"_npmUser":{"name":"jsonlee_12138","email":"lijunsong2@gmail.com"},"directories":{},"maintainers":[{"name":"jsonlee_12138","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-api-pro_0.0.5_1744861001036_0.6808507177684839"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-04-17T03:36:41.188Z","publish_time":1744861001188,"_source_registry_name":"default","_cnpm_publish_time":1744861001188},"0.0.3":{"name":"typescript-api-pro","version":"0.0.3","description":"A comprehensive TypeScript type utility library","types":"types/index.d.ts","scripts":{"test":"tsc --noEmit","check":"tsc --noEmit"},"keywords":["typescript","types","utilities","type-utils"],"author":"","license":"MIT","_id":"typescript-api-pro@0.0.3","gitHead":"eca23ed7b573886b5f0793a5b05fae5908b027f0","_nodeVersion":"20.18.0","_npmVersion":"11.0.0","dist":{"shasum":"314a1c58ea9ae0d6ce969c36d0dbbbc421981d86","size":4813,"noattachment":false,"key":"/typescript-api-pro/-/typescript-api-pro-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/typescript-api-pro/download/typescript-api-pro-0.0.3.tgz"},"_npmUser":{"name":"jsonlee_12138","email":"lijunsong2@gmail.com"},"directories":{},"maintainers":[{"name":"jsonlee_12138","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-api-pro_0.0.3_1744375977639_0.41112537970897534"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-04-11T12:52:57.838Z","publish_time":1744375977838,"_source_registry_name":"default","_cnpm_publish_time":1744375977838},"0.0.2":{"name":"typescript-api-pro","version":"0.0.2","description":"A comprehensive TypeScript type utility library","types":"types/index.d.ts","scripts":{"test":"tsc --noEmit","check":"tsc --noEmit"},"keywords":["typescript","types","utilities","type-utils"],"author":"","license":"MIT","_id":"typescript-api-pro@0.0.2","gitHead":"c5f01375a52eb5cf0450b73564ffb101629eab7b","_nodeVersion":"20.18.0","_npmVersion":"11.0.0","dist":{"shasum":"1f14d67bc35fb109ee478db62f276ac5241a98d7","size":3146,"noattachment":false,"key":"/typescript-api-pro/-/typescript-api-pro-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/typescript-api-pro/download/typescript-api-pro-0.0.2.tgz"},"_npmUser":{"name":"jsonlee_12138","email":"lijunsong2@gmail.com"},"directories":{},"maintainers":[{"name":"jsonlee_12138","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-api-pro_0.0.2_1743125624018_0.47938991080954163"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-03-28T01:33:44.202Z","publish_time":1743125624202,"_source_registry_name":"default","_cnpm_publish_time":1743125624202},"0.0.1":{"name":"typescript-api-pro","version":"0.0.1","description":"A comprehensive TypeScript type utility library","types":"types/index.d.ts","scripts":{"test":"tsc --noEmit","check":"tsc --noEmit"},"keywords":["typescript","types","utilities","type-utils"],"author":"","license":"MIT","_id":"typescript-api-pro@0.0.1","gitHead":"034597d8fe66fc292cd81a683a707d632396c0cf","_nodeVersion":"20.18.0","_npmVersion":"11.0.0","dist":{"shasum":"a19a71afe6b2a1dedbac74f653eb1dfa54b0c1f0","size":3051,"noattachment":false,"key":"/typescript-api-pro/-/typescript-api-pro-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/typescript-api-pro/download/typescript-api-pro-0.0.1.tgz"},"_npmUser":{"name":"jsonlee_12138","email":"lijunsong2@gmail.com"},"directories":{},"maintainers":[{"name":"jsonlee_12138","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typescript-api-pro_0.0.1_1742922091335_0.9337328804252418"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-03-25T17:01:31.537Z","publish_time":1742922091537,"_source_registry_name":"default","_cnpm_publish_time":1742922091537}},"readme":"# Typescript API Reference\n\n[中文文档](https://github.com/JsonLee12138/typescript-api-pro/blob/main/README.md)\n\n## ???? Type Utilities\n\nTypeScript API Pro provides a complete set of type utilities organized into the following categories:\n\n- [Object Types](#object-types) - Object type utilities\n- [Array Types](#array-types) - Array type utilities\n- [Map Types](#map-types) - Map type utilities\n- [Set Types](#set-types) - Set type utilities\n- [String Types](#string-types) - String type utilities\n\n## Object Types\n\n### PropertyKey\n\nA union type representing all possible object property key types in JavaScript.\n\n```typescript\ntype PropertyKey = string | number | symbol;\n```\n\n#### Description\n\n- Includes all possible object property key types in JavaScript\n- Equivalent to TypeScript's built-in `PropertyKey` type\n\n#### Example\n\n```typescript\nconst strKey: PropertyKey = 'name'; // string key\nconst numKey: PropertyKey = 42; // number key\nconst symKey: PropertyKey = Symbol(); // symbol key\n```\n\n### AnyObject<T = any>\n\nCreates an object type with keys of type `PropertyKey` and values of generic type `T`.\n\n```typescript\ntype AnyObject<T = any> = Record<PropertyKey, T>;\n```\n\n#### Description\n\n- Generic parameter `T` defines the type of object values, defaults to `any`\n- Object keys can be any `PropertyKey` type\n- Useful for defining objects with flexible key types but consistent value types\n\n#### Example\n\n```typescript\n// Object with all string values\nconst strObject: AnyObject<string> = {\n  name: 'John',\n  1: 'One',\n  [Symbol('key')]: 'Symbol value'\n};\n\n// Object with all number values\nconst numObject: AnyObject<number> = {\n  count: 42,\n  1: 123,\n  [Symbol('key')]: 456\n};\n```\n\n### RequiredDependency<T, K, D>\n\nCreates a type where certain properties must either exist together or not exist at all.\n\n```typescript\ntype RequiredDependency<T, K extends keyof T, D extends keyof T>\n  = Omit<T, D> & (Partial<{ [P in K | D]: never }> | Required<Pick<T, K | D>>);\n```\n\n#### Type Parameters\n\n- `T`: Base object type\n- `K`: Key property\n- `D`: Dependent property\n\n#### Description\n\n- Ensures that when key property `K` exists, dependent property `D` must also exist\n- If key property `K` is not provided, dependent property `D` cannot be provided either\n- Useful for handling property dependencies in configuration objects or API parameters\n\n#### Example\n\n```typescript\ninterface Config {\n  name: string;\n  host?: string;\n  port?: number;\n}\n\n// Create a type where host and port must exist together or not at all\ntype ServerConfig = RequiredDependency<Config, 'host', 'port'>;\n\n// ✅ Valid: both host and port are provided\nconst config1: ServerConfig = {\n  name: 'server1',\n  host: 'localhost',\n  port: 8080\n};\n\n// ✅ Valid: neither host nor port is provided\nconst config2: ServerConfig = {\n  name: 'server2'\n};\n\n// ❌ Invalid: cannot provide host without port\nconst config3: ServerConfig = {\n  name: 'server3',\n  host: 'localhost' // Error\n};\n\n// ❌ Invalid: cannot provide port without host\nconst config4: ServerConfig = {\n  name: 'server4',\n  port: 8080 // Error\n};\n```\n\n### MutuallyWithObject<T>\n\nCreates a mutually exclusive object type where only one property from the base type T can be present.\n\n```typescript\ntype MutuallyWithObject<T extends AnyObject> = {\n  [K in keyof T]: { [P in K]: T[K] } & { [P in Exclude<keyof T, K>]?: never };\n}[keyof T];\n```\n\n#### Description\n\n- Ensures only one property from the specified set can exist in an object\n- Perfect for representing mutually exclusive options\n- Each property maintains its original type from T\n\n#### Example\n\n```typescript\ninterface LoginOptions {\n  username: string;\n  email: string;\n  phone: number;\n}\n\n// Create a type that only allows one login method at a time\ntype LoginMethod = MutuallyWithObject<LoginOptions>;\n\n// ✅ Valid: using only username\nconst login1: LoginMethod = {\n  username: 'user123'\n};\n\n// ✅ Valid: using only email\nconst login2: LoginMethod = {\n  email: 'user@example.com'\n};\n\n// ✅ Valid: using only phone\nconst login3: LoginMethod = {\n  phone: 13812345678\n};\n\n// ❌ Invalid: cannot provide multiple properties\nconst login4: LoginMethod = {\n  username: 'user123',\n  email: 'user@example.com' // Error\n};\n```\n\n### Mutually<T, K, O>\n\nCreates a union type where either property K is absent or property O is absent.\n\n```typescript\ntype Mutually<T extends AnyObject, K extends keyof T, O extends keyof T> = Omit<T, K> | Omit<T, O>;\n```\n\n#### Type Parameters\n\n- `T`: Base object type\n- `K`: First mutually exclusive property\n- `O`: Second mutually exclusive property\n\n#### Description\n\n- Ensures two specific properties cannot exist together in an object\n- Unlike MutuallyWithObject, other properties are allowed to coexist\n- Useful for handling mutual exclusivity between two specific properties\n\n#### Example\n\n```typescript\ninterface FormData {\n  name: string;\n  age: number;\n  personalId?: string;\n  passportNumber?: string;\n}\n\n// Create a type where personal ID and passport number are mutually exclusive\ntype IdentityFormData = Mutually<FormData, 'personalId', 'passportNumber'>;\n\n// ✅ Valid: providing personal ID, no passport number\nconst data1: IdentityFormData = {\n  name: 'John',\n  age: 30,\n  personalId: '110101199001011234'\n};\n\n// ✅ Valid: providing passport number, no personal ID\nconst data2: IdentityFormData = {\n  name: 'Jane',\n  age: 25,\n  passportNumber: 'G12345678'\n};\n\n// ✅ Valid: providing neither\nconst data3: IdentityFormData = {\n  name: 'Alex',\n  age: 40\n};\n\n// ❌ Invalid: cannot provide both properties\nconst data4: IdentityFormData = {\n  name: 'Sam',\n  age: 35,\n  personalId: '110101199001011234',\n  passportNumber: 'G12345678' // Error\n};\n```\n\n### Generic<R, K, T>\n\nCreates a new type that inherits all properties from the base type R but overwrites the type of a specific property K with type T.\n\n```typescript\ntype Generic<R extends AnyObject, K extends keyof R, T> = Omit<R, K> & { [P in K]: T };\n```\n\n#### Type Parameters\n\n- `R`: Base object type\n- `K`: Property key whose type needs to be overwritten\n- `T`: New property type\n\n#### Description\n\n- Preserves all properties from the original type\n- Replaces just the type of the specified property\n- Useful for extending or specializing existing types\n\n#### Example\n\n```typescript\ninterface User {\n  id: number;\n  name: string;\n  roles: string[];\n}\n\n// Create a new type that changes the roles property from string[] to a more specific Role[] type\ninterface Role {\n  id: number;\n  name: string;\n  permissions: string[];\n}\n\ntype EnhancedUser = Generic<User, 'roles', Role[]>;\n\n// ✅ Valid: roles is now of type Role[]\nconst user: EnhancedUser = {\n  id: 1,\n  name: 'John',\n  roles: [\n    { id: 1, name: 'admin', permissions: ['read', 'write', 'delete'] },\n    { id: 2, name: 'editor', permissions: ['read', 'write'] }\n  ]\n};\n```\n\n### OmitByObject<T, U>\n\nExclude all properties from type T that have the same key names as those in type U.\n\n```typescript\ntype OmitByObject<T, U> = Pick<T, Exclude<keyof T, keyof U>>;\n```\n\n#### Type Parameters\n\n- `T`: The source object type\n- `U`: The object type containing keys to be omitted\n\n#### Description\n\n- Excludes properties from the source object based on the keys of another object type.\n- More flexible than the standard `Omit`, as it can omit properties based on the structure of an entire object type.\n- Useful when you need to remove properties from one object that are present in the structure of another object.\n\n#### Example\n\n```typescript\ninterface Person {\n  name: string;\n  age: number;\n  address: string;\n  phone: string;\n}\n\ninterface ContactInfo {\n  address: string;\n  phone: string;\n  email: string;\n}\n\n// Create a type for personal information only, excluding contact info fields\ntype PersonalInfoOnly = OmitByObject<Person, ContactInfo>;\n\n// Equivalent to { name: string; age: number; }\nconst personalInfo: PersonalInfoOnly = {\n  name: 'Zhang San',\n  age: 30\n  // address and phone are omitted because they exist in ContactInfo\n};\n\n// Another example: Exclude common metadata fields\ninterface WithMetadata {\n  id: string;\n  createdAt: Date;\n  updatedAt: Date;\n}\n\ninterface Product extends WithMetadata {\n  name: string;\n  price: number;\n  description: string;\n}\n\n// Get only the business data of a product, excluding metadata\ntype ProductData = OmitByObject<Product, WithMetadata>;\n\n// Equivalent to { name: string; price: number; description: string; }\nconst productData: ProductData = {\n  name: 'Smartphone',\n  price: 3999,\n  description: 'The latest smartphone'\n  // id, createdAt, and updatedAt are omitted\n};\n```\n\n## Array Types\n\n### ArrayItem<T>\n\nA utility type that extracts the element type from an array type.\n\n```typescript\ntype ArrayItem<T extends any[]> = T[number];\n```\n\n#### Type Parameters\n\n- `T`: Any array type\n\n#### Description\n\n- Uses indexed access type `T[number]` to extract the element type from an array type\n- Can be used to get element types from arrays, tuples, or readonly arrays\n- Particularly useful when working with generic arrays, preserving specific type information of elements\n\n#### Example\n\n```typescript\n// Simple array type\ntype NumberArray = number[];\ntype NumberItem = ArrayItem<NumberArray>; // number\n\n// Tuple type\ntype StringNumberTuple = [string, number];\ntype TupleItem = ArrayItem<StringNumberTuple>; // string | number\n\n// Readonly array\ntype ReadonlyStringArray = ReadonlyArray<string>;\ntype ReadonlyItem = ArrayItem<ReadonlyStringArray>; // string\n\n// Generic array\ninterface User {\n  id: number;\n  name: string;\n}\n\ntype UserArray = User[];\ntype UserItem = ArrayItem<UserArray>; // User\n```\n\n### ValueOf<T>\n\nExtracts a union type of all property values from an object type.\n\n```typescript\ntype ValueOf<T> = T[keyof T];\n```\n\n#### Type Parameters\n\n- `T`: Any object type\n\n#### Description\n\n- Produces a union of all property value types of the object\n- Useful for type mapping, inference, and utility types\n\n#### Example\n\n```typescript\ninterface StatusMap {\n  success: 200;\n  notFound: 404;\n  error: 500;\n}\ntype StatusCode = ValueOf<StatusMap>; // 200 | 404 | 500\n```\n\n### KeyOf<T>\n\nGets a union type of all property keys of an object.\n\n```typescript\ntype KeyOf<T> = keyof T;\n```\n\n#### Type Parameters\n\n- `T`: Any object type\n\n#### Description\n\n- Equivalent to TypeScript's built-in `keyof` operator\n- Produces a union of all property names of the object\n\n#### Example\n\n```typescript\ninterface User {\n  id: number;\n  name: string;\n  age: number;\n}\ntype UserKeys = KeyOf<User>; // \"id\" | \"name\" | \"age\"\n```\n\n## Map Types\n\n### MapKeyOf<T>\n\nExtracts the key type from a Map type.\n\n```typescript\ntype MapKeyOf<T extends Map<any, any>> = T extends Map<infer K, any> ? K : never;\n```\n\n#### Type Parameters\n\n- `T` : Any Map type\n\n#### Description\n\n- Uses conditional types and the `infer` keyword to extract the key type from a Map type\n- Returns a union type of all possible keys in the Map\n- Returns `never` if the input is not a Map type\n\n#### Example\n\n```typescript\n// Basic usage\ntype StringNumberMap = Map<string, number>;\ntype Keys = MapKeyOf<StringNumberMap>; // string\n\n// Union key type\ntype UnionKeyMap = Map<string | number, boolean>;\ntype UnionKeys = MapKeyOf<UnionKeyMap>; // string | number\n\n// Literal key type\ntype LiteralMap = Map<'name' | 'age', string>;\ntype LiteralKeys = MapKeyOf<LiteralMap>; // 'name' | 'age'\n```\n\n### MapValueOf<T>\n\nExtracts the value type from a Map type.\n\n```typescript\ntype MapValueOf<T extends Map<unknown, unknown>> = T extends Map<unknown, infer V> ? V : never;\n```\n\n#### Type Parameters\n\n- `T`: Any Map type\n\n#### Description\n\n- Extracts the value type from a Map type\n- Returns a union type of all possible values in the Map\n\n#### Example\n\n```typescript\n// Basic usage\ntype StringNumberMap = Map<string, number>;\ntype Values = MapValueOf<StringNumberMap>; // number\n\n// Union value type\ntype UnionValueMap = Map<string, number | boolean>;\ntype UnionValues = MapValueOf<UnionValueMap>; // number | boolean\n\n// Object value type\ninterface User {\n  id: number;\n  name: string;\n}\ntype UserMap = Map<string, User>;\ntype UserValue = MapValueOf<UserMap>; // User\n```\n\n### MapToObject<T>\n\nConverts a Map type to an equivalent object type.\n\n```typescript\ntype MapToObject<T extends Map<unknown, unknown>> = {\n  [K in MapKeyOf<T> & PropertyKey]: T extends Map<unknown, infer V> ? V : never;\n};\n```\n\n#### Type Parameters\n\n- `T`: Any Map type\n\n#### Description\n\n- Converts a Map type to an equivalent object type\n- Only works correctly when the Map's key type is a subset of `PropertyKey` (string | number | symbol)\n- Preserves the original key-value relationships\n\n#### Example\n\n```typescript\n// String key Map\ntype StringMap = Map<'name' | 'age', string>;\ntype StringObject = MapToObject<StringMap>;\n// { name: string; age: string; }\n\n// Numeric key Map\ntype NumberMap = Map<1 | 2 | 3, boolean>;\ntype NumberObject = MapToObject<NumberMap>;\n// { 1: boolean; 2: boolean; 3: boolean; }\n\n// Practical example\nconst userMap: Map<'id' | 'name', string> = new Map([\n  ['id', '123'],\n  ['name', 'John']\n]);\n\n// Converted object type\ntype UserObject = MapToObject<typeof userMap>;\n// { id: string; name: string; }\n```\n\n### ObjectToMap<T>\n\nConverts an object type to an equivalent Map type.\n\n```typescript\ntype ObjectToMap<T extends AnyObject> = Map<keyof T, T[keyof T]>;\n```\n\n#### Type Parameters\n\n- `T`: Object type inheriting from `AnyObject`\n\n#### Description\n\n- Converts an object type to an equivalent Map type\n- Uses object keys as Map keys and object values as Map values\n\n#### Example\n\n```typescript\n// Basic object conversion\ninterface User {\n  id: number;\n  name: string;\n  active: boolean;\n}\ntype UserMap = ObjectToMap<User>;\n// Map<'id' | 'name' | 'active', number | string | boolean>\n\n// Configuration object conversion\ninterface Config {\n  host: string;\n  port: number;\n  ssl: boolean;\n}\ntype ConfigMap = ObjectToMap<Config>;\n// Map<'host' | 'port' | 'ssl', string | number | boolean>\n```\n\n### OmitMapKey<T, K>\n\nCreates a new Map type excluding specified keys.\n\n```typescript\ntype OmitMapKey<T extends Map<unknown, unknown>, K extends MapKeyOf<T>>\n  = T extends Map<infer Keys, infer V> ? Map<Exclude<Keys, K>, V> : never;\n```\n\n#### Type Parameters\n\n- `T`: Object type inheriting from AnyObject\n- `K`: Keys to exclude (must exist in T)\n\n#### Description\n\n- Creates a new Map type excluding specified keys\n- Preserves the original value type while removing specified key types\n- Similar to the Omit utility type for object types\n\n#### Example\n\n```typescript\n// Exclude single key\ntype OriginalMap = Map<'name' | 'age' | 'email', string>;\ntype WithoutEmail = OmitMapKey<OriginalMap, 'email'>;\n// Map<'name' | 'age', string>\n\n// Exclude multiple keys (using union type)\ntype WithoutNameAndAge = OmitMapKey<OriginalMap, 'name' | 'age'>;\n// Map<'email', string>\n```\n\n### PickMapKey<T, K>\n\nCreates a new Map type including only specified keys.\n\n```typescript\nexport type PickMapKey<T extends Map<unknown, unknown>, K extends MapKeyOf<T>>\n  = T extends Map<unknown, infer V> ? Map<K, V> : never;\n```\n\n#### Type Parameters\n\n- `T`: Object type inheriting from AnyObject\n- `K`: Keys to include (must exist in T)\n\n#### Description\n\n- Creates a new Map type including only specified keys\n- Preserves the original value type while selecting specific key types\n- Similar to the Pick utility type for object types\n\n#### Example\n\n```typescript\n// Select single key\ntype OriginalMap = Map<'name' | 'age' | 'email', string>;\ntype OnlyName = PickMapKey<OriginalMap, 'name'>;\n// Map<'name', string>\n\n// Select multiple keys\ntype NameAndAge = PickMapKey<OriginalMap, 'name' | 'age'>;\n// Map<'name' | 'age', string>\n```\n\n## Set Types\n\n### SetValueOf<T>\n\nExtracts the element type from a Set type.\n\n```typescript\ntype SetValueOf<T extends ReadonlySet<unknown>> = T extends ReadonlySet<infer V> ? V : never;\n```\n\n#### Type Parameters\n\n- `T`: Any Set type\n\n#### Description\n\n- Extracts the element type from a Set type using conditional types and `infer`\n- Returns a union type of all possible elements in the Set\n- Returns `never` if the input is not a Set type\n\n#### Example\n\n```typescript\n// Basic usage\ntype StringSet = Set<string>;\ntype StringElement = SetValueOf<StringSet>; // string\n\n// Union type elements\ntype MixedSet = Set<string | number | boolean>;\ntype MixedElement = SetValueOf<MixedSet>; // string | number | boolean\n\n// Literal type elements\ntype LiteralSet = Set<'red' | 'green' | 'blue'>;\ntype ColorElement = SetValueOf<LiteralSet>; // 'red' | 'green' | 'blue'\n\n// Object type elements\ninterface User {\n  id: number;\n  name: string;\n}\ntype UserSet = Set<User>;\ntype UserElement = SetValueOf<UserSet>; // User\n```\n\n### OmitSetValue<T, V>\n\nCreates a new Set type excluding specified value types.\n\n```typescript\ntype OmitSetValue<T extends Set<unknown>, V extends SetValueOf<T>>\n  = T extends Set<infer Values> ? Set<Exclude<Values, V>> : never;\n```\n\n#### Type Parameters\n\n- `T`: Any Set type\n- `V`: Values to exclude (must exist in T)\n\n#### Description\n\n- Creates a new Set type excluding specified element types\n- Uses the Exclude utility type to remove specified types from the union\n- Useful for scenarios requiring removal of specific element types from Sets\n\n#### Example\n\n```typescript\n// Exclude single value type\ntype OriginalSet = Set<'apple' | 'banana' | 'orange'>;\ntype WithoutApple = OmitSetValue<OriginalSet, 'apple'>;\n// Set<'banana' | 'orange'>\n\n// Exclude multiple value types\ntype WithoutFruits = OmitSetValue<OriginalSet, 'apple' | 'banana'>;\n// Set<'orange'>\n\n// Numeric example\ntype NumberSet = Set<1 | 2 | 3 | 4 | 5>;\ntype WithoutOddNumbers = OmitSetValue<NumberSet, 1 | 3 | 5>;\n// Set<2 | 4>\n```\n\n### PickSetValue<T, V>\n\nCreates a new Set type including only specified value types.\n\n```typescript\ntype PickSetValue<T extends Set<unknown>, V extends SetValueOf<T>> = Set<V>;\n```\n\n#### Type Parameters\n\n- `T`: Any Set type\n- `V`: Values to include (must exist in T)\n\n#### Description\n\n- Creates a new Set type including only specified element types\n- Directly constructs a new Set with the specified value types\n- Useful for extracting specific element types from existing Sets\n\n#### Example\n\n```typescript\n// Select value types\ntype OriginalSet = Set<'red' | 'green' | 'blue' | 'yellow'>;\ntype PrimaryColors = PickSetValue<OriginalSet, 'red' | 'green' | 'blue'>;\n// Set<'red' | 'green' | 'blue'>\n\n// Numeric selection\ntype NumberSet = Set<1 | 2 | 3 | 4 | 5>;\ntype EvenNumbers = PickSetValue<NumberSet, 2 | 4>;\n// Set<2 | 4>\n```\n\n### ArrayToSet<T>\n\nConverts an array type to an equivalent Set type.\n\n```typescript\ntype ArrayToSet<T extends readonly unknown[]> = Set<T[number]>;\n```\n\n#### Type Parameters\n\n- T: Any array type\n\n#### Description\n\n- Converts an array type to an equivalent Set type\n- Uses indexed access type `T[number]` to extract element types\n- Automatically deduplicates repeating element types\n\n#### Example\n\n```typescript\n// Basic array conversion\ntype StringArray = string[];\ntype StringSet = ArrayToSet<StringArray>; // Set<string>\n\n// Tuple conversion\ntype ColorTuple = ['red', 'green', 'blue', 'red'];\ntype ColorSet = ArrayToSet<ColorTuple>; // Set<'red' | 'green' | 'blue'>\n\n// Union type array\ntype MixedArray = (string | number)[];\ntype MixedSet = ArrayToSet<MixedArray>; // Set<string | number>\n\n// Practical example\nconst fruits = ['apple', 'banana', 'apple', 'orange'] as const;\ntype FruitSet = ArrayToSet<typeof fruits>;\n// Set<'apple' | 'banana' | 'orange'>\n```\n\n### SetToArray<T>\n\nConverts a Set type to an equivalent array type.\n\n```typescript\ntype SetToArray<T extends ReadonlySet<unknown>> = SetValueOf<T>[];\n```\n\n#### Type Parameters\n\n- `T`: Any array type\n\n#### Description\n\n- Converts a Set type to an equivalent array type\n- Extracts element types using SetValueOf and creates an array type\n- Provides the inverse operation of ArrayToSet\n\n#### Example\n\n```typescript\n// Basic Set conversion\ntype StringSet = Set<string>;\ntype StringArray = SetToArray<StringSet>; // string[]\n\n// Literal Set conversion\ntype ColorSet = Set<'red' | 'green' | 'blue'>;\ntype ColorArray = SetToArray<ColorSet>; // ('red' | 'green' | 'blue')[]\n\n// Object Set conversion\ninterface User {\n  id: number;\n  name: string;\n}\ntype UserSet = Set<User>;\ntype UserArray = SetToArray<UserSet>; // User[]\n\n// Practical example\nfunction convertSetToArray<T extends Set<any>>(set: T): SetToArray<T> {\n  return Array.from(set) as SetToArray<T>;\n}\n```\n\n## String Types\n\n### Camel2SnakeCase<T, U>\n\nConverts camelCase strings to snake_case format.\n\n```typescript\ntype Camel2SnakeCase<T extends string, U extends boolean = true> = /* ... */\n```\n\n#### Type Parameters\n\n- `T`: The camelCase string to convert\n- `U`: Whether to use uppercase (default: `true`)\n\n#### Description\n\n- Converts camelCase to snake_case format\n- Optionally converts to UPPER_SNAKE_CASE or lower_snake_case\n- Type-level transformation with zero runtime overhead\n- Useful for API requests/responses, database fields, environment variables, and other naming convention conversions\n\n#### Example\n\n```typescript\n// Convert to UPPER_SNAKE_CASE (default)\ntype Result1 = Camel2SnakeCase<'userName'>; // 'USER_NAME'\ntype Result2 = Camel2SnakeCase<'userId'>; // 'USER_ID'\ntype Result3 = Camel2SnakeCase<'myVariableName'>; // 'MY_VARIABLE_NAME'\n\n// Convert to lowercase snake_case\ntype Result4 = Camel2SnakeCase<'userName', false>; // 'user_name'\ntype Result5 = Camel2SnakeCase<'userId', false>; // 'user_id'\ntype Result6 = Camel2SnakeCase<'myVariableName', false>; // 'my_variable_name'\n\n// Practical use: API request object conversion\ninterface UserRequest {\n  firstName: string;\n  lastName: string;\n  emailAddress: string;\n}\n\n// Convert to backend API format (UPPER_SNAKE_CASE)\ntype ApiUserRequest = {\n  [K in keyof UserRequest as Camel2SnakeCase<K & string>]: UserRequest[K]\n};\n// Result: { FIRST_NAME: string; LAST_NAME: string; EMAIL_ADDRESS: string; }\n\n// Convert to database field format (lower_snake_case)\ntype DbUserModel = {\n  [K in keyof UserRequest as Camel2SnakeCase<K & string, false>]: UserRequest[K]\n};\n// Result: { first_name: string; last_name: string; email_address: string; }\n\n// Environment variable configuration\ninterface AppConfig {\n  databaseUrl: string;\n  apiKey: string;\n  maxConnections: number;\n}\n\ntype EnvVars = {\n  [K in keyof AppConfig as Camel2SnakeCase<K & string>]: string\n};\n// Result: { DATABASE_URL: string; API_KEY: string; MAX_CONNECTIONS: string; }\n\n// Type-safe conversion function\nfunction toSnakeCase<T extends Record<string, unknown>>(\n  obj: T,\n  uppercase = false\n): { [K in keyof T as Camel2SnakeCase<K & string, false>]: T[K] } {\n  const result: Record<string, unknown> = {};\n\n  for (const key in obj) {\n    const snakeKey = key.replace(/[A-Z]/g, letter =>\n      `_${uppercase ? letter : letter.toLowerCase()}`);\n    result[snakeKey] = obj[key];\n  }\n\n  return result as { [K in keyof T as Camel2SnakeCase<K & string, false>]: T[K] };\n}\n\nconst userData: UserRequest = {\n  firstName: 'John',\n  lastName: 'Doe',\n  emailAddress: 'john@example.com'\n};\n\nconst dbRecord = toSnakeCase(userData);\n// TypeScript ensures type safety\nconsole.log(dbRecord.first_name); // ✅ Valid\n// console.log(dbRecord.firstName); // ❌ Error: Property does not exist\n```\n\n## ???? Contribution Guide\n\nFeel free to submit `issues` or `pull requests` to help improve `Hook-Fetch`.\n\n## ???? License\n\nMIT\n\n## Contact US\n\n- [Discord](https://discord.gg/Ah55KD5d)\n","_attachments":{},"homepage":"https://jsonlee12138.github.io/typescript-api-pro/","bugs":{"url":"https://github.com/JsonLee12138/typescript-api-pro/issues","email":"lijunsong2@gmail.com"},"license":"MIT"}