0Pricing
TypeScript Academy · Lesson

lib DOM types & querySelector (strict null checks)

Understand lib DOM types and select elements safely with querySelector using strict null checks.

Intro

Goal: Use lib DOM types and querySelector safely. You will check for null first, then use narrowed types for element APIs.

DOM lib types

The TS DOM lib provides types for browser globals (e.g., Document, HTMLElement, Event), powering IntelliSense and checks.

// DOM types come from the lib DOM definitions
// Examples: Document, HTMLElement, HTMLInputElement, Event

const title: string = document.title; // Document API
console.log("Title:", title);

All lessons in this course

  1. lib DOM types & querySelector (strict null checks)
  2. Event types, custom events; narrowing HTMLElement subtypes
  3. Working with FormData, URL, URLSearchParams
← Back to TypeScript Academy