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.
TypeScript 3.5
81–88 of 88 posts
Re: TypeScript 3.5
#82Earlier 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?
Re: TypeScript 3.5
#83Earlier 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`.
Re: TypeScript 3.5
#84I 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…
Re: TypeScript 3.5
#85The 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…
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.
Re: TypeScript 3.5
#86Earlier 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.
Re: TypeScript 3.5
#87Earlier 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')
Re: TypeScript 3.5
#88Earlier 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.
I merely know from experience that they have a pretty good type system, but not much more. So I asked :-)
Answers have been enlightening