-
-
Notifications
You must be signed in to change notification settings - Fork 230
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
fix: DeepPartial with generic parameter should allow assigning {} #184
fix: DeepPartial with generic parameter should allow assigning {} #184
Conversation
@piotrwitek can you take a look? |
@mpiniarski thanks I'll tomorrow morning :) |
package-lock.json
Outdated
@@ -1,8 +1,7811 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpiniarski could you please remove the package-lock
file from the PR, it shouldn't be committed as it's unrelated
src/mapped-types.spec.snap.ts
Outdated
<T extends object>() => { | ||
// @dts-jest:pass:snap -> DeepPartial<{ first: { second: { name: string; }; }; }> | ||
testType<DeepPartial<NestedProps>>({}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpiniarski I think this test should look like this to reflect the original issue report, could you try it?
<T extends{}>() => {
// @dts-jest:pass:snap -> I'm not sure about what type will be resulting here from dts as it's using generic
// possibly ` DeepPartial<T>`, let me know we'll figure it out
testType<DeepPartial<T>>({});
};
In summary, whatever dts
will derive and there is no error from the compiler on test assignments we can assume it's working correctly
Hey @mpiniarski, have you seen my comments? |
Fixed, sorry for the delay. |
No problem, thanks a lot. I'll have a look shortly :) |
// @dts-jest:pass:snap -> DeepPartial<{ first: { second: { name: string; }; }; }> | ||
testType<DeepPartial<NestedProps>>({}); | ||
|
||
<T extends object>() => { | ||
// @dts-jest:pass:snap -> DeepPartial<T> | ||
testType<DeepPartial<T>>({}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it looks exactly as in the ticket, nice :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work @mpiniarski thanks again :)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [utility-types](https://togithub.com/piotrwitek/utility-types) | [`3.10.0` -> `3.11.0`](https://renovatebot.com/diffs/npm/utility-types/3.10.0/3.11.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/utility-types/3.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/utility-types/3.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/utility-types/3.10.0/3.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/utility-types/3.10.0/3.11.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>piotrwitek/utility-types (utility-types)</summary> ### [`v3.11.0`](https://togithub.com/piotrwitek/utility-types/releases/tag/v3.11.0) [Compare Source](https://togithub.com/piotrwitek/utility-types/compare/v3.10.0...v3.11.0) #### What's Changed - Fix a typo in README by [@​gamtiq](https://togithub.com/gamtiq) in [https://github.com/piotrwitek/utility-types/pull/153](https://togithub.com/piotrwitek/utility-types/pull/153) - add "Nullish" type alias by [@​zhirzh](https://togithub.com/zhirzh) in [https://github.com/piotrwitek/utility-types/pull/152](https://togithub.com/piotrwitek/utility-types/pull/152) - Fix typo in $Call documentation by [@​kumar303](https://togithub.com/kumar303) in [https://github.com/piotrwitek/utility-types/pull/154](https://togithub.com/piotrwitek/utility-types/pull/154) - Link to ReturnType from $Call docs by [@​kumar303](https://togithub.com/kumar303) in [https://github.com/piotrwitek/utility-types/pull/155](https://togithub.com/piotrwitek/utility-types/pull/155) - fix: ReadOnly<T> has a typo in its documentation ([#​156](https://togithub.com/piotrwitek/utility-types/issues/156)) by [@​cyli2014](https://togithub.com/cyli2014) in [https://github.com/piotrwitek/utility-types/pull/157](https://togithub.com/piotrwitek/utility-types/pull/157) - fix: DeepPartial with generic parameter should allow assigning {} by [@​mpiniarski](https://togithub.com/mpiniarski) in [https://github.com/piotrwitek/utility-types/pull/184](https://togithub.com/piotrwitek/utility-types/pull/184) - Fix typo in $Call comment by [@​Yuddomack](https://togithub.com/Yuddomack) in [https://github.com/piotrwitek/utility-types/pull/185](https://togithub.com/piotrwitek/utility-types/pull/185) #### New Contributors - [@​gamtiq](https://togithub.com/gamtiq) made their first contribution in [https://github.com/piotrwitek/utility-types/pull/153](https://togithub.com/piotrwitek/utility-types/pull/153) - [@​zhirzh](https://togithub.com/zhirzh) made their first contribution in [https://github.com/piotrwitek/utility-types/pull/152](https://togithub.com/piotrwitek/utility-types/pull/152) - [@​kumar303](https://togithub.com/kumar303) made their first contribution in [https://github.com/piotrwitek/utility-types/pull/154](https://togithub.com/piotrwitek/utility-types/pull/154) - [@​cyli2014](https://togithub.com/cyli2014) made their first contribution in [https://github.com/piotrwitek/utility-types/pull/157](https://togithub.com/piotrwitek/utility-types/pull/157) - [@​mpiniarski](https://togithub.com/mpiniarski) made their first contribution in [https://github.com/piotrwitek/utility-types/pull/184](https://togithub.com/piotrwitek/utility-types/pull/184) - [@​Yuddomack](https://togithub.com/Yuddomack) made their first contribution in [https://github.com/piotrwitek/utility-types/pull/185](https://togithub.com/piotrwitek/utility-types/pull/185) **Full Changelog**: piotrwitek/utility-types@v3.10.0...v3.11.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 10pm every weekday,before 5am every weekday,every weekend" in timezone Asia/Tokyo, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/macchiitaka/tasks-app-nextjs). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMzUuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEzNS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Description
DeepPartial supports the assignment of
{}
when the passed type is generic:It's not possible to test with
dts-jest
, so I setup an additionaltsconfig.test-d.json
used to runtsc
onsrc/**/*.test-d.ts
files.It would be even better to integrate types testing library like tsd, to be able to assert also cases when type error is expected.
Related issues:
Checklist
For bugfixes: