Closed VinSpee closed 2 years ago
I'd ideally like this too. However that would require the underlying object to be in this format:
const procedures = {
queries: {
post: {
all: () => {}
}
}
While this is nice, it might be hard to achieve this recursively and lead to the same sort of complexity costs that we have now. Not sure if it's possible even. Might have a stab at it.
Had a quick stab at 693b067
Got any ideas?
I guess it could also be done in that proxy object.... sort of parsing the strings and turning them into a new object based on the dot-notation, that should be possible.
Can also be solved by not using dot notation, you can use _
as a separator or CamelCase
your procedure names.
True, but there’s still the “magic” part On Jan 20, 2022, 00:56 -0500, Alex Johansson @.***>, wrote:
Can also be solved by not using dot notation, you can use _ as a separator or CamelCase your procedure names. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
Seems doable.
Then we'd need a recursive proxy object that would return the concatenated string as a result. Wanna have a stab at it?
I do think that the current DX is superior once you get used to it though:
['']
for youThe new recommended convention will be to camelCase
or snake_case
rather than dot notation.
https://github.com/trpc/v10-playground/blob/cfee1c2c2b03baa131d3bfcb50addc10ffe53d81/src/client.ts#L13
In my opinion, this syntax is unnatural in JS/TS. It’s acceptable when the value is just a string, but in this case, it’s a dot-separated string which is the property of an object. It feels quirky and IMO really exposes this as a DSL, a “magic string”.
Since we’re considering an alternative syntax anyway, is there a stance against making procedures referenceable as objects? Example:
thanks!