CropperJS - Use partials for setting methods which take options#24959
Merged
RyanCavanaugh merged 1 commit intoDefinitelyTyped:masterfrom Apr 18, 2018
Merged
Conversation
This commit addresses a problem where the following would produce a type
error, even though it was valid code:
```typescript
setCanvasData({left: 23})
```
I have changed the argument type for all of the `setXXX` methods which
accept an object as their argument. In the spec files for cropperjs,
@fengyuanchen uses these objects as partials for setters. So I have
made the type definitions follow that same pattern.
I changed the `cropperjs.CropBoxData` type to act the same way as well.
It looks like it was changed at some point, I am guessing to allow it
to be used as a partial in the `setCropBoxData` method. Since, like all
the other data structures here, it contains all members when you `get`
it, I have made all members required parts of the object and changed
the setter method to accept a partial.
I hope this all makes sense. Basically, I went from the first line below
to the second.
```typescript
setXXXXX(thing: cropperjs.SomeInterface): void
setXXXXX(thing: Partial<cropperjs.SomeInterface>): void
```
Then I changed `cropperjs.CropBoxData` to fit this new system.
Contributor
|
@happycollision Thank you for submitting this PR! 🔔 @stepancar - please review this PR in the next few days. Be sure to explicitly select If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead. |
Contributor
|
After 5 days, no one has reviewed the PR 😞. A maintainer will be reviewing the PR in the next few days and will either merge it or request revisions. Thank you for your patience! |
Member
|
🌟 🎈 🎉 🏆 🎂 ✨ ⭐️ Congratulations on your first DefinitelyTyped contribution! 🌟 🎈 🎉 🏆 🎂 ✨ ⭐️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please fill in this template.
npm test.)npm run lint package-name(ortscif notslint.jsonis present).Select one of these and delete the others:
If changing an existing definition:
tslint.jsoncontaining{ "extends": "dtslint/dt.json" }.This commit addresses a problem where the following would produce a type
error, even though it was valid code:
I have changed the argument type for all of the
setXXXmethods whichaccept an object as their argument. In the spec files for cropperjs,
@fengyuanchen uses these objects as partials for setters. So I have
made the type definitions follow that same pattern.
I changed the
cropperjs.CropBoxDatatype to act the same way as well.It looks like it was changed at some point, I am guessing to allow it
to be used as a partial in the
setCropBoxDatamethod. Since, like allthe other data structures here, it contains all members when you
getit, I have made all members required parts of the object and changed
the setter method to accept a partial.
I hope this all makes sense. Basically, I went from the first line below
to the second.
Then I changed
cropperjs.CropBoxDatato fit this new system.