You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disclaimer: Since that PR I'm now also a co-maintainer of type-fest. That doesn't make me less of a fan of the work @sindresorhus and others has put into it though, hence I want to share.
I've used CamelCase<> myself when working with database queries, where all columns have been snake-cased, and the rest of my code, where the same properties have been camel-cased.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In type-fest v0.20.0 a PR of mine got merged that, together with the new TypeScript 4.1 release, enables new custom type helpers like
CamelCase<>
.Disclaimer: Since that PR I'm now also a co-maintainer of
type-fest
. That doesn't make me less of a fan of the work @sindresorhus and others has put into it though, hence I want to share.I've used
CamelCase<>
myself when working with database queries, where all columns have been snake-cased, and the rest of my code, where the same properties have been camel-cased.Using
CamelCase<>
I created the following:TypeScript-flavor:
JSDoc-flavor:
Which I could then use to convert the type of a database result to the type that my JS wants:
Nice to be able to get less repetition of types and more guarantees that two types actually match in everything but their property casing.
(And this is just one of the things that the template literal types in TypeScript 4.1 enables)
Beta Was this translation helpful? Give feedback.
All reactions