Categories
Capstone

Learning a New Language: TypeScript

After the Betchya team learned that AWS had deprecated the Go 1.x managed runtime, we quickly shifted our focus to learning TypeScript. This transition would also come with the benefit of enhanced productivity as we have experience with JavaScript. However, that is not to say that this learning experience was not met with unforeseen challenges!

Our team had originally preferred TypeScript over Go in the initial planning of our lambda function. We were excited about the overall fewer runtime errors and an overall more maintainable codebase. I was also excited about the opportunity to expand my skillset and elevate our project’s efficiency.

Set of Challenges: Setup and Configuration

My first hurdle into my journey with TypeScript was the environmental set and configuration in Visual Studio Code. The ‘tsconfig.json’ file was a bit of a puzzle at first. While the learning curve with TypeScript was steep, each obstacle offered a valuable lesson.

1. Environment quirks:

My initial program written in TypeScript was a simple ‘Hello World’ program – a rite of passage for any new language. I wanted familiarize myself with TypeScript’s compiling process and also ensure that my development environment was correctly set up. However, compiling and running my program was not an easy process.

Despite the many online resources on TypeScript, I found that the instruction on executing the program within Visual Studio Code were not as clear cut as I had hoped. My preference for PowerShell in VS Code led to some unexpected difficulties in compiling and running my TS program. The error message originally produced in the terminal was not very descriptive as seen here:

However, facing new obstacles and ambiguous error message are part of the learning process! I immediately took to online forums, documentation and the TypeScript community for guidance. My solution was rather simple and quite embarrassing once I figure out why my program wasn’t compiling/running. My terminal is supposed to be set to Bash not PowerShell! This experience working with TS, though somewhat embarrassing, reinforces the idea that the path to mastering a new language is often paved with unexpected challenges!

2. Configuring ‘tsconfig.json’:

Upon viewing the tsconfig.json file, I was very unfamiliar with many of the options commented throughout the file. However, I decided to continue with coding my program. When I finished with my program, I compiled in the Bash terminal and came across this error message.

Thankfully, the compiling error message was a little more descriptive this time! I was able to uncomment the ‘lib’ compiler option and include the suggested ES2017. Now, the ‘lib’ option expects an array so my ‘lib’ option now looked like this.

Once I resolved that error message, I compiled the program once again in hopes of finally running my program. However, I was met with another compiling error!

I am rather thankful that the error messages are very straight-forward. For the ‘console.log’ and ‘console.error’ methods to work, I needed to include “DOM” in the ‘lib’ array as well. My ‘lib’ option now looked like this at the end.

After these error messages were resolved, I was able to successfully compile and run my program! After these hiccups, I now have a much better understanding of tsconfig.json and its configuration options!

Lessons Learned and Moving Forward

In conclusion, my journey into the world of TypeScript, was met with some unexpected challenges but it was an immensely rewarding experience. From the initial setup and configuration hurdles in Visual Studio Code to the nuanced understanding of ‘tsconfig.json’, each obstacle was a crucial learning opportunity. I think my experience highlights the importance of perseverance and willingness to embrace silly mistakes. This journey has not only expanded my technical capabilities but also reinforced the value of adaptability and continuous learning. Looking forward, I anticipate a path filled with opportunities for further learning, personal development and more rewarding challenges that will undoubtedly enrich my journey as a software engineer.

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *