Angular & TypeScript: How to Import RxJS Correctly?

Angular has some third-party dependencies, one of which is RxJS, a library which makes reactive programming very easy to use. The library is obtained as an npm package. In order to use functionality from the RxJS library, it has to be imported first. So before you can use an operator such as map in the following snippet, it has to be imported:

route.params
  .map(params => params.id)
  .subscribe(id => console.log(id));

Whereas IDEs such as WebStorm (prior to 2017.2) or Visual Studio Code do a good job for auto-importing symbols, they don’t suggest anything at all for RxJS symbols. Both IDEs simply print the following error message from TypeScript:

Property ‘map’ does not exist on type ‘Observable’.

Continue reading Angular & TypeScript: How to Import RxJS Correctly?

Angular & TypeScript: Writing Safer Code with strictNullChecks

On May 4, Angular 4.1.1 was released. This release fulfils a promise already made for Angular 4.1: Adding support for TypeScript’s strictNullChecks compiler option added in TypeScript 2.0.

Strict Null Checking = Safer Code

This transpiler flag enables us to write safer code. TypeScript with strict null checking enabled feels even more comfortable for developers with a static-typed language background. Without strict null checking, assigning null or undefined for instance to a variable of type number is perfectly possible:

Continue reading Angular & TypeScript: Writing Safer Code with strictNullChecks

Angular 2: An Overview

Angular 2 is the upcoming all-new Single-Page Web Application (SPA) framework from Google. It’s the successor to the well-known AngularJS, which was first published in 2009.

Logo of AngularJS
Logo of AngularJS

Do you remember? In 2009, Windows 7 was released, which included Internet Explorer 8 as the default browser. The work on HTML5 just started. And the iPad wasn’t even on the market. Since then, the world and the web have changed a lot: Mobile internet usage surpassed desktop usage. Fully-fledged business applications are built using HTML5. And web technologies are on par with their native counterparts in terms of functionality and performance. Angular 2 wants to address these changes by being:

  • easier to learn
  • flexible
  • fast
  • ready for mobile

And here’s how:

Continue reading Angular 2: An Overview