当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript prop-types.arrayOf函数代码示例

本文整理汇总了TypeScript中prop-types.arrayOf函数的典型用法代码示例。如果您正苦于以下问题:TypeScript arrayOf函数的具体用法?TypeScript arrayOf怎么用?TypeScript arrayOf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了arrayOf函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Error

// $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>
AirbnbPropTypes.requiredBy('bar', PropTypes.number, 42).isRequired;

validateRequireableTop(AirbnbPropTypes.restrictedProp());
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => 'Error'));
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => new Error('Error')));
开发者ID:ChaosinaCan,项目名称:DefinitelyTyped,代码行数:31,代码来源:airbnb-prop-types-tests.ts

示例2:

   '300',
   '400',
   '500',
   '600',
   '700',
   '800',
   '900'
 ]),
 /**
  * @platform ios
  */
 fontVariant: ReactPropTypes.arrayOf(
   ReactPropTypes.oneOf([
     'small-caps',
     'oldstyle-nums',
     'lining-nums',
     'tabular-nums',
     'proportional-nums'
   ])
 ),
 textShadowOffset: ReactPropTypes.shape({
   width: ReactPropTypes.number,
   height: ReactPropTypes.number
 }),
 textShadowRadius: ReactPropTypes.number,
 textShadowColor: ColorPropType,
 /**
  * @platform ios
  */
 letterSpacing: ReactPropTypes.number,
 lineHeight: ReactPropTypes.number,
开发者ID:YangShaoQun,项目名称:taro,代码行数:31,代码来源:TextStylePropTypes.ts

示例3: SingleChildShape

export const SingleChildShape = PropTypes.shape({
  id: PropTypes.number,
  active: PropTypes.bool,
  self: (...args) => SingleChildShape(...args),
});

export interface SingleChildShape {
  id?: number;
  active?: boolean;
  self?: SingleChildShape;
}

export const ParentShape = PropTypes.shape({
  id: PropTypes.number,
  name: PropTypes.string,
  children: PropTypes.arrayOf(MultipleChildrenShape),
  orphan: SingleChildShape,
  polymorph: PropTypes.oneOfType([
    SingleChildShape,
    MultipleChildrenShape,
  ]),
  polymorph_fk: KeyShape,
  polymorph_type: PropTypes.string,
});

export interface ParentShape {
  id?: number;
  name?: string;
  children?: Array<MultipleChildrenShape>;
  orphan?: SingleChildShape;
  polymorph?: SingleChildShape | MultipleChildrenShape;
开发者ID:milesj,项目名称:shapeshifter,代码行数:31,代码来源:infer-and-schema-generics.ts

示例4:

   *
   * `transform([{ rotateX: '45deg' }, { rotateZ: '0.785398rad' }])`
   *
   * The skew transformations require a string so that the transform may be
   * expressed in degrees (deg). For example:
   *
   * `transform([{ skewX: '45deg' }])`
   */
  transform: ReactPropTypes.arrayOf(
    ReactPropTypes.oneOfType([
      ReactPropTypes.shape({perspective: ReactPropTypes.number}),
      ReactPropTypes.shape({rotate: ReactPropTypes.string}),
      ReactPropTypes.shape({rotateX: ReactPropTypes.string}),
      ReactPropTypes.shape({rotateY: ReactPropTypes.string}),
      ReactPropTypes.shape({rotateZ: ReactPropTypes.string}),
      ReactPropTypes.shape({scale: ReactPropTypes.number}),
      ReactPropTypes.shape({scaleX: ReactPropTypes.number}),
      ReactPropTypes.shape({scaleY: ReactPropTypes.number}),
      ReactPropTypes.shape({translateX: ReactPropTypes.number}),
      ReactPropTypes.shape({translateY: ReactPropTypes.number}),
      ReactPropTypes.shape({skewX: ReactPropTypes.string}),
      ReactPropTypes.shape({skewY: ReactPropTypes.string})
    ])
  ),

  /**
   * Deprecated. Use the transform prop instead.
   */
  transformMatrix: TransformMatrixPropType,
  /**
   * Deprecated. Use the transform prop instead.
   */
开发者ID:YangShaoQun,项目名称:taro,代码行数:32,代码来源:TransformPropTypes.ts

示例5:

    node: PropTypes.node,
    requiredNode: PropTypes.node.isRequired,
    number: PropTypes.number.isRequired,
    object: PropTypes.object.isRequired,
    string: PropTypes.string.isRequired,
    symbol: PropTypes.symbol.isRequired,
    instanceOf: PropTypes.instanceOf(TestClass).isRequired,
    oneOf: PropTypes.oneOf<'a' | 'b' | 'c'>(['a', 'b', 'c']).isRequired,
    oneOfType: PropTypes.oneOfType(arrayOfTypes).isRequired,
    numberOrFalse: PropTypes.oneOfType([PropTypes.oneOf<false>([false]), PropTypes.number]).isRequired,
    // The generic function type (() => any) is assignable to ReactNode because ReactNode extends the empty object type {}
    // Which widens the array literal of validators to just Array<Requireable<() => any>>
    // It's too risky to change ReactNode to exclude {} even though it's invalid, as it's required for children-as-function props to work
    // So we assert the explicit tuple type
    nodeOrRenderFn: PropTypes.oneOfType([PropTypes.node, PropTypes.func] as [PropTypes.Requireable<ReactNode>, PropTypes.Requireable<() => any>]),
    arrayOf: PropTypes.arrayOf(PropTypes.bool.isRequired).isRequired,
    objectOf: PropTypes.objectOf(PropTypes.number.isRequired).isRequired,
    shape: PropTypes.shape(innerProps).isRequired,
    optionalNumber: PropTypes.number,
    customProp: (() => null) as PropTypes.Validator<typeof uniqueType | undefined>
};

// JS checking
const propTypesWithoutAnnotation = {
    any: PropTypes.any,
    array: PropTypes.array.isRequired,
    bool: PropTypes.bool.isRequired,
    element: PropTypes.element.isRequired,
    func: PropTypes.func.isRequired,
    node: PropTypes.node,
    requiredNode: PropTypes.node.isRequired,
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:31,代码来源:prop-types-tests.ts


注:本文中的prop-types.arrayOf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。