Created
December 29, 2019 11:07
-
-
Save piksel/8370652e4a29c2d99e2c74c18150a4b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PropTypes from 'prop-types'; | |
export function interfacePropType<T>(): PropTypes.Requireable<T> { | |
const validator = function(props: { [key: string]: any }, propName: string, componentName: string, location: string, propFullName: string) | |
{ | |
return null; | |
} | |
validator.isRequired= function(props: {[key: string]: any}, propName: string, componentName: string){return null} | |
validator.get = function(target: any, prop: any) { | |
if(prop == PropTypes.nominalTypeHack) { | |
return { type: {} as T } | |
} | |
return target[prop]; | |
} | |
return validator; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment