3 ms·
My list: - extremely verbose - even further verbose and hard to read compiler errors - advanced uses require extreme prophiciency in TS - poorly typed libra
by epolanski 3y ago
My list:
- extremely verbose
- even further verbose and hard to read compiler errors
- advanced uses require extreme prophiciency in TS
- poorly typed libraries (including the standard ones, for easier transitions to ts), e.g. JSON.parse returning `any`s
- untyped error channels. Got a function that can throw an error? You can't type it unless you change the shape of the returned type to some ADT like `Either<A,B>`. Have a promise that can reject with some generic error `E`? Well, `Promise<A>` takes only one generic argument, the errors are untyped, so you need to use stuff like `Promise<Either<A,B>>` and handle it manually or with external libraries.
- Hard time to implement many kinds of stuff with a fluent api (meaning stuff like Foo.get().map(someMappingFunction).call(Baz) needs to be implemented as `get`, `map`, `call` as separate functions, not as methods). This is what forced `fp-ts` to go for `pipeable` APIs ( pipe(get, map(someMappingFunction), call(Baz) ) rather than the fluent api before. It also led for a period the `effect` ecosystem to write their own extensions for TS, called TS+ [1]
[1] https://dev.to/effect-ts/the-case-for-ts-18b3 https://dev.to/effect-ts/the-case-for-ts-18b3
With all of that being said, TypeScript is one of the most productive and efficient and flexible programming languages out there, I know very few languages that allow to write so many kind of software for so many kind of platforms. TypeScript's structural typing has a long list of pros, and for functionally-inclined developers like me TypeScript allows to express and implement stuff that other languages e.g. Haskell cannot such as more generic typeclasses like Ordering, Eq, etc, without the same being "attached" to the type itself and being unique (which has no mathematical foundation, there's infinite ways to implement a sorting on any kind of type, there's zero mathematical reasons why there should be only one).
- mekster 3y ago> JSON.parse returning `any`s How do you type it?
- epolanski 3y agoSomething like this [1] is the should be the real type of the function. [1] https://www.typescriptlang.org/play?#code/C4TwDgpgBAUgygeQHIDUCGAbArtAvFAKCgB8oBnYAJwEsA7AcyNNqwFsAjCSpqdgez4YIaWjxYYMPeMnTYIAbQC6PAN7yA1hBAAuclTr1Fu6akw4AvgQIATCAGMMaStDt9aFKGCdkIJ3QAoyXQoaBgBKKFwAPig4EFpgNAAPAFFKSj5KElhEUzkgA https://www.typescriptlang.org/play?#code/C4TwDgpgBAUgygeQHI...
- Capricorn2481 3y agoWith the way its type inference works, it's probably the least verbose type system out there.