import * as t from "@babel/types" ; const utilityTypes = { $Keys : ( T ) => { return { type : "TSTypeOperator" , typeAnnotation : T , operator : "keyof" , } ; } , $Values : ( T ) => { return t . tsIndexedAccessType ( T , { type : "TSTypeOperator" , typeAnnotation : T , operator : "keyof" , } ) ; } , $ReadOnly : ( T ) => { const typeName = t . identifier ( "Readonly" ) ; const typeParameters = t . tsTypeParameterInstantiation ( [ T ] ) ; return t . tsTypeReference ( typeName , typeParameters ) ; } , $Shape : ( T ) => { const typeName = t . identifier ( "Partial" ) ; const typeParameters = t . tsTypeParameterInstantiation ( [ T ] ) ; return t . tsTypeReference ( typeName , typeParameters ) ; } , $NonMaybeType : ( T ) => { const typeName = t . identifier ( "NonNullable" ) ; const typeParameters = t . tsTypeParameterInstantiation ( [ T ] ) ; return t . tsTypeReference ( typeName , typeParameters ) ; } , $Exact : ( T ) => { return T ; } , $PropertyType : ( T , name ) => { return t . tsIndexedAccessType ( T , name ) ; } , $FlowFixMe : ( ) => { return t . tsAnyKeyword ( ) ; } , Class : null , $Diff : null , $ElementType : null , $Call : null , $Rest : "$Diff" , } ; export const GenericTypeAnnotation = { exit ( path , state ) { const { id : typeName , typeParameters } = path . node ; if ( typeName . name in utilityTypes ) { const value = utilityTypes [ typeName . name ] ; if ( ( typeof value === "function" && state . options . inlineUtilityTypes ) || typeName . name === "$Exact" || typeName . name === "$FlowFixMe" ) { return typeParameters ? value ( ... typeParameters . params ) : value ( ) ; } if ( typeof value === "string" ) { state . usedUtilityTypes . add ( value ) ; return t . tsTypeReference ( t . identifier ( value ) , typeParameters ) ; } state . usedUtilityTypes . add ( typeName . name ) ; } } , } ;