本文整理匯總了TypeScript中airbnb-prop-types.object函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript object函數的具體用法?TypeScript object怎麽用?TypeScript object使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了object函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.nChildren(1, PropTypes.number);
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.nChildren(1, AirbnbPropTypes.childrenOfType('span'));
// $ExpectType Requireable<number>
AirbnbPropTypes.nonNegativeInteger;
// $ExpectType Requireable<number>
AirbnbPropTypes.nonNegativeNumber();
// $ExpectType Requireable<string>
AirbnbPropTypes.numericString();
// $ExpectType Requireable<object>
const props: PropTypes.Requireable<object> = 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<number>
AirbnbPropTypes.range(0, 10);
// $ExpectType Requireable<5>
AirbnbPropTypes.range<5>(0, 10);
// $ExpectType Requireable<string | null>
AirbnbPropTypes.requiredBy('foo', PropTypes.string);
// $ExpectType Validator<number>
示例2:
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.nChildren(1, PropTypes.number);
// $ExpectType Requireable<ReactNodeLike>
AirbnbPropTypes.nChildren(1, AirbnbPropTypes.childrenOfType('span'));
// $ExpectType Requireable<number>
AirbnbPropTypes.nonNegativeInteger;
// $ExpectType Requireable<number>
AirbnbPropTypes.nonNegativeNumber();
// $ExpectType Requireable<string>
AirbnbPropTypes.numericString();
// $ExpectType 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<number>
AirbnbPropTypes.range(0, 10);
// $ExpectType Requireable<5>
AirbnbPropTypes.range<5>(0, 10);
// $ExpectType Requireable<string | null>
AirbnbPropTypes.requiredBy('foo', PropTypes.string);
// $ExpectType Validator<number>