Blog
Sep 1, 2025 - 3 MIN READ
Hidden Features & Lesser-Known TypeScript Gems

Hidden Features & Lesser-Known TypeScript Gems

*By Sean Erick C. Ramones, Vue SME | JavaScript/TypeScript SME*

Sean Erick C. Ramones

Sean Erick C. Ramones

Introduction

TypeScript has become the default choice for building scalable JavaScript applications. While most developers are familiar with its basic features such as static typing, interfaces, and generics, TypeScript also includes lesser-known but powerful features that can significantly improve developer experience, reduce boilerplate, and make applications safer.

This report highlights several of these "hidden gems" in TypeScript and explains how they can be applied in real-world projects.

2. Utility Types

TypeScript ships with a rich set of utility types that are often overlooked. Some of the most useful include:

  • Partial<T> – Makes all properties optional
  • Pick<T, K> – Selects a subset of properties
  • Omit<T, K> – Removes certain properties
  • Record<K, T> – Defines key-value maps
interface User {
  id: string;
  name: string;
  email: string;
}

type UpdateUser = Partial<Omit<User, "id">>;

Why it matters: Cuts down on boilerplate when working with complex data models.


3. The satisfies Operator

Introduced in TypeScript 4.9, satisfies ensures an object conforms to a type without widening its type unnecessarily.

type Role = "admin" | "manager" | "employee";

const userRoles = {
  alice: "admin",
  bob: "manager",
} satisfies Record<string, Role>;

Why it matters: Provides the best of both worlds—type safety and accurate inference.


4. Template Literal Types

Template literal types allow the creation of string patterns that are type-safe.

type EventName = `on${Capitalize<string>}`;

const clickEvent: EventName = "onClick"; // ✅
const wrongEvent: EventName = "click";   // ❌

Why it matters: Great for enforcing naming conventions and API consistency.


5. Discriminated Unions with Exhaustive Checking

TypeScript unions can be paired with never to ensure that all cases are handled.

type Shape =
  | { kind: "circle"; radius: number }
  | { kind: "square"; size: number };

function area(shape: Shape): number {
  switch (shape.kind) {
    case "circle":
      return Math.PI * shape.radius ** 2;
    case "square":
      return shape.size * shape.size;
    default:
      const _exhaustive: never = shape;
      return _exhaustive;
  }
}

Why it matters: Prevents missing cases when working with unions.


6. Literal Inference with as const in Objects

You can freeze nested structures into immutable literal types:

const THEMES = {
  light: { background: "#fff", text: "#000" },
  dark: { background: "#000", text: "#fff" },
} as const;

type Theme = keyof typeof THEMES;

Why it matters: Helps in theming, configuration, and role-based design systems.


Conclusion

These features,const assertions, utility types, satisfies, template literal types, discriminated unions, and literal inference demonstrate how TypeScript goes beyond "just typing variables." By applying them, teams can achieve:

  • Safer code with fewer runtime errors
  • More expressive types that reflect actual business logic
  • Cleaner, shorter codebases with less boilerplate

Mastering these lesser-known features allows developers to take full advantage of TypeScript, leading to more reliable and maintainable applications.

Built with Nuxt UI • © 2026