AC3431

Introduction to TypeScript Training

TypeScript, a superset of JavaScript, enhances the reliability and predictability of JavaScript code. This TypeScript training course teaches you the fundamentals of TypeScript, allowing you to create applications for both the server and client-side.
Course Details

Duration

2 days

Prerequisites

  • Experience with at least one modern object-oriented programming language, preferably a statically-typed language (e.g., C# or Java)
  • Knowledge of JavaScript either as a frontend web developer or backend Node.js developer

Skills Gained

  • Master the core concepts of TypeScript, including basic types, variable declarations, type inference, generics, and type guards
  • Seamlessly integrate TypeScript with existing TypeScript libraries
  • Enhance the type safety and maintainability of existing JavaScript code
  • Interpret and resolve warnings and errors reported by the TypeScript compiler
  • Explore advanced techniques
  • Build and deploy type-safe applications for both the server-side and client-side
  • Use TypeScript tooling, including the type checker, editor plugins, and compiler, to enhance your development workflow, streamline code analysis, and improve productivity
Course Outline
  • Introduction
  • Basic Types and Variable Declarations
  • Primitives and Non-Primitives
  • Typing Function Arguments and Return Types
  • Basic Type Inference
  • Generics and Type Parameters
  • Any
  • Unions
  • More Advanced Generics
  • Any vs. Unknown
  • Type Guards and Narrowing
  • Interfaces vs. Type Aliases
  • Intersection Types
  • Modules and Exporting Type Aliases
  • Ways to Break Type Guarantees
    • any
    • foo as Bar
    • Function or Object or object in certain cases
    • Non-null assertion operator foo!.bar
  • Using as to tell TypeScript “trust me”
  • Discriminated unions (tagged unions)
  • Creating Custom Type Guards
  • Literal Types
  • Enums and Const Enums
  • Building a Validator using Custom Type Guards
  • Using Runtypes or Zod to Validate Data
  • Declaration Files and DefinitelyTyped Repository of Community Types
  • Recursive Types
  • Typing JSON
  • Utility Types
  • Generics with Constraints
  • Advanced Types (typeof, keyof)
  • Making a Property Read-only
  • Conditional Types
  • Making a Type or Interface Read-Only (the hard way)
  • Runtime Manifestation (type position vs. value position)
  • Mapped Types (using a key in to modify an object type or interface)
  • ReadonlyArray (and the read-only modifier for object properties)
  • Declaration Merging
  • Adding Types to Existing Code
  • Declaration Files
    • Shipped with the package from the library author
    • Decl Files written by the community
    • Write your own and put it in global.d.ts
    • If it is your own library, then you can add JSDoc annotations, then you don’t need a d.ts file
    • If you have a JS file with JSDoc annotations then you can auto-generate the d.ts for export (such as if you’re a library author)
  • Conclusion