-
-
Notifications
You must be signed in to change notification settings - Fork 675
Description
We've figured for a long time that we'll eventually want to move to TypeScript; it's much better supported for the open-source community than Flow is, and seems to be increasingly the choice that people outside Facebook use and that outside tools best support.
For the Zulip webapp, there's long been a hope to migrate it from plain JS to TypeScript. When that work gets going in earnest, it'll open a quite valuable opportunity to share the maintenance of the types we have in src/api/ to describe the Zulip server's API. To do that effectively, we'll want to be using TypeScript ourselves.
Fortunately, the tools for doing this have gotten better in recent years, and it should be a quite reasonable amount of work. The basic plan is:
- Adjust the Babel config so that it looks for
*.tsfiles, and compiles them as TypeScript instead of Flow. (This only became possible with Babel 7.) - Start using
tscas a type-checker, as well asflow. (Add it totools/test, and make sure our recommended VS Code config supports it well.) - Convert files to TypeScript, one at a time.
- I expect neither type-checker will be super effective when the codebase is half and half... but at least they can work on their respective sides, and the code can all run correctly.
- We'll want to not spend too much time in this intermediate state, though.
- When that's done, optionally switch away from Babel to
tscentirely.
For converting a given file, or swath of files:
- See this post.
- There are some high-volume, highly-mechanical things like converting
{| ... |}to{ ... }; and some low-volume things that are more manual.