Seanny123 initiated a discussion on revisiting the move to TypeScript for the Discourse project, having recently gained experience with the tool. He asked if interest remains and sought clarification on the current JavaScript build process, noting that references to Babel for ES6-to-ES5 conversion appeared hidden or obsolete.
User jomaxro clarified that the ES6 conversion was completed over nine months ago, explaining the lack of current Babel references. eviltrout expressed strong personal support for TypeScript, describing it as a “super linter” that helps prevent null exceptions and type errors in specific parts of the codebase. However, he noted that the current pipeline, which relies on Rails Sprockets and custom Babel configurations, does not support it.
Eviltrout highlighted that the team plans to review alternative build pipelines like Rollup, Ember CLI, or Webpack to replace Sprockets. This shift aims to resolve several critical issues: upgrading to newer Rails and Ruby versions, improving server memory usage and performance, speeding up development, and allowing front-end designers to work locally without the full Ruby app.
Seanny123 acknowledged the benefits of TypeScript and offered his experience with Webpack, expressing readiness to assist once the team’s internal discussions on a new pipeline conclude.
Around a year ago, @eviltrout has previously expressed reasonably cautious interest in moving to TypeScript. Having recently started using it in my own development projects, I’ve been slowly figuring out how to integrate TypeScript build tools (tslint, tsc and ts-loader) into established projects.
My questions are as follows:
Is there still interest in using TypeScript?
What is the JavaScript build process of this project? I know you’re using babel to convert from es6 to es5 and I looked at the docs, but where it’s called seemed a bit hidden? I’m assuming you have a build script of some sort?
Since then (two years really flies by!) I have had the opportunity to play with TypeScript a bit more and I can say that I am quite a fan.
I would not suggest it for everything in Discourse, but there are parts of the codebase where stronger typing would certainly help from a development perspective. I consider TypeScript something like a super linter, where you can avoid null exceptions and accessing members that aren’t there.
The big problem right now is the pipeline doesn’t support it. Our current JS build process is still based on sprockets in Rails, with a bunch of custom code to use Babel for ES6 features.
We’ve had some internal discussions about reviewing other build pipelines such as rollup, ember cli or webpack to see if those tools can be used instead of sprockets. There are several advantages to this:
Our sprockets hacks are holding us back from upgrading Rails right now
Not upgrading Rails is holding us back from the newer version of Ruby which has better memory usage/performance
Sprockets is really slow and uses a lot of memory. We’d like to be able to upgrade Discourse without hitting swap on low memory servers.
We’d like to improve development speed
We’d like for front end designers to work on Discourse locally without the entire ruby app
I suspect that based on internal discussions that we will have an opportunity to look into a new build pipeline this year (maybe even this quarter). Once that is in place we will be in a much better position to add something like TypeScript.
I consider TypeScript something like a super linter, where you can avoid null exceptions and accessing members that aren’t there.
That’s how I’ve used it as well. It’s personally saved me a ton of time.
We’ve had some internal discussions about reviewing other build pipelines such as rollup, ember cli or webpack to see if those tools can be used instead of sprockets.
I only have experience with Webpack2, so I can’t really comment on the difference between Rollup and Webpack2. Please ping me when the internal discussions have concluded!