Future of TypeScript on ESLint
eslint.org
eslint.org
I am a Typescript convert myself and would suggest any daily JS developer give it an honest try.
But yeah it really has improved my day to day immensely and I really feel the difference when I'm working in legacy portions of our apps that pre-date the flow adoption.
Besides that, TypeScript has much wider adoption and community support. Most issues I have with TypeScript I can find others who have had similar issues on the web, where as I can't say the same about Flow.
I'm curious to hear how Typescript vs Flow discussions go within Facebook, and what engineers there think of each.
So I would say if you're interested pick one and dive in.
Right now typescript has a lot of community momentum: https://github.com/DefinitelyTyped/DefinitelyTyped
And an extremely fast, open sourced, plugin enabled editor, vs-code ftw! I am a convert after being a longtime diehard vim user. (vs-code has the best vim binding emulation I have ever used in a free open sourced editor)
Facebook is deprecating their flow atom editor plugin; nuclide - https://twitter.com/fbopensource/status/1072928679695548416?...
This is all why I would choose typescript over flow if it were up to me. maybe a flow user can chime in.
Flow doesn't seem to be built with the (non-Facebook) developer experience in mind. It very frequently has breaking changes. The tooling is worse. There's no good official way to publish a package to npm with Flow type definitions included. Its alternative to DefinitelyTyped requires using their own CLI tool instead of copying DefinitelyTyped's simple npm-based strategy.
There a few things Flow does better. Functions internal to a file often don't need their parameters to be typed because Flow infers their types, but honestly I don't think that's a very killer feature. I often type them anyway just to be explicit. Flow does model type variance better (a Promise<{a:string,b:string}> can be cast to Promise<{a:string}>, but not vice versa, and you can't do the same with mutable arrays, etc.) but variance doesn't come up often and you can always use the any-type escape hatch in TypeScript to make it through those uncommon situations. I do hope TypeScript gets better about that though.
Flow isn't bad; a Flow codebase is still much better than an untyped Javascript codebase. But if you're starting a new project and have the choice, pick TypeScript.
Also errors in Flow are often very esoteric. The "smarter inference" sometimes made type errors appear in the callee rather than the caller (having an error on React's component type definition is not helpful). The wording isn't user-friendly if you're not familiar with typing theory.
Inference is not that much of a killer feature I feel: I don't want the type to be inferred based on how I use a variable, I want to check that I don't misuse the variable based on its type. Obviously there's use for inference too, but in the general case...
This is problematic. Now your webpack build is shelling out asynchronously to a second process. It makes it very hard to integrate type checking to a build system.
[1].push("foo");I can’t find the link which details this right now, but I believe there are/were some cases where Flow’s syntax isn’t strictly a superset of JavaScript (to do with generics and comparison operators). I’m not sure whether TypeScript has the same problem or not.
TypeScript compiles `a<b>(x)` to `a(x)`, which is a function call, but when run as plain JS, `a<b>(x)` is a less-than and greater-than comparison between a, b, and x.
When I'm responsible for tooling in a JavaScript project, it's pretty well a given that I'll push for TypeScript.
I spent the last 90 days porting about 350k lines of code to Typescript plus implementing another 400k.
It's basically a document and annotation manager for PDF and notes. Kind of an Open Source Mendeley/Evernote/Github if you will.
This code base is changing often and I really hit a dead in in terms of JS scalability.
I was just refactoring too much, breaking things, etc.
Now I can just rely on the compiler when I break things.
If I want to change a function type in TS it's no problem.
In JS it's a nightmare.
The issue tracker is a good place to start looking :)
My problem is that I read a LOT of articles and publications. If I started highlighting things in articles, I would never have enough time to go back to them. Besides, why would I want to? I already read it, which means that it's already in my mind! What's the point of reading stuff if not to put information inside your mind? I'd rather use my time to read more new stuff than to revisit things I already know.
Maybe the solution is not more tools, it's just to stick to topics that interest you and to pay attention and put more thought into what you're reading.
I apologize, I projected my own experience and assumed that other people were able to remember the main points of what they read. I guess most people don't have have great memory. I never thought of myself has having good memory but I remember the main points of most of what I read.
https://www.reddit.com/r/PolarBookshelf/comments/ah1g5w/what...
I was actually one of the original inventors of RSS 1.0 and was on the working group.
Is my other company and we have about a petabyte of content ... so definitely familiar with the space.
I'm trying to look at things a bit differently now though. I have a bunch of ideas I'm going to experimenting with.
FYI in a narrow (especially < ~1000px) the Features icons are overlapping content. I tried changing the class 'fa-4x' to 'fa-2x' on those icons and it appears to fix the issue.
You can write Typescript like Java. You can also write it (almost) like Clojure. It's really very flexible, but without most of the insanity that flexibility causes in normal JS.
I would be surprised (without golfing of course) if typescript can match clojure's conciseness.
There's not a big difference in concisesness or readability between Clojure threading macros and JS promise chaining, for example:
(-> (do x) then-do-y then-do-z then-do-q)
vs
doX() .then(doY) .then(doZ) .then(doQ);
Of course, the Clojure version is more flexible, and the ability to define DSLs very simply allows for further conciseness, but that's all beside the point. My point is just that Typescript can be written very concisely or very verbosely, depending on your own coding style.
Does TS work well alongside legacy JS so you can update individual files incrementally as you go along? I remember trying it once and facing some unexpected blockers, but I don't remember what they were.
Take create-react-app and the now deprecated create-react-app-typescript. The node_modules folder of the CRA app is over a hundred megs bigger than that of CRA-ts, and it doesn't even have feature parity.
https://github.com/AssemblyScript/assemblyscript/blob/master...
My very first programming language was ActionScript 2 (which was also based on the ECMAScript standard without types; just like JavaScript) and I clearly remember that I was really enjoying ActionScript 3 when it came out in 2006 (that's when ActionScript became a statically typed language; very similar to TypeScript).
Then a few years later, I got back to JavaScript/Node.js (dynamically typed) and I noticed that I could create libraries and applications a LOT faster without types and that writing libraries was also a lot more enjoyable.
My view now is that statically typed languages are like training wheels on a bike. Statically typed languages force you to think about software in a structured way and in doing so, they teach you some fundamental concepts about abstraction. That said, if you're experienced enough to know how to structure and test your code correctly, then, much like training wheels on a bike; they only slow you down.
I've been using TypeScript for the past couple of years at work so I can confidently say that it creates more obstacles than it solves for me.
Pros:
- Easier to keep track of all the places in the code which are affected by a refactoring (especially if the code is messy, poorly tested and components have poor separation of concerns; it gives useful warnings).
- Easier to find class and method definitions in the code.
- Easier to rename classes, functions and properties.
- Much less likely to leave forgotten unused variables or functions in your code.
Cons:
- Slow debug cycle due to increased compile time. If using TDD, it takes longer to run tests.
- Sporadic source mapping issues/bugs which makes it hard to fix things (I had an issue with Mocha tests last week where it was always telling me that the issue was on line 1). I've worked with TypeScript on multiple projects across different companies but every single time, there has been source mapping or configuration issues of some kind.
- Type definitions from DefinitelyTyped are often out of date or have missing properties/methods. It means that I can't use the latest version of a library.
- Third party libraries are difficult to integrate into my project's code due to conflicts in type names or structural philosophy (e.g. they leverage types to impose constraints which are inconsistent with my project requirements).
- Doesn't guarantee type safety at runtime; e.g. If parsing an object from JSON at runtime; you still need to do type validation explicitly. The 'unknown' type helps but it's not clear that this whole flow of validating unknown data and then casting to a known type adds any value over regular schema validation done in plain JavaScript.
- Whenever I write any class/method, I have to spend a considerable amount of time and energy thinking about how to impose constraints on the user of the library/module instead of assuming that the user is an intelligent person who knows what they're doing.
- Compiler warnings make it hard to test code quickly using console.log(...); I'm more reliant on clunky debuggers which slows me down a lot and breaks my train of thought.
- The 'rename symbol' feature supported by some IDEs is nice, but if a class or property is mentioned inside a string (e.g. in a test case definition) then it will not rename that; so I still have to do text search after doing a symbol rename and manually clean up.
- It takes a lot of time think of good names for interfaces and they are renamed often as project requirements evolve. It's not always clear whether similar concepts should be different types or merged into one. It often comes down to what constraints you want to impose on users; This adds a whole layer of unnecessary mental work which could have been better spent on thinking about logic only.
- Setting up TypeScript is a pain.
- Adds a lot of dependencies and complexity.
- Makes the bundling step a necessity. This goes against innovations like HTTP 2 which could potentially remove the necessity of the bundling step by allowing us to preemptively push scripts to the client.
You don't need to do type assertions with JavaScript; in the tests you may need to assert that certain properties exist but only to the extent that this property is relevant to the test case. This is purely a logic concern, not a typing concerns.
Types are just labels which try to make sense of reality so it makes no sense to assert their correctness.
Any project of size will need types. Either they will be explicit (static typing) or the project will be riddled comments, tests, assertions, and bugs.
You can eliminate a whole group of tests in TS that you would otherwise need in a JS project.