DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. JavaScript
  4. Stop Writing Spaghetti Code: Why You Should Use TypeScript

Stop Writing Spaghetti Code: Why You Should Use TypeScript

TypeScript is a typed superset of JavaScript created by Microsoft that compiles directly to regular JavaScript to enable JavaScript developers to code with type safety. This is important because coding with type safety allows developers to code more cleanly, resulting in easier maintenance and fewer bugs. Read on to learn more.

John Basso user avatar by
John Basso
·
Feb. 10, 16 · Analysis
Like (3)
Save
Tweet
Share
5.72K Views

Join the DZone community and get the full member experience.

Join For Free

TypeScript is a typed superset of JavaScript created by Microsoft that compiles directly to regular JavaScript to enable JavaScript developers to code with type safety. This is important because coding with type safety allows developers to code more cleanly, resulting in easier maintenance and fewer bugs. It is a great tool to add to your next web project that will save your team time and energy both in the development and support phases.

Benefits

TypeScript’s most significant benefit is the type system that gives it its name. By enabling compile-time error-checking, TypeScript dramatically decreases the frequency of run-time errors. This is especially important as web applications become more front-end focused, and consequently the amount of JavaScript code grows considerably. Writing type safe JavaScript code has become important for the exact same reasons as its importance on the back-end–it’s easier to maintain and has fewer bugs. And beyond simple type safety, TypeScript’s language paradigms, especially surrounding inheritance, are similar to those found in mainstream back-end languages like Java and C#, cutting down on possible mistakes with junior developers who might not be familiar with advanced JavaScript features (such as prototypical inheritance). These benefits make it less likely your code will fall victim to the dreaded "spaghetti code" complex that can affect large JavaScript projects that weren’t organized with experience and foresight.

Considerations

Though TypeScript is a powerful developer tool that creates better code and fewer bugs, there are a couple of things worth thinking through before choosing to work with TypeScript. The first is that TypeScript is a relatively new technology. JavaScript currently has better IDE and debugger support than found with TypeScript, though this will change over time. Also, TypeScript does a great job masking JavaScript’s idiosyncrasies, but sometimes you will encounter complex or unusual functionality which may require knowledge of underlying JavaScript mechanisms.

Popularity

As TypeScript gains popularity, tooling support will swiftly improve and the web development community will shift more toward TypeScript.  The next version of Angular, arguably the most popular JavaScript framework, is written in TypeScript.

Best Use Cases

TypeScript is an excellent tool for front-end web development, bringing type safety, better organization, and fewer bugs to your projects. Anyone looking to start a new front-end-heavy web application (or overhauling an old one) should strongly consider using TypeScript to create a quality code foundation that will save time on development and support.

Growing Popularity

Google Trends graph displaying TypeScript’s growth in popularity from January 2013 to January 2016.
TypeScript_GoogleTrends

TypeScript

Published at DZone with permission of John Basso, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Top Authentication Trends to Watch Out for in 2023
  • Core Machine Learning Metrics
  • Deploying Java Serverless Functions as AWS Lambda
  • Writing a Modern HTTP(S) Tunnel in Rust

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: