mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add types for react-immutable-proptypes (#37746)
This commit is contained in:
parent
ed915d5618
commit
9c1db51afd
31
types/react-immutable-proptypes/index.d.ts
vendored
Normal file
31
types/react-immutable-proptypes/index.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Type definitions for react-immutable-proptypes 2.1
|
||||
// Project: https://github.com/HurricaneJames/react-immutable-proptypes
|
||||
// Definitions by: Joris van der Wel <https://github.com/Joris-van-der-Wel>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Validator, Requireable, ValidationMap } from 'prop-types';
|
||||
import * as Immutable from 'immutable';
|
||||
|
||||
export function listOf<V>(type: Validator<V>): Requireable<Immutable.List<V>>;
|
||||
export function mapOf<V, K = any>(valueType: Validator<V>, keyType?: Validator<K>): Requireable<Immutable.Map<K, V>>;
|
||||
export function orderedMapOf<V, K = any>(valueType: Validator<V>, keyType?: Validator<K>): Requireable<Immutable.OrderedMap<K, V>>;
|
||||
export function setOf<V>(type: Validator<V>): Requireable<Immutable.Set<V>>;
|
||||
export function orderedSetOf<V>(type: Validator<V>): Requireable<Immutable.OrderedSet<V>>;
|
||||
export function stackOf<V>(type: Validator<V>): Requireable<Immutable.Stack<V>>;
|
||||
export function iterableOf<V>(type: Validator<V>): Requireable<Immutable.Iterable<any, V>>;
|
||||
// todo: recordOf can be made more useful when immutable v4 releases, because it has much better typescript
|
||||
// support (for example by setting the return type to RecordOf<InferProps<P>>)
|
||||
export function recordOf(type: ValidationMap<any>): Requireable<Immutable.Map<string, any>>;
|
||||
export function shape(type: ValidationMap<any>): Requireable<Immutable.Iterable<any, any>>;
|
||||
export function contains(type: ValidationMap<any>): Requireable<Immutable.Iterable<any, any>>;
|
||||
export function mapContains(type: ValidationMap<any>): Requireable<Immutable.Map<any, any>>;
|
||||
export const list: Requireable<Immutable.List<any>>;
|
||||
export const map: Requireable<Immutable.Map<any, any>>;
|
||||
export const orderedMap: Requireable<Immutable.OrderedMap<any, any>>;
|
||||
export const set: Requireable<Immutable.Set<any>>;
|
||||
export const orderedSet: Requireable<Immutable.OrderedSet<any>>;
|
||||
export const stack: Requireable<Immutable.Stack<any>>;
|
||||
export const seq: Requireable<Immutable.Seq<any, any>>;
|
||||
export const record: Requireable<Immutable.Map<string, any>>;
|
||||
export const iterable: Requireable<Immutable.Iterable<any, any>>;
|
||||
6
types/react-immutable-proptypes/package.json
Normal file
6
types/react-immutable-proptypes/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"immutable": "^3.8.2"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
import * as PropTypes from 'prop-types';
|
||||
import * as Immutable from 'immutable';
|
||||
import * as ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
|
||||
interface Props {
|
||||
list: Immutable.List<any>;
|
||||
map: Immutable.Map<any, any>;
|
||||
orderedMap: Immutable.OrderedMap<any, any>;
|
||||
set: Immutable.Set<any>;
|
||||
orderedSet: Immutable.OrderedSet<any>;
|
||||
stack: Immutable.Stack<any>;
|
||||
seq: Immutable.Seq<any, any>;
|
||||
record: Immutable.Map<string, any>;
|
||||
iterable: Immutable.Iterable<any, any>;
|
||||
listOf: Immutable.List<string>;
|
||||
mapOf: Immutable.Map<string, number>;
|
||||
mapOfNoKey: Immutable.Map<any, number>;
|
||||
orderedMapOf: Immutable.OrderedMap<string, number>;
|
||||
orderedMapOfNoKey: Immutable.OrderedMap<any, number>;
|
||||
setOf: Immutable.Set<string>;
|
||||
orderedSetOf: Immutable.OrderedSet<string>;
|
||||
stackOf: Immutable.Stack<string>;
|
||||
iterableOf: Immutable.Iterable<any, string>;
|
||||
recordOf: Immutable.Map<string, any>;
|
||||
shape: Immutable.Iterable<any, any>;
|
||||
contains: Immutable.Iterable<any, any>;
|
||||
mapContains: Immutable.Map<any, any>;
|
||||
}
|
||||
|
||||
const propTypes: PropTypes.ValidationMap<Props> = {
|
||||
list: ImmutablePropTypes.list.isRequired,
|
||||
map: ImmutablePropTypes.map.isRequired,
|
||||
orderedMap: ImmutablePropTypes.orderedMap.isRequired,
|
||||
set: ImmutablePropTypes.set.isRequired,
|
||||
orderedSet: ImmutablePropTypes.orderedSet.isRequired,
|
||||
stack: ImmutablePropTypes.stack.isRequired,
|
||||
seq: ImmutablePropTypes.seq.isRequired,
|
||||
record: ImmutablePropTypes.record.isRequired,
|
||||
iterable: ImmutablePropTypes.iterable.isRequired,
|
||||
listOf: ImmutablePropTypes.listOf(
|
||||
PropTypes.string.isRequired
|
||||
).isRequired,
|
||||
mapOf: ImmutablePropTypes.mapOf(
|
||||
PropTypes.number.isRequired,
|
||||
PropTypes.string.isRequired
|
||||
).isRequired,
|
||||
mapOfNoKey: ImmutablePropTypes.mapOf(
|
||||
PropTypes.number.isRequired
|
||||
).isRequired,
|
||||
orderedMapOf: ImmutablePropTypes.orderedMapOf(
|
||||
PropTypes.number.isRequired,
|
||||
PropTypes.string.isRequired
|
||||
).isRequired,
|
||||
orderedMapOfNoKey: ImmutablePropTypes.orderedMapOf(
|
||||
PropTypes.number.isRequired
|
||||
).isRequired,
|
||||
setOf: ImmutablePropTypes.setOf(
|
||||
PropTypes.string.isRequired
|
||||
).isRequired,
|
||||
orderedSetOf: ImmutablePropTypes.orderedSetOf(
|
||||
PropTypes.string.isRequired
|
||||
).isRequired,
|
||||
stackOf: ImmutablePropTypes.stackOf(
|
||||
PropTypes.string.isRequired
|
||||
).isRequired,
|
||||
iterableOf: ImmutablePropTypes.iterableOf(
|
||||
PropTypes.string.isRequired
|
||||
).isRequired,
|
||||
recordOf: ImmutablePropTypes.recordOf({
|
||||
foo: PropTypes.string.isRequired,
|
||||
}).isRequired,
|
||||
shape: ImmutablePropTypes.shape({
|
||||
foo: PropTypes.string.isRequired,
|
||||
}).isRequired,
|
||||
contains: ImmutablePropTypes.contains({
|
||||
foo: PropTypes.string.isRequired,
|
||||
}).isRequired,
|
||||
mapContains: ImmutablePropTypes.mapContains({
|
||||
foo: PropTypes.string.isRequired,
|
||||
}).isRequired,
|
||||
};
|
||||
|
||||
type ExtractedProps = PropTypes.InferProps<typeof propTypes>;
|
||||
|
||||
// $ExpectType true
|
||||
type ExtractPropsMatch = ExtractedProps extends Props ? true : false;
|
||||
23
types/react-immutable-proptypes/tsconfig.json
Normal file
23
types/react-immutable-proptypes/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-immutable-proptypes-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/react-immutable-proptypes/tslint.json
Normal file
1
types/react-immutable-proptypes/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user