Why is this an issue?

When TypeScript’s exactOptionalPropertyTypes option is disabled, an optional property already accepts undefined; adding | undefined repeats the same contract. Remove the redundant union member while keeping ? if callers should still be able to omit the property. This rule does not report issues when exactOptionalPropertyTypes is enabled, because the two declarations then have different meanings.

Noncompliant code example

interface Person {
  address?: string | undefined; // Noncompliant: "undefined" is redundant
}

Compliant solution

interface Person {
  address?: string;
}

How to fix it

Choose the declaration that matches the intended contract:

These distinctions assume strictNullChecks is enabled. Without it, undefined is assignable to other types as well.

Note that reading a missing property returns undefined; TypeScript does not add that property to the object.

Type aliases and detection limits

The rule also follows local type aliases, alias chains, and generic types that introduce undefined. This requires strictNullChecks or strict; otherwise, only undefined written directly in the property annotation is detected.

For a local alias such as type Maybe<T> = T | undefined, decide whether to change the alias for all its users or use a narrower type for the optional property. Do not remove ? just to avoid changing an alias if omission is part of the contract.

The rule does not report undefined reached only through an external library’s type, including indexed access to an external optional property:

import type { TextFieldProps } from "@mui/material";

interface Props {
  size?: TextFieldProps["size"]; // Not reported: the type comes from an external declaration
}

There is no explicit union member to remove here, and removing ? would make size required. This exception does not apply to the same pattern using a locally declared type.

Resources

Documentation