Uploaded image for project: 'BookBrainz'
  1. BookBrainz
  2. BB-557

Switch from flow to TypeScript

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Normal Normal
    • None
    • None
    • None
    • None

      TypeScript and flow are both static type checking extensions of JavaScript. They approach the subject of type checking differently - TypeScript is a new language which is a superset of ES6, while flow annotates standard JavaScript. Both require transpilation to remove typing information prior to use in node.js or the browser.

      Typescript currently has a more active community, with approx 30x as many dependent packages on GitHub. It also has far better support amongst commonly used libraries, with a much more active library type definition repository (https://github.com/DefinitelyTyped/DefinitelyTyped vs https://github.com/flow-typed/flow-typed). It has good documentation and good IDE integration.

      While this might not be a high priority for BookBrainz, it's something I'd be interested in working on, as well as expanding type annotations across the codebase. The rough plan (not yet tested) would be:

      1. Add build dependency on Babel's "preset-typescript", and enable babel to run on .ts and .tsx files.
      2. Convert all files which currently have "// @flow" in the name to TypeScript files (~67 files - mostly client-side)
      3. Remove Babel "preset-flow" from build and turn off flow type checking, create typescript configuration and add typescript as a project dependency, install type definitions for dependencies and run typescript type checking as part of CI and linting
      4. Extend typescript across the remainder of the codebase

      Each of those steps would be at least one PR - #2 and #4 may be multiple PRs.

      Interested to hear thoughts on this.

            lordsputnik Ben Ockmore
            lordsputnik Ben Ockmore
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Version Package