News for hackers. Stuff that matters.
Re:Etcd, or, why modern software makes me sad by nikitaga on Tuesday July 14, 2020 @04:06PM (#23837114)
Offtopic but what's nice about Typescript generics? Typescript doesn't even let you specify variance. It's one of the unsound parts of the language's type system in fact.
Re:Etcd, or, why modern software makes me sad by IggleSniggle on Tuesday July 14, 2020 @08:03PM (#23839652)
You cannot explicitly specify covariant vs contravariant, but TypeScript absolutely does allow you to express these relationships. Unless I misunderstand you.

That said, the type system has come a very long way even in just the last year. The biggest improvements imho being around recursive types (which was one of the biggest holes for a long time imo), literal types / literal type inference, and tuple types.

It's not complete by any means, but it's improving quite rapidly.

Re:Etcd, or, why modern software makes me sad by nikitaga on Wednesday July 15, 2020 @12:53AM (#23841467)
It appears that function parameter bivariance is still a thing? [1] Although there seems to now be a flag to make this one use of variance correct.

I would assume even Array<T> is still bivariant as well...

Both of those are horribly unsound, just for convenience. Sure convenience and compatibility are Typescript's ultimate goals, but to actually praise it for its generics? That's very strange.

> TypeScript absolutely does allow you to express these relationships

How would you express a class with covariant or contravariant type params in Typescript?

[1] https://www.typescriptlang.org/docs/handbook/type-compatibil...

Re:Etcd, or, why modern software makes me sad by flatline on Tuesday July 14, 2020 @04:20PM (#23837305)
It is not the most feature-rich generic system but it's come a long way since the earliest revisions and does have some niceties: https://www.typescriptlang.org/docs/handbook/advanced-types....