hstspreload.org
hstspreload.org copied to clipboard
Switch to TypeScript
The frontend code is on in an okay state, but it would be good to get static type checking on it soon. I don't plan to work on this myself (I expect it will take some fiddling to set up a good deveopment and deployment flow), but if someone wants to help I would love us to switch. :-)
I can help, I have experience with TypeScript. What I am not sure on is how to integrate compilation in to your pipeline.
- Do .js files as a result of the compilation get checked in, and hope that everyone remembers to compile before committing? (I don't like this approach but has a low bar)
- Assume .js files do not get checked in, when do they get built during deployment? As part of the container? What is the workflow for developers? Do we compile in the Makefile for starting up?
- Do we deploy sourcemaps to certain environments at all to aide in debugging in test, or even production environments?
- Do .js files as a result of the compilation get checked in, and hope that everyone remembers to compile before committing? (I don't like this approach but has a low bar)
I think it's fine not to commit .js into the source.
- Assume .js files do not get checked in, when do they get built during deployment? As part of the container? What is the workflow for developers? Do we compile in the Makefile for starting up?
I think it's okay to assume for now that developers will use make serve for local testing.
It would be nice ifmake serve spins up something like tsc --watch, but then quits when you quit the server – this may be possible in the shell using wait?
- Do we deploy sourcemaps to certain environments at all to aide in debugging in test, or even production environments?
It would be nice to have for testing. hstspreload.org is not really optimized right now, and I don't think there's a problem with having source maps in prod, although we could make a prod build in make deploy.
I'm the only one regularly working on this repo, so anything that works well for me is probably good. :-) (I looked at how other Google projects do this, but I can only find internal advice that's not so relevant to us.)
Ok. I can take a shot at this. I would propose a few PRs, or at least two.
The first would be to just change the file extensions from .js to .ts and get it compiling and the site consuming the output of the compiler.
The subsequent ones would be refactoring to types, classes, and utilizing TypeScript's language features.
Thoughts?