Content pfp
Content
@
0 reply
0 recast
0 reaction

Nicholas Charriere pfp
Nicholas Charriere
@pushix
I was looking at google's new node SDK for gemini. I like this "disjoint types" pattern. A very good way to make your TypeScript very readable + meaningful, I have used something similar, but not with the "never" trick.
9 replies
0 recast
9 reactions

Nicholas Charriere pfp
Nicholas Charriere
@pushix
We made a change today in Axflow that follows this pattern đŸ’Ș https://github.com/axflow/axflow/pull/104/files
0 reply
0 recast
0 reaction

Darryl Yeo đŸ› ïž pfp
Darryl Yeo đŸ› ïž
@darrylyeo
Looks like we need a /typescript channel!
0 reply
0 recast
1 reaction

Darryl Yeo đŸ› ïž pfp
Darryl Yeo đŸ› ïž
@darrylyeo
The caveat with this “optional never” approach is that it still allows the property to be set to undefined. This may not be what you want if your logic depends on the presence or non-presence of a property, i.e. using the JavaScript “in” operator.
1 reply
0 recast
1 reaction

Zach pfp
Zach
@zachterrell
yeah i love doing this
0 reply
0 recast
1 reaction

Gabriel Ayuso pfp
Gabriel Ayuso
@gabrielayuso.eth
I usually do this with protobufs' oneof Didn't know about `never`. Nice feature.
0 reply
0 recast
1 reaction

 stringtheory pfp
stringtheory
@stringtheory69
Can u elaborate?
1 reply
0 recast
0 reaction

Cassie Heart pfp
Cassie Heart
@cassie
Discriminated Unions are a good feature, if only typescript had a better way to actually identify the type (I know it’s javascript’s fault it can’t, but I still wish it did)
2 replies
0 recast
3 reactions