1 min read 87 words Updated Sep 24, 2026 Created Sep 24, 2026
#Programming#TypeScript#review

Compared to Rust or Kotlin TypeScript also offers optional null-safety, but only at compile time. Thus, at execution, null-related errors are still possible.

strictNullChecks is true, if strict is true in tsconfig.

Useful features of TypeScript for writing null-safe code:

Optional Chaining:

const length = name?.length; // `undefined`, if `name` null/undefined

Nullish Coalescing:

const result = name ?? "default";

Type Guards:

if (typeof name === "string") {
  // name is guaranteed to be a string 
}

Utility types:

NonNullable oder Partial