How to use airbnb-prop-types - 10 common examples

To help you get started, we’ve selected a few airbnb-prop-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
// $ExpectType Requireable
AirbnbPropTypes.mutuallyExclusiveProps(PropTypes.number);
// $ExpectType Requireable
AirbnbPropTypes.mutuallyExclusiveProps(PropTypes.number, 'foo');
// $ExpectType Requireable
AirbnbPropTypes.mutuallyExclusiveProps(PropTypes.string, 'foo', 'bar');

// $ExpectType Requireable
AirbnbPropTypes.mutuallyExclusiveTrueProps('foo');
// $ExpectType Requireable
AirbnbPropTypes.mutuallyExclusiveTrueProps('foo', 'bar');

// $ExpectType Requireable
AirbnbPropTypes.nChildren(1, PropTypes.number);
// $ExpectType Requireable
AirbnbPropTypes.nChildren(1, AirbnbPropTypes.childrenOfType('span'));

// $ExpectType Requireable
AirbnbPropTypes.nonNegativeInteger;

// $ExpectType Requireable
AirbnbPropTypes.nonNegativeNumber();

// $ExpectType Requireable
AirbnbPropTypes.numericString();

// $ExpectType Requireable
const props: PropTypes.Requireable = AirbnbPropTypes.object();
// $ExpectType Requireable<{ foo: string; }>
AirbnbPropTypes.object<{ foo: string }>();

AirbnbPropTypes.or([PropTypes.bool.isRequired, AirbnbPropTypes.explicitNull().isRequired]);
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
// $ExpectType Requireable
AirbnbPropTypes.between({ gte: 4 });
// $ExpectType Requireable
AirbnbPropTypes.between({ lt: 1, gt: 0 });

// $ExpectType Requireable
AirbnbPropTypes.booleanSome('foo', 'bar', 'baz');

// $ExpectType Requireable
AirbnbPropTypes.childrenHavePropXorChildren('foo');

// $ExpectType Requireable
AirbnbPropTypes.childrenOf(PropTypes.string);

// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(FuncComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType('div');
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp, FuncComp, 'div');

// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.number });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.string, max: 100 });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.bool, min: 0 });

// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo');
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
// $ExpectType Requireable
AirbnbPropTypes.between({ lt: 1, gt: 0 });

// $ExpectType Requireable
AirbnbPropTypes.booleanSome('foo', 'bar', 'baz');

// $ExpectType Requireable
AirbnbPropTypes.childrenHavePropXorChildren('foo');

// $ExpectType Requireable
AirbnbPropTypes.childrenOf(PropTypes.string);

// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(FuncComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType('div');
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp, FuncComp, 'div');

// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.number });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.string, max: 100 });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.bool, min: 0 });

// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo');
// $ExpectType Requireable
AirbnbPropTypes.componentWithName(/Foo/);
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
// $ExpectType Requireable
AirbnbPropTypes.booleanSome('foo', 'bar', 'baz');

// $ExpectType Requireable
AirbnbPropTypes.childrenHavePropXorChildren('foo');

// $ExpectType Requireable
AirbnbPropTypes.childrenOf(PropTypes.string);

// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(FuncComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType('div');
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp, FuncComp, 'div');

// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.number });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.string, max: 100 });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.bool, min: 0 });

// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo');
// $ExpectType Requireable
AirbnbPropTypes.componentWithName(/Foo/);
// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo', { stripHOCs: ['connect'] });
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType('div');
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp, FuncComp, 'div');

// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.number });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.string, max: 100 });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.bool, min: 0 });

// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo');
// $ExpectType Requireable
AirbnbPropTypes.componentWithName(/Foo/);
// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo', { stripHOCs: ['connect'] });

// $ExpectType Requireable
AirbnbPropTypes.disallowedIf(PropTypes.number, 'foo', PropTypes.string);

// $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');
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp, FuncComp, 'div');

// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.number });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.string, max: 100 });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.bool, min: 0 });

// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo');
// $ExpectType Requireable
AirbnbPropTypes.componentWithName(/Foo/);
// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo', { stripHOCs: ['connect'] });

// $ExpectType Requireable
AirbnbPropTypes.disallowedIf(PropTypes.number, 'foo', PropTypes.string);

// $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
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
AirbnbPropTypes.object<{ foo: string }>();

