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 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
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-pl...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform
Also sprach Dave Townsend:
> 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.
As mconley said, this really is great work! Any step we can take
to make using JavaScript safer should be applauded.
We’d be interested in providing stronger type hints in the new
remote protocol in development under remote/, as I understand
adding types retroactively to existing code can be challenging.
> 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.
Has any progress been made since to include this in our lint checks?
If not, what instructions do I need for running the manual checks?
_______________________________________________
firefox-dev mailing list
firef...@mozilla.org
https://mail.mozilla.org/listinfo/firefox-dev
I know from the folks talking about types earlier, we're definitely interested in other teams adopting some TypeScript comments in their own areas of the codebase, so we can gather more feedback. If anyone is interested in experimenting, I'd be happy to help guide some initial setup.
We are going to prototype a WebDriver Bidi (https://w3c.github.io/webdriver-bidi/) implementation in mozilla-central.
This will be implemented in JavaScript and will mostly be written from scratch (although inspired from DevTools and Remote Agent).We are discussing about using TypeScript comments for this new code, but I can see that TS is still only used in DevTools' performance-new panel for now.What is the status of TypeScript in mozilla-central? Is it fine if a new project starts using it?