Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UndefinedOnPartialDeep (opposite of PartialOnUndefinedDeep) #681

Closed
kachkaev opened this issue Sep 7, 2023 · 0 comments · Fixed by #700
Closed

UndefinedOnPartialDeep (opposite of PartialOnUndefinedDeep) #681

kachkaev opened this issue Sep 7, 2023 · 0 comments · Fixed by #700
Labels
help wanted Extra attention is needed type addition

Comments

@kachkaev
Copy link

kachkaev commented Sep 7, 2023

It’d be great have a type similar to PartialOnUndefinedDeep, which does the opposite:

import type { UndefinedOnPartialDeep } from 'type-fest';

interface Settings {
  optionA: string;
  optionB?: number;
  subOption: {
    subOptionA: boolean;
    subOptionB?: boolean;
  };
}

const testSettingsA: Settings = {
  optionA: 'foo',
  optionB: undefined, // TS error if exactOptionalPropertyTypes is true
  subOption: {
    subOptionA: true,
    subOptionB: undefined, // TS error if exactOptionalPropertyTypes is true
  },
};

const testSettingsB: UndefinedOnPartialDeep<Settings> = {
  optionA: 'foo',
  optionB: undefined, // 👉 optionB can be set to undefined now
  subOption: {
    subOptionA: true,
    subOptionB: undefined, // 👉 subOptionB can be set to undefined now
  },
};

See #426 and exactOptionalPropertyTypes docs for context.

@kachkaev kachkaev changed the title PartialOnUndefinedDeep UndefinedOnPartialDeep (opposite of PartialOnUndefinedDeep) Sep 7, 2023
@sindresorhus sindresorhus added help wanted Extra attention is needed type addition labels Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed type addition
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants