News for hackers. Stuff that matters.
Re:Problems with TypeScript in 2020 by julius_set on Thursday April 16, 2020 @02:40AM (#22886797)
All those features are present in other languages too, the premise that no other useful or mainstream languages don’t is false. For example Swift has all of those features.
Re:Problems with TypeScript in 2020 by DaiPlusPlus on Thursday April 16, 2020 @07:28AM (#22888325)
Swift doesn't have first-class intersection-types or discriminated-unions (it has a variation on Java's enum types, which are close, but not exactly the same, e.g. you can't use a custom type defined elsewhere as a discriminated-union type: you have to use an enum case as the containing type - this is not a huge problem, just an ergonomic frustration).

Additionally, I don't believe Swift supports true structural typing (i.e. Duck-typing). If you have a method that accepts a protocol-implementing object, that object has to explicitly implement that protocol, it can't be inferred by the compiler.

In a similar vein, C# also supports intersection type (but only intersection-of-interfaces in type-parameterized generic methods) or structural-typing (again, via generics with explicit implementation). Please correct me if I'm wrong, but to my knowledge Swift doesn't support call-site structural typing nor true intersection types (i.e. intersection of non-interface types).

Re:Problems with TypeScript in 2020 by namelosw on Thursday April 16, 2020 @08:50AM (#22888821)
Swift is missing a lot of features, and that's why you can see a lot of type operators and type-level programming in some TypeScript code. For example, there is no Higher-Kind type support in TypeScript, but with some primitives from TypeScript, it's not hard to hack it out yourself. I doubt it's viable in Swift.

Among those mainstream languages, not many of them having such an advanced type system, with very few exceptions like Scala - even with GADT, dependent types ahead. It's light years ahead of its peers.

But I believe there are still some abstractions can be expressed in TypeScript but not Scala because the gradually/dynamically typed languages start from the opposite side from the spectrum.