3 ms·
This is the first time I'm hearing such a claim. In C# you can't work with optional generics because an optional reference type is different from an optional v
by SebastianKra 2y ago
This is the first time I'm hearing such a claim.
In C# you can't work with optional generics because an optional reference type is different from an optional value type.
C#s poor type-inference often requires you to type out types thrice. You can't declare constants or class members with type-inferrence.
The only way to define sum-types (A | B | C) is through intefaces and I'm pretty sure they can't be sealed. Defining product-types (A & B & C) is impossible.
- storafrid 2y agoSorry I probably used the wrong term, not a native English speaker. I didn't mean lack of complexity or lack of "features" but rather the lack of carefully thought-through feature "depth". Like, we can infer generic arguments which is nice, but then we try doing that with some keyof complex type and it doesn't work. And later we find an issue on GitHub saying that it's not implemented. Which is fine, I love TS anyway and it's evolving.
- fire_lake 2y agoC# has record (product) types now.
- crabmusket 2y agoI'm not sure about the terminology here, but the & in TS is much more than a record. You can use it to smush types together e.g. {name: string} & {birthday: Date} becomes a single type with both properties.
- fire_lake 2y agoProduct types are tuple types. Record types are tuple types with names instead of indexes. The TypeScript “&” is another thing.