Skip to content

Commit

Permalink
Update index.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
tebatalla committed Mar 25, 2021
1 parent 89a61c1 commit 0e988d8
Showing 1 changed file with 3 additions and 32 deletions.
35 changes: 3 additions & 32 deletions index.d.ts
Expand Up @@ -3,35 +3,6 @@ import * as PropTypes from 'prop-types';

declare module 'react-moment-proptypes';

export const momentObj: ReactMomentProptypes.RequireableValidator<moment.Moment>;
export const momentString: ReactMomentProptypes.RequireableValidator<string>;
export const momentDurationObj: ReactMomentProptypes.RequireableValidator<moment.Duration>;

/**
* Constructs specific to 'react-moment-proptypes' that are not top-level, but need to be exposed.
*/
export namespace ReactMomentProptypes {

/**
* A prop-type validator with can be extended with a validation predicate.
*/
export interface Validator<T> extends PropTypes.Validator<T | undefined | null> {
withPredicate(isValidMoment: ValidMomentPredicate): Validator<T>,
}

/**
* A prop-type validator that allows for forcing requirement of the corresponding prop.
*/
export interface RequireableValidator<T> extends Validator<T> {
isRequired: Validator<NonNullable<T>>;
}

/**
* Predicate to determine if the specific Moment is valid according to our desired characteristics
*
* @param moment The moment being validated
* @returns true if the Moment is valid
*/
type ValidMomentPredicate = (moment: moment.Moment) => boolean;

}
export const momentObj: PropTypes.Requireable<moment.Moment>;
export const momentString: PropTypes.Requireable<string>;
export const momentDurationObj: PropTypes.Requireable<moment.Duration>;

0 comments on commit 0e988d8

Please sign in to comment.