ratehub / check-prop-types Goto Github PK
View Code? Open in Web Editor NEWCheck PropTypes, returning errors instead of logging them
License: MIT License
Check PropTypes, returning errors instead of logging them
License: MIT License
Current version in npm is 1.1.2, which requires "prop-types": "<=15.6.0" - thus preventing usage with newer pro-types.
I see that it's fixed in 1.1.3, but latest version in npm is 1.1.2
prop-types
already have checkPropTypes()
then why this module. Could you please explain the reason behind it?
To use! Just I need to import it in sample.spec.js or sample.js file
// import
import PropTypes, {checkPropTypes} from 'prop-types';
//... direct call that method
checkPropTypes(Sample.propTypes, expectedProps, 'props', Sample.name)
Thanks!
Currently checkPropTypes()
is wrapped in if (process.env.NODE_ENV !== 'production') {
condition.
Can we add some config object as 6th parameter, something like:
function checkPropTypes(typeSpecs, values, location, componentName, getStack, { validateAlways: boolean }) {
Thanks
I'm converting my project to Typescript and am using check-prop-types all over the place in my testing.
I get this message:
Could not find a declaration file for module 'check-prop-types'. '/node_modules/check-prop-types/index.js' implicitly has an 'any' type.
Try npm install @types/check-prop-types
if it exists or add a new declaration (.d.ts) file containing declare module 'check-prop-types';
Would it be possible to make a definition file?
I'm checking proptypes on an object, but no errors are throw when one of the props in the object is incorrect.
For example:
SelectField.propTypes = {
fieldData: PropTypes.shape({
options: PropTypes.array.isRequired,
label: PropTypes.string,
required: PropTypes.bool.isRequired,
type: PropTypes.string.isRequired,
validation_message: PropTypes.string,
}),
};
I set 'required' to empty and no error is returned.
There is no actual return at the end of the function if it doesn't return an error earlier on.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.