News for hackers. Stuff that matters.
Re:TypeScript 3.5 by mattigames on Wednesday May 29, 2019 @09:13PM (#20047434)
The 2 big things missing on typescript:

1) Operator overloading

2) Runtime type checking of JSON payloads (on dev env at least)

Can't believe in 2019 every library has to create its own way to add 2 elements of the same class together e.g dataframe1.addTo(dataframe2) vs dataframe1 + dataframe2

And the most common error that it should help catch during development is that you get a JSON and you cast it but it means nothing cause on runtime the JSON can be something completely different and nothing breaks until is somewhere else hard to debug, I get that Microsoft don't want to add runtime overhead but it should be possible at least on development mode.

Re:TypeScript 3.5 by nsonha on Thursday May 30, 2019 @04:11AM (#20049303)
1) If your motivation is heavy mathematical programming then I hear you, but beware that you are the minority of the language's userbase, (more generally, most application-level programming languages' userbase), it's not something most people care about.

If you want to write clever DSLs and/or name methods in ways that save keystrokes like in scala, NO, please.

2) There are libraries such as runtypes and io-ts that integrate well with the static type system

Re:TypeScript 3.5 by rkuykendall-com on Thursday May 30, 2019 @01:34PM (#20053765)
> Runtime type checking of JSON payloads

We've been using Mobx State Tree for this, which also gives us frontend models and automatically generates interfaces. Obviously only works for you if you're using Mobx, but we love it.

https://github.com/mobxjs/mobx-state-tree

Re:TypeScript 3.5 by hermanradtke on Thursday May 30, 2019 @12:05AM (#20048273)
I use https://github.com/gcanti/io-ts for the runtime checking. It is similar to tcomb (same author)!

You can even define the type via io-ts and then make a TypeScript interface out of it!

Given this, and the other libraries that do something similar, I am not sure why Microsoft needs to add it to the language.

Re:TypeScript 3.5 by MaulingMonkey on Thursday May 30, 2019 @04:46AM (#20049440)
RE: JSON: I've started tagging my JSON blobs as `unknown` and then using type guards (typeof, instanceof, field access existence checks, Array.isArray checks, user defined type guards[1], etc.) my way to inferring the shape of that JSON blob is as expected, and it seems to work pretty well.

[1] https://www.typescriptlang.org/docs/handbook/advanced-types....

Re:TypeScript 3.5 by farnsworth on Wednesday May 29, 2019 @10:44PM (#20047903)
> 1) Operator overloading

Please, please, please, no.

Re:TypeScript 3.5 by mattigames on Wednesday May 29, 2019 @10:51PM (#20047947)
You know it would be completely transparent right? Just gets transpiled into .__add__(obj)
Re:TypeScript 3.5 by watt on Thursday May 30, 2019 @03:14AM (#20049046)
We already saw this play out in Scala. People end up abusing these to create absolutely unreadable "DSL"s. Even when it's tastefully done, for example the "!" and "?" operator for messages in Akka, it's not better than the names "tell" and "ask".
Re:TypeScript 3.5 by mattigames on Thursday May 30, 2019 @04:58AM (#20049504)
Fair enough.
Re:TypeScript 3.5 by jakelazaroff on Thursday May 30, 2019 @12:44AM (#20048468)
The explicit goal of TypeScript is to be JavaScript, with types — i.e. not introduce any features not likely to land in an ECMAScript spec.
Re:TypeScript 3.5 by mattigames on Thursday May 30, 2019 @02:10AM (#20048807)
Which is a shame because JavaScript is constrained due needing backwards-compatibility above all (among other issues) but TypeScript isn't
Re:TypeScript 3.5 by MaulingMonkey on Thursday May 30, 2019 @04:41AM (#20049421)
Not much of a shame IMO - there are plenty of other languages that transpile to JS without those goals, if you don't care about backwards compatability and 1:1 mappings to vanilla JS.

On the other hand, there's only one language that I'm aware of - TypeScript - prioritizing these things, which is a major selling point of it to me. I don't want yet another leaky abstraction, or yet another runtime heavy enough for those abstractions to not leak.

I just want enough types for my intellisense to work right, and for my sorry ass - spoiled by years of nothing but static typing systems - to be able to code without drowning in a veritable sea of uncaught type errors to debug, when I poke frontend stuff.

Re:TypeScript 3.5 by mattigames on Thursday May 30, 2019 @04:54AM (#20049476)
Typed and those features? there isn't a single one. But yeah, maybe what I need is a fork of TypeScript with those features (or maybe some sort of plugin)