Skip to content

Conversation

@tassoevan
Copy link
Collaborator

Proposed changes (including videos or screenshots)

It ensures the return type of capitalize is a capitalization of the input e.g. capitalize('example' as const) returns the string literal type Capitalize<'example'>, equivalent to 'Example'.

Issue(s)

Further comments

It leverages the utility type Capitalize<T> to avoid widening the type of the input.

@tassoevan tassoevan requested review from a team and Copilot August 8, 2025 22:42
@changeset-bot
Copy link

changeset-bot bot commented Aug 8, 2025

🦋 Changeset detected

Latest commit: 01890c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@rocket.chat/string-helpers Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the capitalize function in the string-helpers package to preserve TypeScript string literal types. Instead of returning a generic string type, the function now returns Capitalize<T> where T is the input string literal type.

  • Updated function signature to use generics with Capitalize<T> utility type
  • Added type assertions to maintain type safety while preserving literal types
  • Added changeset documentation for the feature enhancement

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/string-helpers/src/capitalize.ts Enhanced function signature and return type to preserve string literal types using TypeScript generics
.changeset/ripe-numbers-deny.md Added changeset entry documenting the new feature

@tassoevan tassoevan merged commit d967a2a into main Aug 18, 2025
7 checks passed
@tassoevan tassoevan deleted the feat/capitalize-type branch August 18, 2025 17:46
This was referenced Aug 18, 2025
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.

2 participants