ویو جی اس

Beginning TypeScript

Beginning TypeScript

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.

سطح متوسط 11 جلسه آموزشی 08:01:00 ساعت
01
قسمت 1

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.

02
قسمت 2

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.

03
قسمت 3

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.

04
قسمت 4

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. For further reading, I highly recommend delving into the literal type documentation. They’re some of the most underutilized types in the wild and can be quite complex.

05
قسمت 5

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.

06
قسمت 6

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.

07
قسمت 7

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.

08
قسمت 8

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.

09
قسمت 9

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.

10
قسمت 10

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.

11
قسمت 11

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.