Advanced types

Watch User Created Playlist (13)

This playlist is user created.

pro-course-rss-logo

PRO RSS Feed

Restrict null and undefined via Non-Nullable-Types in TypeScript

Understand TypeScript’s Control Flow Based Type Analysis

Define Custom Type Guard Functions in TypeScript

P

Make Properties and Index Signatures Readonly in TypeScript

P

Represent Non-Primitive Types with TypeScript’s object Type

P

Use TypeScript’s never Type for Exhaustiveness Checking

P

Overload a Function with TypeScript’s Overload Signatures

P

Collect Related Strings in a String Enum in TypeScript

P

Specify Exact Values with TypeScript’s Literal Types

P

Model Alternatives with Discriminated Union Types in TypeScript

P

Infer Types for Rest and Spread Properties in TypeScript

P

Query Properties with keyof and Lookup Types in TypeScript

P

Transform Existing Types Using Mapped Types in TypeScript

P
typescript tutorial about Restrict null and undefined via Non-Nullable-Types in TypeScript

Restrict null and undefined via Non-Nullable-Types in TypeScript

6:17 typescript

This lesson introduces the --strictNullChecks compiler option and explains how non-nullable types differ from nullable types. It also illustrates how you can write safer code by being explicit about null and undefined in the type system.

typescript tutorial about Understand TypeScript’s Control Flow Based Type Analysis

Understand TypeScript’s Control Flow Based Type Analysis

4:14 typescript

The TypeScript compiler analyzes the control flow of your program to determine the most precise type for a variable at any given location.

This lesson shows control flow based type analysis in action and explains how type guards and jumps in control flow affect the type that is inferred.

typescript tutorial about Define Custom Type Guard Functions in TypeScript

Define Custom Type Guard Functions in TypeScript

5:01 typescript PRO

One aspect of control flow based type analysis is that the TypeScript compiler narrows the type of a variable within a type guard.

This lesson explores how you can define functions and type predicates to create your own type guards similar to the Array.isArray() method.

typescript tutorial about Make Properties and Index Signatures Readonly in TypeScript

Make Properties and Index Signatures Readonly in TypeScript

4:19 typescript PRO

TypeScript 2.0 introduced the readonly modifier which can be added to a property or index signature declaration. It helps prevent against unintended property assignments. This lesson gives various use cases for readonly and shows what the generated JavaScript code looks like.

typescript tutorial about Represent Non-Primitive Types with TypeScript’s object Type

Represent Non-Primitive Types with TypeScript’s object Type

3:03 typescript PRO

TypeScript 2.2 introduced the object, a type that represents any non-primitive type. It can be used to more accurately type methods such as Object.create. Don't confuse it with the Object type or {}, the empty object type, though!

typescript tutorial about Use TypeScript’s never Type for Exhaustiveness Checking

Use TypeScript’s never Type for Exhaustiveness Checking

5:03 typescript PRO

TypeScript 2.0 introduced a new primitive type called never, the type of values that never occur. It helps model the completion behavior of functions more accurately and can also be used for exhaustiveness checking.

typescript tutorial about Overload a Function with TypeScript’s Overload Signatures

Overload a Function with TypeScript’s Overload Signatures

4:38 typescript PRO

Some functions may have different return types depending on the types of the arguments with which they’re invoked. Using TypeScript’s function overloads, you can create an overload for each allowed combination of parameter and return types. This way, all type-correct signatures of a function are encoded in the type system and can be surfaced by the TypeScript Language Service within your editor.

typescript tutorial about Collect Related Strings in a String Enum in TypeScript

Collect Related Strings in a String Enum in TypeScript

3:32 typescript PRO

As of TypeScript 2.4, it is now possible to define string enums, or more precisely, enums with string members. Just like any other numeric enum, string enums can be made constant using the const modifier so that they disappear entirely from the generated JavaScript; in this case, all enum values will be inlined into the output.

typescript tutorial about Specify Exact Values with TypeScript’s Literal Types

Specify Exact Values with TypeScript’s Literal Types

5:38 typescript PRO

A literal type is a type that represents exactly one value, e.g. one specific string or number. You can combine literal types with union types to model a finite set of valid values for a variable. In this lesson, we explore the all kinds of literal types in TypeScript:

  • String literal types
  • Numeric literal types
  • Boolean literal types
  • Enum literal types
typescript tutorial about Model Alternatives with Discriminated Union Types in TypeScript

Model Alternatives with Discriminated Union Types in TypeScript

6:05 typescript PRO

TypeScript’s discriminated union types (aka tagged union types) allow you to model a finite set of alternative object shapes in the type system. The compiler helps you introduce fewer bugs by only exposing properties that are known to be safe to access at a given location. This lesson shows you how to define a generic Result<T> type with a success case and a failure case. It also illustrates how you could use discriminated unions to model various payment methods.

typescript tutorial about Infer Types for Rest and Spread Properties in TypeScript

Infer Types for Rest and Spread Properties in TypeScript

7:03 typescript PRO

TypeScript supports rest and spread properties for objects, which are slated for standardization in ECMAScript 2018. It automatically infers rest and spread types so that you can use object spread and rest elements in a statically typed manner without having to manually add type annotations.

typescript tutorial about Query Properties with keyof and Lookup Types in TypeScript

Query Properties with keyof and Lookup Types in TypeScript

5:06 typescript PRO

The keyof operator produces a union type of all known, public property names of a given type. You can use it together with lookup types (aka indexed access types) to statically model dynamic property access in the type system.

typescript tutorial about Transform Existing Types Using Mapped Types in TypeScript

Transform Existing Types Using Mapped Types in TypeScript

7:42 typescript PRO

Mapped types are a powerful and unique feature of TypeScript's type system. They allow you to create a new type by transforming all properties of an existing type according to a given transformation function. In this lesson, we'll cover mapped types like Readonly<T> or Partial<T> that ship with the TypeScript compiler, and we'll also explore how to create our own type transformations.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?