Skip to content

Improve README utility examples#208

Open
rafael81 wants to merge 2 commits into
piotrwitek:masterfrom
rafael81:docs/improve-readme-examples
Open

Improve README utility examples#208
rafael81 wants to merge 2 commits into
piotrwitek:masterfrom
rafael81:docs/improve-readme-examples

Conversation

@rafael81

@rafael81 rafael81 commented May 12, 2026

Copy link
Copy Markdown

Summary

  • add missing README usage examples for several built-in and utility types
  • fix incorrect or incomplete README snippets for ValuesType, Mutable, UnionToIntersection, and Class

Fixes #51

Validation

  • git diff --check

Transparency

I used AI assistance to identify documentation gaps, draft the README-only changes, and review the diff. I manually checked the final patch and validation output before submitting.

Funded issue


IssueHunt Summary

Referenced issues

This pull request has been submitted to:


@rafael81

Copy link
Copy Markdown
Author

Follow-up for maintainers: after opening this I noticed IssueHunt lists #207, which did not appear in my earlier GitHub PR search. I kept this PR scoped to additional README gaps and snippet fixes that are not covered by #207, rather than duplicating its Record/Parameters/ConstructorParameters additions. If you prefer these to be consolidated into the other PR, I am happy to close this one.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the README.md by adding usage examples for several utility types, including NonNullable, NonUndefined, Exclude, Extract, Partial, Readonly, ReturnType, and InstanceType. It also corrects existing examples for ValuesType, Mutable, UnionToIntersection, and Class to ensure they are syntactically valid and consistent. The review feedback suggests aligning the NonUndefined example with the NonNullable example by using the same base union type to improve clarity and comparability.

Comment thread README.md Outdated
Comment on lines +315 to +318
import { NonUndefined } from 'utility-types';

// Expect: string | null
type NonUndefinedName = NonUndefined<string | null | undefined>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this example is correct, it is slightly inconsistent with the NonNullable example above (line 303) which uses string | number | null | undefined. For better clarity and easier comparison between NonNullable and NonUndefined, consider using the same base union type in both examples.

Suggested change
import { NonUndefined } from 'utility-types';
// Expect: string | null
type NonUndefinedName = NonUndefined<string | null | undefined>;
import { NonUndefined } from 'utility-types';
// Expect: string | number | null
type NonUndefinedName = NonUndefined<string | number | null | undefined>;

@rafael81

Copy link
Copy Markdown
Author

Addressed the review note by aligning the NonUndefined example with the same base union used in the NonNullable example.

Validation: git diff --check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve organization and add missing examples in API documentation

1 participant