|
|
|
|
|
by SebastianKra
197 days ago
|
|
Have you engaged with the advanced features? TS is the only mainstream language that lets you express pretty much everything in the typesystem, to the point where I frequently have to hold myself back. Having used Swift and Kotlin in the past, their typesystems don’t come close to the flexibility with which you can wrangle data in TS. Many concepts that I would consider fundamental are either not present or require complicated syntax eg.: product types A & B, sum types A | B, { …spreading }. And where Swift needs custom syntax such as `guard let` and `case let` to narrow types, Typescript is able to analyze normal control flow. For practical reasons, there are a ton of ugly workarounds, but I’d rather live with those than go back to the rigid “Java++” languages. |
|
those are intersection types and union types and are much more unique and rare in type systems eg all typed functional languages have product/sum types but typescript is the only mainstream language I know to have unions and intersection.