addons icon indicating copy to clipboard operation
addons copied to clipboard

Investigate updating addons-frontend to use TypeScript

Open eviljeff opened this issue 2 years ago • 3 comments

We currently use Flow for our typing, for historic <reasons>. Flow isn't widely used by the javascript community these days, whereas TypeScript is. We should investigate if there are tools to convert out codebase automagically from Flow to TypeScript, and otherwise get an idea how much work a complete rewrite will be.

┆Issue is synchronized with this Jira Task

eviljeff avatar Oct 12 '22 16:10 eviljeff

(copying over and rephrasing what I said on https://matrix.to/#/#amo:mozilla.org): Initial thoughts on Flow -> TypeScript: it's a big change. The actual type syntax differences are minor and there is a tool to change them, but oh boy, there are a mountain of other changes starting with the file extension changing on every *.js file making reviewing a diff much much harder.

I used https://github.com/Khan/flow-to-ts to do the conversion. And also prettier with --fix afterwards (which may not have been necessary if the eslint config matched our current style choices)

https://github.com/mozilla/addons-frontend/tree/11886-rip-flow-long-live-typescript is the branch After conversion:

  • "7356 errors in 425 files."
  • If noImplictAny is set to false (which it shouldn't - because it indicates were missing type declarations) then it's down to "3807 errors in 404 files".
  • if we ignore /tests and only compile /src/"1462 errors in 215 files" (that's where the branch was left)

(it's possible there are some quick wins in there that could be fixed with a tweak to config, etc. I've not started fixing errors in individual files either, so I can't say how many of these errors are quick fixes and how many require more significant rewriting) Also, I'm not even close to be able to answer the question of whether there are any incompatibilities beyond tsc, e.g. in the webpack, etc, pipelines - there's just too much broken typing.

Dropping my assignment on the issue for now as I'm not actively investigating this for the moment.

eviljeff avatar Oct 17 '22 11:10 eviljeff

Exact same issue on Firefox profiler project: https://github.com/firefox-devtools/profiler/issues/2931

diox avatar Feb 21 '23 13:02 diox

Old Jira Ticket: https://mozilla-hub.atlassian.net/browse/ADDFRNT-105

KevinMind avatar May 03 '24 18:05 KevinMind