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

feat: add an option to disable Exact types #456

Merged
merged 5 commits into from
Dec 30, 2021

Conversation

aikoven
Copy link
Collaborator

@aikoven aikoven commented Dec 27, 2021

Closes #454

Copy link
Owner

@stephenh stephenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still a little bummed about not finding a way for your mapped types to keep these, but am not coming up with anything ... i.e. a way to pass long / "look up" the "appropriate" / "contextual" DeepPartial from a given message.

On another project, I've made fake properties, i.e.:

class Foo { 
  __types: { encoder: FooEncoder, decoder: FooDecoder }
}

And then always just set __types: null! because it's not actually used at runtime, but is just a way for mapped types to look into __types and grab what it needs.

For that project, the __types approach was more appropriate, but it seems more icky here, sitting on protobuf message types... 🤷

But yeah, this is a cheap option to add, so why not/makes sense. Maybe add it to the readme, just in case others run into issues with Exact?

@aikoven
Copy link
Collaborator Author

aikoven commented Dec 28, 2021

The hardest problem is preserving the trick with generic parameter required for Exact in mapped type.

Things might get better if/when TypeScript supports exact types natively :)

But yeah, this is a cheap option to add, so why not/makes sense. Maybe add it to the readme, just in case others run into issues with Exact?

I've updated the readme, could you review it please?

Copy link
Owner

@stephenh stephenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @aikoven !

@aikoven aikoven merged commit 9c53d7e into stephenh:main Dec 30, 2021
@aikoven aikoven deleted the add-option-to-disable-exact-types branch December 30, 2021 04:06
stephenh pushed a commit that referenced this pull request Dec 30, 2021
# [1.97.0](v1.96.1...v1.97.0) (2021-12-30)

### Features

* add an option to disable Exact types ([#456](#456)) ([9c53d7e](9c53d7e))
@stephenh
Copy link
Owner

🎉 This PR is included in version 1.97.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Problems with Exact types
2 participants