How to use the airbnb-prop-types.keysOf function in airbnb-prop-types

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 ValidationMap
AirbnbPropTypes.forbidExtraProps({
    foo: PropTypes.string.isRequired,
    bar: PropTypes.number.isRequired,
    baz: PropTypes.bool,
});

// $ExpectType Requireable
AirbnbPropTypes.integer();

const top = ((x?: T): T => x!)();
type Top = typeof top;
declare function validateRequireableTop(x: React.Requireable): void;

validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.number));
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.number, 'foo'));
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.oneOf(['foo', 'bar'])));

// $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);
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
// $ExpectType ValidationMap
AirbnbPropTypes.forbidExtraProps({
    foo: PropTypes.string.isRequired,
    bar: PropTypes.number.isRequired,
    baz: PropTypes.bool,
});

// $ExpectType Requireable
AirbnbPropTypes.integer();

const top = ((x?: T): T => x!)();
type Top = typeof top;
declare function validateRequireableTop(x: React.Requireable): void;

validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.number));
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.number, 'foo'));
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.oneOf(['foo', 'bar'])));

// $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
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
AirbnbPropTypes.forbidExtraProps({
    foo: PropTypes.string.isRequired,
    bar: PropTypes.number.isRequired,
    baz: PropTypes.bool,
});

// $ExpectType Requireable
AirbnbPropTypes.integer();

const top = ((x?: T): T => x!)();
type Top = typeof top;
declare function validateRequireableTop(x: React.Requireable): void;

validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.number));
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.number, 'foo'));
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.oneOf(['foo', 'bar'])));

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