Issue link:

Contents of this Issue


Page 2 of 26

August 2014 3 Introduction to TypeScript Microsoft's alternative to JavaScript adds modularity, generics, and type informa- tion while maintaining JS source compatibility. U sed to develop applications for browsers, servers, phones, and the desktop, JavaScript has grown to be one of the most ubiquitous programming languages. For all its pop- ularity, the language was not originally designed for the scale and complexity of today's use cases. One of the key features of programming languages designed for this kind of use is a type system that can enable developers to use modern tooling to refactor, navigate, and detect errors in the code as it grows and changes. TypeScript helps to fill this gap for JavaScript applications. As a superset of JavaScript, TypeScript allows programmers to use their existing JavaScript code and frameworks. TypeScript provides a flexible type system that layers well on top of existing JavaScript, which enables developers to scale their codebases more quickly and with more confidence than with vanilla JavaScript. TypeScript Starts and Ends with JavaScript The problem with many errors in JavaScript is that they're silent. For example, it's perfectly valid JavaScript to access an object with an arbitrary member name. If the member doesn't already exist, it will be created. The only way to detect errors like this is to come across them at runtime or by looking for them with unit tests. If we're un- lucky, the error lies dormant, waiting for an unsuspecting user to find it. function changeDirection(s) { if (Math.random() > 0.5) { s.goLet = true; // <-- Silent error } else { s.goRight = true; } By Jonathan Turner and Amanda Silver [ TYPESCRIPT ] Table of Contents @jntrnr Previous Next Previous Next Download Download Register Register Subscribe Subscribe Previous Next Previous Next

Articles in this issue

Links on this page

view archives of InformationWeek - 7_23_Dr_Dobbs