Skip to content

Smart Reschedule: TypeScript?

Posted on:May 25, 2020 at 12:00 AM

So, I guess it’s a series now. In our last installment, we walked through the reason behind the project and my vague ideas about how to go about it.

​Now, I’ve been tinkering with the project for a little bit and want to share some of my observations and where things stand at the moment.

Not much has changed in how I think I will approach task rescheduling. However, I tweaked the parameters a bit. Let me recap:

Next steps

Next, I need to figure out how to go about, well, rescheduling tasks. As of this moment, the plan is this:

TypeScript

I get distracted by shiny new objects really easily. Last night, I came across two fairly old talks on TypeScript:

This talk is so old that arrow functions, classes, and string literals had already made their way into JavaScript! In this one, TypeScript 3.8 is announced. We are at 4.0 already!

As a result, I’ve completely rewritten my little serverless fetchTasks.js in TypeScript. It’s a fantastic low-pressure introduction. Since TypeScript compiles to plain JavaScript, it remains a valid serverless lambda function, while I get to take full advantage of TypeScript: types, amazing IDE support, suggestions, and so on. And since I’m at the ground level of this project, it was really easy to figure out what types and interfaces I need and where I can get the most benefits moving forward.

Anyway, stick around if you want to see me stumble around and make this thing happen after all!

Bonus

Here’s a sneak peek of what my current function returns. Future tasks are also included. All of this is also sorted by rescheduleScore and importanceScore for past due and future tasks respectively. As you can see, there’s an interesting bug/feature: tasks that are due tomorrow (within a few hours from now) are considered overdue (which is a bug) but receive the highest rescheduleScore (which is a feature). I will fix this later by making sure that tasks with zero days left are not considered overdue 🤷‍♂️