Beginning TypeScript

0
Language

Level

Beginner

Access

Paid

Certificate

Paid

As the complexity and scale of our apps forever increases, TypeScript has risen in popularity as people seek the reassurances of type safety in their applications. Major frameworks such as Vue have rewritten their entire code bases in TypeScript.

Nonetheless, there is a cost associated with adopting it. Teams must learn how to use a new set of tooling, think about their code in a different way, and learn concepts that may be foreign to them. This series aims to ease the transition to TypeScript. It assumes basic knowledge of JavaScript but otherwise serves as an introduction to the most common types that will enable you to build real applications in TypeScript.

Add your review

Hello, TypeScript

In this lesson we learn how to install TypeScript and use its compiler. We cover the basics of setting up a tsconfig and how to configure our Typescript projects.

Understanding the Type System

In this lesson, we learn about the mechanics of the TypeScript type system. We learn how to read basic syntax of TypeScript and delve into what it means for a type system to be Structural and Erased. We highlight the power of TypeScript’s type inference and get a board overview of the various types available to us.

For further reading, I recommend the getting started guide in the TypeScript handbook – especially the sections for JS developers as well as the Java/C# section – most of this is relevant for PHP (and any OOP heavy language) as well. See here and here.

Arrays and Tuples

In this lesson, we move beyond primitive types to explore Array and Tuple types and how to represent collections of data. You can read more about these types in the official TypeScript handbook. See here and here.

Literals and Enums

Next up, we’ll cover some very useful types: Literal Types and Enums. We’ll explore the difference between these two types and when you might reach for each.

Void and Null

Void and Null should be familiar types for any programmer. Conceptually, they are relatively simple types, thoughNull can be a tricky one – even in dynamic languages.

Any and Unknown

In this lesson we cover the use of unknown and highlight the dangers of using any. It’s important that we avoid the use of any in our code wherever we can, and instead reach for unknown. We’ll also discuss the concepts of type narrowing and type casting.

I recommend paying attention to this lesson and really trying to grok the subtleties of unknown. For further reading, I recommend looking at the TypeScript documentation for any and unknown.

Interfaces and Type Aliases

In this lesson, we get into the most useful parts of TypeScript: Interfaces and Type aliases. The majority of TypeScript you will write or encounter in the wild will be Interfaces and Type aliases. One of the most common questions that newcomers ask is when to use one over the other. In this lesson, we’ll answer that very question and highlight the subtle differences between the two types.

Unions and Intersections

Unions are fundamental to how we compose types in TypeScript to build rich data structures from smaller ones. One of the trickier things with type unions is Discriminated Unions. So let’s learn how to deal with these and leverage TypeScripts type narrowing in order to perform exhaustiveness checking and splitting on intersections. As usual refer to the documentation for further reading.

Never

The `never` type represents a type that can never occur. An example of this might be functions that never return or always throw exceptions. Variables are also typed as `never` when exhaustively narrowed by type guards. Though it might be initially confusing, this type is useful for exhaustiveness checking.

Intersections

Intersections are useful for composing types in TypeScript and building up rich data structures from smaller ones. When composing types with intersections, be careful that your intersections are compatible with one another. Please refer to the TypeScript for further reading on this topic.

Generics

Generics can be scary topic at first – especially if you come from a language that doesn’t support them. In this lesson, we break down Generics to their simplest form and show how they are a tool that we can leverage to express the relationship between types in our system. Generics allow us to create an interface or type alias that can work over a variety of types rather than a single one.

User Reviews

0.0 out of 5
0
0
0
0
0
Write a review

There are no reviews yet.

Be the first to review “Beginning TypeScript”

×

    Your Email (required)

    Report this page
    LiveTalent.org
    Logo
    LiveTalent.org
    Privacy Overview

    This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.