AirbnbPropTypes.or([PropTypes.bool.isRequired, AirbnbPropTypes.explicitNull().isRequired]);
AirbnbPropTypes.or([PropTypes.bool, PropTypes.number, PropTypes.arrayOf(PropTypes.string)]);
AirbnbPropTypes.or([PropTypes.number, PropTypes.string, PropTypes.bool], 'foo');

// $ExpectType Requireable
AirbnbPropTypes.range(0, 10);
// $ExpectType Requireable<5>
AirbnbPropTypes.range<5>(0, 10);

// $ExpectType Requireable>
AirbnbPropTypes.ref();

// $ExpectType Requireable
AirbnbPropTypes.requiredBy('foo', PropTypes.string);
// $ExpectType Validator
AirbnbPropTypes.requiredBy('bar', PropTypes.number, 42).isRequired;

validateRequireableTop(AirbnbPropTypes.restrictedProp());
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => 'Error'));
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => new Error('Error')));

validateRequireableTop(AirbnbPropTypes.sequenceOf({ validator: PropTypes.number }));
validateRequireableTop(AirbnbPropTypes.sequenceOf({ validator: PropTypes.number }, { validator: PropTypes.string }));
validateRequireableTop(AirbnbPropTypes.sequenceOf(
    { validator: PropTypes.number, min: 0, max: 10 },
    { validator: PropTypes.string },
    { validator: PropTypes.bool },
));

interface ShapeShape {
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
AirbnbPropTypes.or([PropTypes.bool.isRequired, AirbnbPropTypes.explicitNull().isRequired]);
AirbnbPropTypes.or([PropTypes.bool, PropTypes.number, PropTypes.arrayOf(PropTypes.string)]);
AirbnbPropTypes.or([PropTypes.number, PropTypes.string, PropTypes.bool], 'foo');

// $ExpectType Requireable
AirbnbPropTypes.range(0, 10);
// $ExpectType Requireable<5>
AirbnbPropTypes.range<5>(0, 10);

// $ExpectType Requireable>
AirbnbPropTypes.ref();

// $ExpectType Requireable
AirbnbPropTypes.requiredBy('foo', PropTypes.string);
// $ExpectType Validator
AirbnbPropTypes.requiredBy('bar', PropTypes.number, 42).isRequired;

validateRequireableTop(AirbnbPropTypes.restrictedProp());
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => 'Error'));
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => new Error('Error')));

validateRequireableTop(AirbnbPropTypes.sequenceOf({ validator: PropTypes.number }));
validateRequireableTop(AirbnbPropTypes.sequenceOf({ validator: PropTypes.number }, { validator: PropTypes.string }));
validateRequireableTop(AirbnbPropTypes.sequenceOf(
    { validator: PropTypes.number, min: 0, max: 10 },
    { validator: PropTypes.string },
    { validator: PropTypes.bool },
));

interface ShapeShape {
    foo: string;
    bar?: number | null;
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
AirbnbPropTypes.nonNegativeInteger;

// $ExpectType Requireable
AirbnbPropTypes.nonNegativeNumber();

// $ExpectType Requireable
AirbnbPropTypes.numericString();

// $ExpectType Requireable
const props: PropTypes.Requireable = AirbnbPropTypes.object();
// $ExpectType Requireable<{ foo: string; }>
AirbnbPropTypes.object<{ foo: string }>();

AirbnbPropTypes.or([PropTypes.bool.isRequired, AirbnbPropTypes.explicitNull().isRequired]);
AirbnbPropTypes.or([PropTypes.bool, PropTypes.number, PropTypes.arrayOf(PropTypes.string)]);
AirbnbPropTypes.or([PropTypes.number, PropTypes.string, PropTypes.bool], 'foo');

// $ExpectType Requireable
AirbnbPropTypes.range(0, 10);
// $ExpectType Requireable<5>
AirbnbPropTypes.range<5>(0, 10);

// $ExpectType Requireable>
AirbnbPropTypes.ref();

// $ExpectType Requireable
AirbnbPropTypes.requiredBy('foo', PropTypes.string);
// $ExpectType Validator
AirbnbPropTypes.requiredBy('bar', PropTypes.number, 42).isRequired;

validateRequireableTop(AirbnbPropTypes.restrictedProp());
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => 'Error'));
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo', { stripHOCs: ['connect'] });

// $ExpectType Requireable
AirbnbPropTypes.disallowedIf(PropTypes.number, 'foo', PropTypes.string);

// $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,