sodiray / radash

Functional utility library - modern, simple, typed, powerful
https://radash-docs.vercel.app
MIT License
4.1k stars 160 forks source link

Make types for capitalize infer format for constant strings #414

Open rafawendel opened 2 months ago

rafawendel commented 2 months ago

This PR improves the types of capitalize on string.ts

Description

Instead of hardcoded string types, I've leveraged generic functions and TS' Capitalize to infer the type for constant strings.

Checklist

Resolves

If the PR resolves an open issue tag it here. For example, Resolves #34

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radash-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2024 6:36pm
aleclarson commented 1 month ago

The built-in Capitalize type does not match the behavior of Radash capitalize.

type Foo = Capitalize<'foo Bar'>
//   ^? 'Foo Bar'

let foo = _.capitalize('foo Bar')
// => 'Foo bar'