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

Writable doesn't only strip readonly from the keys

Open bertearazvan opened this issue 1 year ago • 4 comments

Hi! I encounter a weird bug, and I am not sure if I am using it wrong or it's broken somehow.

I am encountering an issue where the Writable doesn't only strip the readonly but it also changes the object's type structure. I expect that Writable simply removes readonly from the first level of keys in the object.

I like the @utility-types approach to it, it seems simpler with a very similar result. Would you be open to have the same implementation here?

Thanks!

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

bertearazvan avatar Oct 20 '23 14:10 bertearazvan

Are you on the latest type-fest version?

sindresorhus avatar Oct 20 '23 16:10 sindresorhus

it seems simpler with a very similar result. Would you be open to have the same implementation here?

It's simpler because it doesn't accept an optional type parameter for what keys it should apply to.

I think we could add an overload when that parameter is not passed and use the simple handling.

sindresorhus avatar Oct 20 '23 16:10 sindresorhus

Are you on the latest type-fest version?

Just double checked and yes I am. I have 4.5.0 and typescript 5.2.2

I think we could add an overload when that parameter is not passed and use the simple handling.

Yeah, it could be an idea 🚀. I tried it by passing each key as an optional type parameter and it worked as expected.

bertearazvan avatar Oct 20 '23 16:10 bertearazvan

I think we could add an overload when that parameter is not passed and use the simple handling.

I think the core reason is we wrap the result with Simplify, so we need to consider whether we should remove Simplify even if we used overload.

Or create another type to do this.

Emiyaaaaa avatar Oct 27 '23 04:10 Emiyaaaaa