docs: add missing built-in utility examples in API documentation#211
docs: add missing built-in utility examples in API documentation#211ncthuc2004 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds usage examples for the Partial, Readonly, ReturnType, and InstanceType utility types in the README.md. The review feedback suggests improving consistency with existing documentation by reusing type names in examples and ensuring consistent semicolon usage within object literals.
| type Props = { name: string; age: number; visible: boolean }; | ||
|
|
||
| // Expect: { name?: string; age?: number; visible?: boolean; } | ||
| type PartialProps = Partial<Props>; |
There was a problem hiding this comment.
For consistency with other shallow transformation utilities in this documentation (such as Pick, Omit, Optional, and Required), it is recommended to re-use the Props type name for the result instead of introducing PartialProps. Additionally, adding a trailing semicolon to the object literal properties aligns with the style used in the Optional and Required sections.
| type Props = { name: string; age: number; visible: boolean }; | |
| // Expect: { name?: string; age?: number; visible?: boolean; } | |
| type PartialProps = Partial<Props>; | |
| type Props = { name: string; age: number; visible: boolean; }; | |
| // Expect: { name?: string; age?: number; visible?: boolean; } | |
| type Props = Partial<Props>; |
| type Props = { name: string; age: number; visible: boolean }; | ||
|
|
||
| // Expect: { readonly name: string; readonly age: number; readonly visible: boolean; } | ||
| type ReadonlyProps = Readonly<Props>; |
There was a problem hiding this comment.
Similar to the Partial example, using the Props type name for the result and adding a trailing semicolon to the object literal properties would maintain consistency with other shallow transformation utilities like Pick, Omit, Optional, and Required elsewhere in the README.
| type Props = { name: string; age: number; visible: boolean }; | |
| // Expect: { readonly name: string; readonly age: number; readonly visible: boolean; } | |
| type ReadonlyProps = Readonly<Props>; | |
| type Props = { name: string; age: number; visible: boolean; }; | |
| // Expect: { readonly name: string; readonly age: number; readonly visible: boolean; } | |
| type Props = Readonly<Props>; |
Summary
Partial,Readonly,ReturnType, andInstanceTypeContext
This addresses the IssueHunt-funded docs improvement request in #51.
Testing
IssueHunt Summary
Referenced issues
This pull request has been submitted to: