refactor: replace Map type with Record#1173
Conversation
|
Visit the preview URL for this PR (updated for commit afa0d49): https://docusaurus-openapi-36b86--pr1173-77zxb08e.web.app (expires Sun, 27 Jul 2025 18:06:15 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: bf293780ee827f578864d92193b8c2866acd459f |
|
Switching from a custom interface Map to TypeScript’s native Record<string, T> improves both the clarity and interoperability of the OpenAPI type definitions: The file no longer declares its own Map type at the top; instead, each property that previously used Map now directly references Record<string, …> (see lines defining ServerObject and ComponentsObject) Operations, parameters, callbacks, and security-related objects all now specify their mappings via Record<string, …> rather than a custom container type Benefits Simpler code: Removing the custom Map interface eliminates an extra abstraction layer. Contributors immediately see that these objects are simple key–value mappings, without hunting down a custom type definition. TypeScript tooling: The built‑in Record type interacts seamlessly with the TypeScript compiler, editors, and IDEs—providing better autocomplete and error checking. Consistency with other projects: Most TypeScript codebases rely on Record for string-keyed objects. Using the standard pattern helps new contributors understand the structure more quickly. Overall, this change streamlines the type definitions and clarifies how the project models OpenAPI objects. The code remains fully type‑safe while benefiting from familiar, well-supported TypeScript constructs. |
Summary
Map<T>with standardRecord<string, T>for OpenAPI typesTesting
yarn lintyarn build-packagesyarn testhttps://chatgpt.com/codex/tasks/task_e_685ed9d1a0148323991549c0dc4f48ae