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

[Proposal] SetNonNullable #144

Closed
xenoterracide opened this issue Nov 12, 2020 · 4 comments
Closed

[Proposal] SetNonNullable #144

xenoterracide opened this issue Nov 12, 2020 · 4 comments

Comments

@xenoterracide
Copy link

I honestly thought SetRequired did this. example of expected behavior

type Optional<T> = T | undefined | null;
type Foo = {
   bar: Optional<string>;
   foo?: string | null;
   baz?: string;
};

type NonNullableFoo = SetNonNullable<Foo, 'bar' | 'foo'>;

// would be equivalent to

type ManualNonNullableFoo = {
   bar: string;
   foo: string;
   baz?: string;
};
@sindresorhus
Copy link
Owner

I honestly thought SetRequired did this.

⬇️

Create a type that makes the given keys required.

@sindresorhus
Copy link
Owner

This seems useful though. I wonder if we could just overwrite the built-in NonNullable version with a more powerful one that also accepts which keys to apply to, as discussed in #171.

@papb
Copy link
Contributor

papb commented Dec 20, 2020

@sindresorhus However, note that SetRequired does more than just mark the given keys as required - it also strips undefined from them.

@joealden
Copy link
Contributor

joealden commented Sep 6, 2022

I believe this can be closed now that #431 has been merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants