Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

String: Type-level helpers for more accurate string types #498

Merged
merged 7 commits into from
Sep 14, 2023

Conversation

TylorS
Copy link
Contributor

@TylorS TylorS commented Sep 13, 2023

I was looking through the docgen code, and noticed some usage of the stripMargin function which I had a need for recently and didn't know existed, which got me looking at the rest of the String module.

Initially I noticed toUpperCase and toLowerCase could easily be improved with the built-ins from TS, I figure those are fairly safe to continue to add here. There's also Capitalize and Uncapitalize built-ins, so I went ahead and added corresponding functions for them.

I also started adding some type-level helpers for some of the easier things to replicate in string functionality. I'm less sure we'll wanna include these types of things in this lib, but I figured I'd open a PR for discussion about it.

@changeset-bot
Copy link

changeset-bot bot commented Sep 13, 2023

🦋 Changeset detected

Latest commit: 0a89dfe

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

This PR includes changesets to release 1 package
Name Type
@effect/data Patch

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

feat: add capitalize and uncapitalize to use TS builtin types
@tim-smart
Copy link
Member

Looks nice :)

Would be a good idea to add some dtslint tests for this, to make sure there are no regressions over time.

Also, if you could run pnpm run docs while you are at it, that would be appreciated!

@TylorS
Copy link
Contributor Author

TylorS commented Sep 14, 2023

@tim-smart Cool, I can definitely start adding some test cases for these tomorrow sometime.

@TylorS
Copy link
Contributor Author

TylorS commented Sep 14, 2023

@tim-smart I've added some unit tests for the captialize and uncapitalize functions, and I've added some type-level tests for all the other helpers.

@tim-smart
Copy link
Member

Thanks, looking good! Once CI is passing and docs are updated (pnpm run docs) we can get this merged.

Also we can drop this to a patch release as it seems backwards compatible.

@TylorS
Copy link
Contributor Author

TylorS commented Sep 14, 2023

@tim-smart Got the docs updated, and fixed one of the examples that had a copy/paste error that failed the type-checks

@tim-smart
Copy link
Member

Thanks. I think you might not have the latest dev deps (we changed eslint plugins a few weeks back).
I can fix the lint issues, but FYI for next time :)

@tim-smart tim-smart merged commit 93b619b into Effect-TS:main Sep 14, 2023
1 check passed
@github-actions github-actions bot mentioned this pull request Sep 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants