JavaScript powers a lot of Firefox but unlike the other languages that ship
code in our product JavaScript uses a dynamic type system. Types for
variables are decided at execution time and can change as new values are
assigned to them. This leaves you open to accidentally passing the wrong
kind of data around your code. Easy to do when APIs are changed on the
other side of the tree.

Flow and Typescript have gained prominence recently as tools that add
static types on top of JavaScript giving you a build time check (note: no
runtime checks) to see if the types you’re using look correct. A number of
us have used these tools successfully in side projects and want to see if
using a tool like this would be beneficial in Firefox.

A first experiment towards understanding this has just landed (
https://hg.mozilla.org/integration/autoland/rev/1dd081553a3a). Specifically
Greg Tatum has added TypeScript <https://www.typescriptlang.org/> type
annotations and configuration to the JavaScript code in the
devtools/client/performance-new directory.

The mode of TypeScript we’re testing involves annotating types with
comments, the JavaScript code itself is just normal JavaScript. All of the
TypeScript bits live in comments so there is no build step and we’re also
not adding any automated tests to verify the types in CI for this
experiment.

For the time being the perf tools team will just be checking the types
locally before committing. This will give us an idea of the benefits on
real in-tree code without any impact outside of the team.

If you have any concerns with this or want to know more please let us know.


Dave
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to