type-fest icon indicating copy to clipboard operation
type-fest copied to clipboard

Add `SetNonNullable` type

Open sindresorhus opened this issue 3 years ago • 6 comments

https://github.com/sindresorhus/type-fest/pull/199

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

sindresorhus avatar Jul 08 '21 11:07 sindresorhus

looking forward to this to be included 👍

falkenhawk avatar Jul 14 '21 14:07 falkenhawk

https://github.com/sindresorhus/type-fest/pull/245

sindresorhus avatar Mar 22 '22 10:03 sindresorhus

@sindresorhus do you think this type needs to deal with optionality? We have the following type in our codebase at work:

type SetNonNullable<
  BaseType,
  KeysToSet extends keyof BaseType = keyof BaseType
> = {
  [Key in keyof BaseType]: Key extends KeysToSet
    ? NonNullable<BaseType[Key]>
    : BaseType[Key];
};

So I'm wondering if we'd all be happier with the naming of this if it more closely followed the behaviour of NonNullable?

joealden avatar May 24 '22 14:05 joealden

@joealden It should work like NonNullable, so not deal with property optionality.

sindresorhus avatar May 26 '22 09:05 sindresorhus

I believe this can be closed now that https://github.com/sindresorhus/type-fest/pull/431 has been merged?

joealden avatar Sep 06 '22 11:09 joealden

yeah this can be closed I guess

kachkaev avatar Apr 11 '24 15:04 kachkaev