Comment

Comment by elnygren

Good points!

Seems like for "6. Optional properties"

One should rather use tagged unions (see: Abstract Data Types, variants) that are usually written like this in TS:

    type Product = 
     | { type: 'digital', id: string, sizeInMb: number }
     | { type: 'physical', id: string, weightInKg: number }
At least I find it more elegant, concise and fun to work with :)
parent elnygren 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton