Skip to content

OverrideProperties changes undefined as optional #858

Description

@CarinaChenot

Considering this:

import { OverrideProperties } from 'type-fest';

type Original = {
  foo: string;
  bar: string;
};

type Modified = {
  foo: string | undefined;
  bar: string;
};

const test: OverrideProperties<Original, Modified> = { bar: '' };

foo is typed as foo?: string instead of foo: string | undefined

CleanShot 2024-04-08 at 09 01 13@2x

This is particularly problematic when using exactOptionalPropertyTypes flag

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions