News for hackers. Stuff that matters.
Re:Announcing TypeScript 3.9 by piazz on Wednesday May 13, 2020 @02:35PM (#23170116)
Can you give a concrete example of the kind of code you'd like to write that you can't write in Typescript?

Types absolutely are a first class citizen in TypeScript. Especially coming from Go, which doesn't even support generics, Typescript is really quite powerful. It even has support for ADTs via discriminated unions, which gives you the same power of enums with associated types that you'd get in Rust/Swift.

Is it possible the reason you feel like Typescript doesn't have Types as a first class citizen is because it leverages structural typing rather than nominal typing?

Re:Announcing TypeScript 3.9 by mxz3000 on Wednesday May 13, 2020 @04:53PM (#23171716)
Not op, but I have experience with TS and some things are more difficult than they should be. For me the biggest issue is the lack of typesafe deserialisation. This makes it super painful to do IO (of which there's _a lot_ of in the serverless infrastructure I'm currently working on). While you can validate with a manually written type guard, that's a pain... It would great if you could do JSON.parse<T>() and have TS auto-generate the type guard for you... There's also no easy way to switch on union types (à la ocaml), sure you can define an enum and use a JS switch, but that's not as nice, and enforcing exhaustiveness of the switch requires some type hackery with `never`...
Re:Announcing TypeScript 3.9 by mixedCase on Wednesday May 13, 2020 @05:34PM (#23172090)
io-ts does this. Although it's the other way around: you write the type guard (API is similar to writing a type) and it gives you the type for free.
Re:Announcing TypeScript 3.9 by The_rationalist on Thursday May 14, 2020 @02:44PM (#23183623)
Typescript has type erasure meaning that after compilation all information about types is lost. This means that you loose: * runtime type reflection * Reified generics