Fix Cropper defaultProps types - #323
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit f054854:
|
|
Would using TypeScript Enums also solve the issue ? |
I'm not a big fan of enums in general as they don't bring anything more than literals unions and are not supported by Babel. I'm not sure but if we use enums for the props definition, library users will have to use the enum as well when setting the props. I'll merge and release this PR once I'm on the computer. I also want to check what the d.ts output looks like. |
|
All good for me 🙂 |
|
Released as v4.0.1. Thank you for your contribution 🎉 |
|
@all-contributors please add @cvolant for code |
|
I've put up a pull request to add @cvolant! 🎉 |
Motivation
Using the above Next.js dynamic import, Typescript complains that Cropper defaultProps are not assignable to Cropper props.
Why? Because defaultProps set
cropShapeto'rect'andobjectFitto'contain', which is good since:... but doing that, TS consider that defaultProps set
cropShapeandobjectFitto astring.What this PR does
It merely adds an
as constbehind the values given tocropShapeandobjectFitin defaultProps.