I've been using TypeScript for over 1 year after 10 years of JavaScript and I really don't like it. It slows me and the team down and creates more problems than it solves. It doesn't even ensure type safety because there is no runtime type validation for JSON objects received from the API. It's disturbing that so few people can see how useless it is. To me, it's extremely obvious. TypeScript is a hack of epic proport…
Typescript has been useful for my team to reduce the number of unit tests and constant checking of number and order of parameters in functions, presence of null/undefined values, etc - when compared to JS obviously. It works particularly well when coupled with JSON schema validation that checks that the contract of your api is not ignored (TS types map very easily to and from JSON schemas). As for your third paragrap…
Migrating 300k LOC from Flow to TypeScript
31–40 of 87 posts
Re: Migrating 300k LOC from Flow to TypeScript
#32I've been using TypeScript for over 1 year after 10 years of JavaScript and I really don't like it. It slows me and the team down and creates more problems than it solves. It doesn't even ensure type safety because there is no runtime type validation for JSON objects received from the API. It's disturbing that so few people can see how useless it is. To me, it's extremely obvious. TypeScript is a hack of epic proport…
I think this is probably the wrong kind of hubris.
Re: Migrating 300k LOC from Flow to TypeScript
#33I've been using TypeScript for over 1 year after 10 years of JavaScript and I really don't like it. It slows me and the team down and creates more problems than it solves. It doesn't even ensure type safety because there is no runtime type validation for JSON objects received from the API. It's disturbing that so few people can see how useless it is. To me, it's extremely obvious. TypeScript is a hack of epic proport…
Disclaimer, I freaking love JavaScript and TypeScript.
> TypeScript is a hack of epic proportions and every so often the reality rears its ugly head in the form of failed source mapping, version compatibility issues, unexpected types during runtime, poor architectural decisions aimed at pleasing the compiler instead of fulfilling project goals.
This just sounds like JavaScript to me. Maybe TypeScript has helped elucidate those problems for you. TypeScript adds some syntax to help formalize solutions to these problems that existed in JavaScript already.
> TypeScript is a very poor way to model real-world systems because it incorrectly assumes that real-world entities have a fixed type schema
This sounds to me like programmer error. TypeScript provides facilities for unknown structures, or structures that have multiple possible definitions. There is the union type for which we can tell the compiler that a value can be of type `A[ or B[ or C[ or... ]]]`. Perhaps even more powerful is optional types. In interface you'd describe an optional field with a question mark, like `{ foo?: string }`. Alternatively, you could use the union type described above, unioned with `undefined`. These structures help you create types that actually do model the uncertainty of data coming into your program. If you're not using these techniques, then you're missing out! Having the type-checker yell at me because I didn't check for the undefined case is a really really cool thing.
> Why not force the developers to account for as many cases and schemas as possible, it's our job!
I would argue that TypeScript provides the vocabulary for doing just that and that JavaScript provides no such niceties. Sure, you provide run-time checks on a piece of datas validity, but there's no system to check that run-time behavior before code gets merged to master.
If you're not running `"strict": true` and annotating your TS code with optional values when data is coming into your program, you might have a bad time.
Re: Migrating 300k LOC from Flow to TypeScript
#34Earlier quoted context omitted.
Typescript has been useful for my team to reduce the number of unit tests and constant checking of number and order of parameters in functions, presence of null/undefined values, etc - when compared to JS obviously. It works particularly well when coupled with JSON schema validation that checks that the contract of your api is not ignored (TS types map very easily to and from JSON schemas). As for your third paragrap…
I still don't get it. You can also add rigorous schema validation to your API endpoints with plain JS so you don't need to worry about strange inputs in your tests either. This is not unique to TS.
All things that come up relatively frequently in vanilla JS during refactoring processes.
Re: Migrating 300k LOC from Flow to TypeScript
#35Earlier quoted context omitted.
I absolutely agree on TypeScript, I love that it's opinionated and simply versioned. Every time I have to step back into a codebase that uses Babel and X number of different plugins it just tires me. Typescript is just Typescript, and the compiler works fantastically well. > Better still, a lot of these languages are coming to the browser (via WASM or transpilation) I think this has always been a concern - CoffeeScri…
All these issues are being worked on. If you use kotlin-js, the output is javascript. There are no GC issues, you use the javascript GC. WASM is currently indeed bottlenecked on the lack of GC. This is being worked on. I expect a lot of progress over the next two years that will gradually remove most of the obstacles on this and other fronts. None of these are fundamental issues; it's just a matter of things not bein…
Re: Migrating 300k LOC from Flow to TypeScript
#36I really like the way TypeScript approaches Dynamic world of JS ecosystem with various advance types. https://www.typescriptlang.org/docs/handbook/advanced-types.... Intersection Types - An intersection type combines multiple types into one. Union Types - A union type describes a value that can be one of several types Type Guards - A type guard is some expression that performs a runtime check that guarantees the type…
https://github.com/microsoft/TypeScript/issues/31983#issueco...
Re: Migrating 300k LOC from Flow to TypeScript
#37I've been using TypeScript for over 1 year after 10 years of JavaScript and I really don't like it. It slows me and the team down and creates more problems than it solves. It doesn't even ensure type safety because there is no runtime type validation for JSON objects received from the API. It's disturbing that so few people can see how useless it is. To me, it's extremely obvious. TypeScript is a hack of epic proport…
what do you mean by type validation of JSON objects? If you mean, that you can for exammple pass string to object property defined as number, then I must warn you, that this is problem in all languages (eg. most java json serializers, will throw exception). Anyway if you need to ensure all object properties have correct type, you should write validator/transformer (there are already libraries that can do it for you).
Re: Migrating 300k LOC from Flow to TypeScript
#38Earlier quoted context omitted.
"Types are useless because they don't version my wire protocol!" is a wholly specious argument. There are a variety of RPC protocols that address versioning in a variety of ways; this isn't a typechecker responsibility. You can generate Typescript interfaces from protobufs if you fancy. Typescript makes sure that all your code agrees with the protocol definition you have chosen. That alone is immensely valuable.
Typescript only checks all that at compile time though. The complaint here is that even a typed json.Parse :(json:string)=>T will not actually give any type checking when you pass it a string containing any schema.
Re: Migrating 300k LOC from Flow to TypeScript
#39Re: Migrating 300k LOC from Flow to TypeScript
#40There have been a few posts like this, and the discussion always seems to focus on plain JavaScript vs TypeScript. I'd like to see some talk about Flow vs TypeScript instead. We have what I'd call a medium-sized project (~30k loc) written with Flow and TypeScript's superior tooling is indeed attractive enough that we too have been thinking about making the switch. Having used both, there are a few features in Flow th…
Ironically, one of the easier ways TypeScript has been able to work quickly is by skipping the type inference Flow does. It’s a trade off. The Flow team was advised that this approach would have performance problems early on in the project, and opted to focus on type system features first and perf second.