Live data from Hacker News

TypeScript 3.5

devblogs.microsoft.com

81–88 of 88 posts

Re: TypeScript 3.5

#81
post #9
post #5

Typescript 3.5: fixing the problems we introduced and providing workarounds for new features in a broken type system.

Could you help me specify why TS is a broken type system ? Thanks you very much.

They may have been talking about how TypeScript's type system is (intentionally) unsound. For example see https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-fun... and the notes on soundness in https://www.typescriptlang.org/docs/handbook/type-compatibil....

Re: TypeScript 3.5

#82

Earlier quoted context omitted.

> There is no other programming language that has union types as powerful as TypeScript I suggest looking into Idris and other languages with dependent types. Nothing against typescript, but it’s not even close.

Idris doesn't have anonymous sum types, nor does Coq or Lean. Which language were you thinking of?

Ceylon comes to mind; haven't googled others.

Re: TypeScript 3.5

#83
post #66

Earlier quoted context omitted.

Probably... but in any case TypeScript also supports naked (edit: I just made up the name) unions, where you don't need to declare them upfront, and where values of different types can be included directly. Such as: let a = random() ? 'a' : 1 TypeScript infers type string | number

This is still a discriminated union, only that the discriminator is provided by Javascript and is thus hidden: it's `typeof`.

No, this works on any overlapping types too - even unsound combinations such as `T | Array`

Re: TypeScript 3.5

#84
post #2

I would really love to enjoy TypeScript, especially now that they've added HKTs, but I am constantly running into type errors when the types clearly match, leading to weird workaround code where the type of some key in some object is specified as: false | 'x' | 'y' | undefined Meaning passing in `'x'` should work just fine. But instead, it specializes it to just a string, then throws a type error. The workaround requ…

Since this is the top comment, for anyone that got overly excited like I did - no, there are no HKTs in TypeScript yet unfortunately.

Re: TypeScript 3.5

#85

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 no…

> 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

#86
post #80

Earlier quoted context omitted.

I'm using 3.5.1, the issue is I don't have very many files and it's in a Node environment where it transpiles the file to the output directory with no bundling or hot reloading included. What are some of these tricks to skip checking or do async checking? I did a quick search and came up with a GitHub issue [0] for adding the option to skip checking, but didn't see anything myself. [0] https://github.com/Microsoft/Ty…

Theres tooling for this for webpack described: https://github.com/TypeStrong/ts-loader#faster-builds More generally though you have two loops one that does transpileOnly and one that doesn't. The latter is your type check process.

As I said there's no bundling, such as webpack.

Re: TypeScript 3.5

#87
post #42
post #39

Earlier quoted context omitted.

> There is no other programming language that has union types as powerful as TypeScript How about Swift and OCaml? ReasonML comes to mind too. Haven't tried actively comparing any of them though.

OCaml/Reason have discriminated unions, which means that you have to explicitly specify which variant of the union you're using, such as type union = Bool of bool | Char of char | Nothing let (x, y, z) = (Nothing, Bool true, Char 'x')

Interesting! Thanks!

Re: TypeScript 3.5

#88
post #47
post #39

Earlier quoted context omitted.

> There is no other programming language that has union types as powerful as TypeScript How about Swift and OCaml? ReasonML comes to mind too. Haven't tried actively comparing any of them though.

What features are you thinking of in those languages? I don't know Swift but I can't think of anything comparable in OCaml.

Sorry; I don't have much of an answer here.

I merely know from experience that they have a pretty good type system, but not much more. So I asked :-)

Answers have been enlightening

Post reply on HN