Provide simplified checkPropTypes implementation#1525
Conversation
… dependency on full package (preactjs#1496)
|
Awesome, that's an excellent start 👍 A few minor changes + some tests cases are missing and then I think it will be ready to go in 🎉 Regarding your questions: Questions/disclosures:
yup, to be able to test against
Our build tool microbundle will automatically transpile it down to ES5 🎉
Good call! Agree, I don't think we need to support that use case. There was a time where devs could write their own prop-type checkers but I haven't seen any of those in the real world so far 👍
It belongs in Let me know what you think 🙂 |
|
Thanks, appreciate the feedback. I can make some of the tweaks right now, but it will take me a bit longer to get up to speed with the test/coverage improvements (likely not until after April 15…). |
…nvert to let/const. (preactjs#1525 (comment)) technically, `loggedTypeFailures` could also be const depending on project style
|
Okay, inline feedback addressed but there's I think two remaining threads from #1525 (comment) here:
Right now If this is just some caching side-effect (I did Otherwise the followup here would be to move As far as coverage, it's a lot better after the recent commits, -0.1% instead of -2.04% but especially since there's already tests for this should be relatively easy to trigger the missing line:
Maybe I'll just look into that while I'm on a roll anyway! |
…while verifying a couple additional expectations
|
Ah, figured out the "why do the tests work" bit too. Which is only coincidental. |
Only debug/test now uses it, so it is not a production dependency. Moving it to a debug/package.json devDependency is not the right solution either, since dependencies of debug/package.json do not actually get installed. Tests have been working only coincidentally right now, as it got installed after all through another devDependency sub-relationship (preactjs#1525 (comment)).
|
I think all the current concerns have been addressed; I'm happy with where this is at and it's ready for review again. |
JoviDeCroock
left a comment
There was a problem hiding this comment.
This looks really good to me and no complaining about less dependencies, makes the ticket about not being tree-shaken a bit easier! Thanks for working on it 💯
This is intended to fix #1496.
I've once again removed the top-level dependency on
prop-types. In its place, I've provided a fairly simplified implementation ofcheckPropTypesbased on just the core of the original.Questions/disclosures:
npm rm -r node_modules && npm install && npm testwhen done. [Resolved: now more tests/familiarity]prop-typesa top-level devDependency. [Resolved: added as top-level devDependency]for (var typeSpecName in typeSpecs) if (typeSpecs.hasOwnProperty(typeSpecName)) {loop withObject.keys(typeSpecs).forEach((typeSpecName) => {which is ES7 (but could trivially become ES5) [Resolved: handled by dist build]varsthough to keep theprocess.env.NODE_ENVcode stripping stuff simple. [Resolved: didn't need NODE_ENV here.]debug/src(next to e.g. "constants.js") or indebug/src/devtools(next to e.g. "custom.js") so I just went with the parent folder. [Resolved: debug/ was correct]