My articles about TypeScript

Create a linked list with TypeScript

A linked list is a data structure, in which each element contains a value and has a reference to the next element in the list. The value of the element can be practically anything, from a string or a number till a complex object and these values can either be sorted or unsorted and unique or duplicated.

Read the complete article

Hints and tips for better programming with the React Native framework

Based on my current experience with the React Native framework, I would like to share with you some hints and tips that will improve your skills in the way you develop with the framework.

Isolate the business logic of your application from the UI/ components code

This is probably the most valuable information someone should have in her mind when developing with React Native. React Native tries to be as platform independent as possible, however, there will be cases, that you will have to write different JavaScript code for iOS and different code for Android.

Read the complete article

Use the JavaScript ES6 Backtick (Template literal) feature to write multiline strings in HTML code

The ES6 specification of JavaScript and of course the TypeScript language, provide us the template literal syntax (the `` characters). With the template literals we can write multiline strings in JavaScript without having to use the old syntax. Take a look at the following example:

1
2
3
4
5
    var testString = "Lorem ipsum dolor sit amet, \
            \nconsetetur sadipscing elitr, \
            \nsed diam nonumy eirmod tempor \
            \ninvidunt ut labore et dolore";
 
Read the complete article

A list of reasons for why I like to use TypeScript - Part One

With this article I like to post my thoughts about TypeScript and some of the advantages of the language that I use on my everyday programming tasks.

  1. Types, types, types

Who does not know or have not implemented code like the following in JavaScript:

1
2
3
4
5
6
7
8
9
10
11
    var person = {
        firstname: "Christos",
        lastname: "Monogios"
    };
    
    // Lines of code...
    
    person.skills = ["TypeScript"];
    
    console.log(person);
 
Read the complete article

How to fix the 'Unable to find "react" ("npm") in the registry' error when using the tool Typings and TypeScript

During the last years we see that every month new JavaScript frameworks/ tools/ libraries are comming out to the public and they all promise to help us develop better, faster and give more quality to our applications. One of the favorite combinations is currently the use of the React framework, TypeScript as superset of JavaScript and the webpack tool for combining files together, dependencies and more.

When using the combination, it is very probably that you are also going to use the Typings plugin for fast downloading of definitions files for TypeScript.

If you installed react with npm and you get the ‘Unable to find “react” (“npm”) in the registry’ error from Typings when you try to download the d.ts file of react, then here is the solution to your problem:

Read the complete article

Is there a naming convention for TypeScript interfaces?

The TypeScript language was created from Microsoft as a super-set of typed-rules for JavaScript. The language contains features that one finds in C#, something that is completely understandable since the inventor of TypeScript also invented C#.

TypeScript provides interfaces that are used for two main reasons:

  1. Standardize/ Giving a type to an object, by defining the properties that an object contains.

  2. Define a structure of properties and/ or functions that a class has to implement. Doing this way you can define multiple implementations that implement the interface. In this case, the interface works as a contract (known best practice term from C#) that the classes have to respect.

Read the complete article

How to fix the "duplicate identifier" error in TypeScript

When working with TypeScript, there is a big chance that you will have to deal with a “duplicate identifier” error sooner or later.

But what exactly this error means? Read the error text again. Duplicate identifier. You are defining, with other words referencing, the same identifier (class, method, property) twice in your code.

Read the complete article