Should we expand this library beyond strings? #51
Replies: 1 comment
-
going beyond stringsI think what is important is for the library to have a clear focus. As I understand it, the current focus is "strongly typed utilities function for strings" which seems quite clear. defining a strongly typed
|
Beta Was this translation helpful? Give feedback.
-
As I keep saying over and over, the goal of this library is to have strongly-typed functions that work seamlessly between type and runtime worlds.
This concepts perfectly applies to strings, but what if we could start going beyond strings?
We actually already have a method that works on Array:
join
but I started thinking we could also be adding more methods to improve the DX of TS folks in general.With that in mind I was playing this morning with the following:
I know the folks from
ts-reset
(@mattpocock) are discouraging) strongly typingObject.keys
andObject.entries
but I think the goal of that library is completely different as they aim to solve some weaknesses of TS without being overly intrusive because it changes your whole codebase. But instring-ts
we can import functions on demand for maybe just a couple cases in a whole codebase.We know a type may deviate from its runtime value but shouldn't we be able to choose when to trust our guts?
@colinhacks wrote an amazing case about it when he was trying to implement end-to-end type-safety in Remix despite the Remix core team back then were not in favor of it.
So if we drop the purism we might excel in DX.
And as we move on with our tree-shaking capabilities I think it should be safe to add more methods.
Going back to the example on the image above, notice that
objKeys
is NOT returning('a' | 'b' | 'c')[]
which is quite easy but it is returning['a', 'b', 'c']
which is a much harder problem and thus it may improve the overall DX to a whole new level.These are just random thoughts I had today and would love to hear some opinions on it.
@p9f , @jly36963 , others?
Beta Was this translation helpful? Give feedback.
All reactions