Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// $ExpectType Requireable
AirbnbPropTypes.elementType(ClassComp);
// $ExpectType Requireable
AirbnbPropTypes.elementType(FuncComp);
// $ExpectType Requireable
AirbnbPropTypes.elementType('div');
// $ExpectType Requireable
AirbnbPropTypes.elementType('*');
// $ExpectError
AirbnbPropTypes.elementType(ClassComp, FuncComp, 'div');
// $ExpectType Requireable
AirbnbPropTypes.explicitNull();
// $ExpectType Validator
AirbnbPropTypes.explicitNull().isRequired;
interface ForbidShape {
foo: string;
bar: number;
baz?: boolean | null;
}
// $ExpectType ValidationMap<{ foo: string | null | undefined; bar: number; baz: boolean | null | undefined; }>
AirbnbPropTypes.forbidExtraProps({
foo: PropTypes.string,
bar: PropTypes.number.isRequired,
baz: PropTypes.bool,
});
// $ExpectType ValidationMap
AirbnbPropTypes.forbidExtraProps({
import React from 'react';
import { intersects } from 'semver';
import { or, explicitNull } from 'airbnb-prop-types';
import PropTypes from 'prop-types';
const propTypes = {
children: or([explicitNull().isRequired, PropTypes.node.isRequired]),
};
const defaultProps = {
children: undefined,
};
const Wrapper = (intersects('>= 0.14', React.version)
// eslint-disable-next-line prefer-arrow-callback
? () => Object.assign(function SimpleSFCWrapper({ children }) {
return children;
}, { propTypes, defaultProps })
: () => {
class SimpleClassWrapper extends React.Component {
render() {
const { children } = this.props;
return children;