Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

The Typescript Workshop: Benefits of migrating an existing Javascript project to Typescript

 
Ranch Hand
Posts: 165
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can understand the benefits of new projects being developed in Typescript. However, what could be compelling reasons to migrate existing large nodeJs projects to Typescript, as against working on features?
 
Marshal
Posts: 5326
324
IntelliJ IDE Python Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are 2 questions here:

Question 1. Is there value in using TypeScript over JavaScript?
Question 2. Is there value in a migration project over new features?

Let's tackle them individually

Opinion 1: As with any language, you can write well designed and well implemented programs that work as intended with minimal problems so there is nothing fundamentally bad about JavaScript. It comes down to the benefit of a Strongly Typed language (TypeScript) over a Loosely Typed language (JavaScript). For me personally I like TS over JS for two main reasons: Firstly I see great benefit in detecting type errors at compile time as opposed to runtime, it means that my IDE can tell me I've messed up instead of my customers. Secondly, coming from a long Java background I find TS to be very familiar in structure and syntax which meant I could get going with it very quickly.

Opinion 2: That is not a technology problem, rather a personal or business decision. If the current JS project is working well then perhaps a rewrite has little value but that doesn't stop you from introducing TS incrementally as you develop new features and address issues in the current codebase. That way you can reap the benefits of using TS without the burden of rewriting everything.
 
Sheriff
Posts: 22649
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another advantage of TypeScript over JavaScript is improved code-completion. Because everything is typed, IDEs (and advanced editors like Visual Studio Code) can determine what functions and properties are available, and complete those for you.

Note that you don't need a full rewrite just to get code-completion support. You can get the same by adding type definitions only (.d.ts files). However, unless these can be generated from JavaScript, you'll run the risk that these get out-of-date.
 
Author
Posts: 10
5
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rob and Tim make some great points and I'd offer the same advice.

I've seen the benefits of using TypeScript on large (>100k loc) projects and I've done the incremental approach on even larger (>200k loc) projects. TypeScript helps ramp up developers faster. Anybody who has worked in a typed language knows the benefits of being able to list out a method argument and IDE completion. This is great when you know the code base, but it's just invaluable if you're learning it for the first time.

With any new technology, it's a smart idea to start small and make sure the choice is right for you, your team, and your project. TypeScript is a great tool for incremental adoption until you're sure you want to use it everywhere. My team uses it for user interfaces, backend code, infrastructure, and cli tooling!
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am currently leading a modernization project where we are replacing an XSL front end (yes, not kidding), with Angular/TypeScript. One thing to keep in mind about bringing in TypeScript incrementally is that developers need to have a broader skillset: both whatever the old framework or language was (nodejs, etc.) and TypeScript. This may be a good thing for current developers (everyone wants to learn something new, right?) but it increases the learning curve for anyone new you want to bring on the team. In contrast, if you move the whole thing to TypeScript, then newbies only need to know that (and whatever other skills they would need to have regardless). I think this is a more minor consideration than what has already been mentioned, but just something to be aware of.
 
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic