4 ms·
* Structural types rather than nominal * Type unions and intersections * Type guards * `keyof` operator * String and number literal types See https://www.types
by recursive 6y ago
* Structural types rather than nominal
* Type unions and intersections
* Type guards
* `keyof` operator
* String and number literal types
See https://www.typescriptlang.org/docs/handbook/advanced-types.html https://www.typescriptlang.org/docs/handbook/advanced-types.... for more. There are a lot of utility types in the standard library that could not be expressed in C# as well.
Reflection is very different. It kind of still exists, but in a very different way.
- seanmcdirmid 6y agoIt isn’t really more advanced as it is different. What typescript achieves with structural typing it loses in terms of good error messages and the encapsulation benefits of nominal typing. I’ve gotten used to typescript, but I still enjoy using C#. Some things I really miss in C# (limited operator overloading) that will never come to typescript (not because of the type system, but because of javascript source compatibility).
- WorldMaker 6y agoSome things like conditional types and string template literal types start to get way out into abstract type land that is certainly more advanced than C#'s type system. Typescript is inching closer and closer to the Haskell-ish land of turing complete type systems where the type system itself is nearly it's own meta-programming language with each version. (A recent example was the "SQL engine" written using string template literal types to type safe "query" an in-memory database. That's quite more advanced than anything C# is capable of, albeit a strange hack and unlikely to be specifically something useful in production anytime soon, though still built out of things that make Typescript useful to some JS projects.)
- seanmcdirmid 6y agoTypescript lacks the goal of soundness, which makes it much easier to introduce powerful features than in Haskell.