Tag Archives: Typescript

TypeScript at Slack: how we converted and what we learned

Case study of converting a large codebase from JavaScript to TypeScript: it is not as painful as you might think.


On the Slack Engineering Blog, Felix Rieseberg writes:

We decided to use Microsoft’s TypeScript, which combines static type analysis with a compiler. Modern JavaScript is valid TypeScript, meaning that one can use TypeScript without changing a single line of code. This allowed us to use “gradual typing” by enabling the compiler and the static analysis early, without suspending work on critical bug fixes or new features.

In practice, switching the analysis and the compiler on without changing code means that TypeScript will immediately attempt to understand your code. It uses built-in types and type definitions available for third party dependencies to analyze the code’s flow, pointing out subtle errors that went previously unnoticed. Wherever TypeScript cannot understand your code, it will assume a special type called “any” and simply move on.

Read more from the source: Several People Are Coding

Angular 2 Beta is Out

Angular 2 reaches beta, packing a lot of changes from the preview


Angular 2 is truly a different framework from Angular 1. Although there is ngUpgrade and ngForward to help transition, the syntax and API are vastly different.

Angular 2 introduces a DOM parser that process html attributes before hitting the DOM. That means the new star, brackets and parentheses are easier to handle under the covers. And Angular 2 makes directives camelCase instead of kebab-case. You may also notice that directive attributes don’t show up on the DOM. All that is parsed out before rendering.

ng-if is now *ngIf and ng-repeat=”item in items” is now *ngFor=”#item of items”. ng-eventname directives are gone in favor of (eventname) syntax.

Property-based directives such as ng-class, ng-style, and ng-disabled are gone in favor of bracket-notated binding: [class.classname], [style.property], [disabled].

ng-model becomes [ngModel] for one-way binding and [(ngModel)] for two-way binding.

The digest cycle is gone, replaced by an immutabile object style checking.

Typescript (or the ES6 subset of Typescript) is recommended, but Angular 2 comes with a webpack-style server and live reloader for development.

Read the announcement on the blog: angularjs.blogspot.com or checkout the updated angular.io website.