// Typescript typings for `react-immutable-proptypes` /** Copy of `React.PropTypes`'s `Validator` */ interface Validator { (object: T, key: string, componentName: string, ...rest: any[]): Error | null; } /** Copy of `React.PropTypes`'s `Requireable` */ interface Requireable extends Validator { isRequired: Validator; } /** . * Modification of `React.PropTypes`'s `ValidationMap` type * * `type ValidationMap = { [K in keyof T]?: Validator };` * * original seemd too generic, since it allowed stings and numbers as args */ type ValidatorMap = { [key: string]: Validator }; /** combination of */ type ValidaterOrValidatorMap = Validator | ValidatorMap declare module 'react-immutable-proptypes' { /** * `ImmutablePropTypes.listOf` is based on `React.PropTypes.array` and * is specific to `Immutable.List` */ function listOf(typeChecker: ValidaterOrValidatorMap): Requireable; /** * `ImmutablePropTypes.mapOf` allows you to control both map values and keys * (in `Immutable.Map`, keys could be anything including another Immutable collections). * * * It accepts two arguments - first one for values, second one for keys (_optional_). * * If you are interested in validation of keys only, just pass `React.PropTypes.any` as * the first argument. */ function mapOf(valuesTypeChecker: Requireable, keysTypeChecker?: Requireable): Requireable; /** * `ImmutablePropTypes.orderedMapOf` is basically the same as `mapOf`, * but it is specific to `Immutable.OrderedMap`. */ function orderedMapOf(valuesTypeChecker: Requireable, keysTypeChecker: Requireable): Requireable; /** * `ImmutablePropTypes.setOf` is basically the same as `listOf`, * but it is specific to `Immutable.Set`. */ function setOf(typeChecker: Requireable): Requireable; /** * `ImmutablePropTypes.orderedSetOf` is basically the same as `listOf`, * but it is specific to `Immutable.OrderedSet`. */ function orderedSetOf(typeChecker: Requireable): Requireable; /** * `ImmutablePropTypes.stackOf` is basically the same as `listOf`, * but it is specific to `Immutable.Stack`. */ function stackOf(typeChecker: Requireable): Requireable; /** * `ImmutablePropTypes.iterableOf` is the generic form of `listOf`/`mapOf`. * It is useful when there is no need to validate anything other than Immutable.js * compatible (ie. `Immutable.Iterable`). * * Continue to use `listOf` and/or `mapOf` when you know the type. */ function iterableOf(typeChecker: Requireable): Requireable; /** * `ImmutablePropTypes.recordOf` is like contains, * except it operates on `Record` properties. */ function recordOf(recordKeys: ValidaterOrValidatorMap): Requireable; /** * `ImmutablePropTypes.mapContains` is based on `React.PropTypes.shape` and will only work * with `Immutable.Map`. */ function shape(shapeTypes: ValidaterOrValidatorMap): Requireable; /** * ImmutablePropTypes.contains (formerly `shape`) is based on `React.PropTypes.shape` * and will try to work with any `Immutable.Iterable`. * * In my usage it is the most used validator, as I'm often trying to validate that a `map` * has certain properties with certain values. * @return {Requireable} */ function contains(shapeTypes: ValidaterOrValidatorMap): Requireable; /** * `ImmutablePropTypes.mapContains` is based on `React.PropTypes.shape` and will only work * with `Immutable.Map`. */ function mapContains(shapeTypes: ValidaterOrValidatorMap): Requireable; /** checker for `Immutable.List.isList` */ const list: Requireable; /** checker for `Immutable.Map.isMap` */ const map: Requireable; /** checker for `Immutable.OrderedMap.isOrderedMap` */ const orderedMap: Requireable; /** checker for `Immutable.Set.isSet` */ const set: Requireable; /** checker for `Immutable.OrderedSet.isOrderedSet` */ const orderedSet: Requireable; /** checker for `Immutable.Stack.isStack` */ const stack: Requireable; /** checker for `Immutable.Seq.isSeq` */ const seq: Requireable; /** checker for `instanceof Record` */ const record: Requireable; /** checker for `Immutable.Iterable.isIterable` */ const iterable: Requireable; }