woah typescript has enums I'm totally on board now
@Moon i heard general recommendation is to avoid using them lmao
@Moon these are also kinda shit given that they don't work how actual JS union works.

const a : A = { ... }
const b : B = { ... }

const ab = { ...a, ...b }
you'd think type of ab would be A & B but not necessarily so, especially if there's overlap between A and B properties.
Follow

@hj AFAIK union in programming usually means “type A or type B(…or type C, or type D…)”, persisting even in times of early C, where a union is a space in memory that can contain data of any of the union types, so you can for example make a float64, uint8[] union, write floats and read them as separate bytes etc.

This is not the same as “contents of type A and contents of type B”.

@hj haha yeah that is a simpler explanation I could have used

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.