@@ -92,7 +92,10 @@ const getGeneratorDefinition = (value: GeneratorDefinition | GeneratorName): Gen
9292 return value ;
9393} ;
9494
95- const getCasualCustomValue = ( generatorDefinition : GeneratorDefinition , opts : Options < NamedTypeNode > ) => {
95+ const getCasualCustomValue = (
96+ generatorDefinition : GeneratorDefinition ,
97+ opts : Options < NamedTypeNode | ObjectTypeDefinitionNode > ,
98+ ) => {
9699 // If there is a mapping to a `casual` type, then use it and make sure
97100 // to call it if it's a function
98101 const embeddedGenerator = casual [ generatorDefinition . generator ] ;
@@ -161,7 +164,10 @@ const getFakerGenerators = (generatorName: GeneratorName) => {
161164 return { embeddedGenerator : null , dynamicGenerator : null } ;
162165} ;
163166
164- const getFakerCustomValue = ( generatorDefinition : GeneratorDefinition , opts : Options < NamedTypeNode > ) => {
167+ const getFakerCustomValue = (
168+ generatorDefinition : GeneratorDefinition ,
169+ opts : Options < NamedTypeNode | ObjectTypeDefinitionNode > ,
170+ ) => {
165171 // If there is a mapping to a `faker` type, then use it
166172 const { embeddedGenerator, dynamicGenerator } = getFakerGenerators ( generatorDefinition . generator ) ;
167173 if ( ! embeddedGenerator && generatorDefinition . generator ) {
@@ -206,7 +212,10 @@ const getFakerCustomValue = (generatorDefinition: GeneratorDefinition, opts: Opt
206212 return value ;
207213} ;
208214
209- const getCustomValue = ( generatorDefinition : GeneratorDefinition , opts : Options < NamedTypeNode > ) => {
215+ const getCustomValue = (
216+ generatorDefinition : GeneratorDefinition ,
217+ opts : Options < NamedTypeNode | ObjectTypeDefinitionNode > ,
218+ ) => {
210219 if ( opts . generateLibrary === 'casual' ) {
211220 return getCasualCustomValue ( generatorDefinition , opts ) ;
212221 }
@@ -219,7 +228,7 @@ const getCustomValue = (generatorDefinition: GeneratorDefinition, opts: Options<
219228} ;
220229
221230const handleValueGeneration = (
222- opts : Options < NamedTypeNode > ,
231+ opts : Options < NamedTypeNode | ObjectTypeDefinitionNode > ,
223232 customScalar : GeneratorDefinition ,
224233 baseGenerator : ( ) => void ,
225234) => {
@@ -244,18 +253,20 @@ const handleValueGeneration = (
244253 return baseGenerator ( ) ;
245254} ;
246255
247- const getNamedImplementType = ( opts : Options < TypeItem [ 'types' ] > ) : string => {
248- if ( ! opts . currentType || ! ( 'name' in opts . currentType ) ) {
256+ const getNamedImplementType = ( opts : Options < TypeItem [ 'types' ] > ) : string | number | boolean => {
257+ const { currentType } = opts ;
258+
259+ if ( ! currentType || ! ( 'name' in currentType ) ) {
249260 return '' ;
250261 }
251262
252- const name = opts . currentType . name . value ;
253- const casedName = createNameConverter ( opts . typeNamesConvention , opts . transformUnderscore ) ( name ) ;
254-
255- return ` ${ toMockName ( name , casedName , opts . prefix ) } ()` ;
263+ return getNamedType ( {
264+ ... opts ,
265+ currentType ,
266+ } ) ;
256267} ;
257268
258- const getNamedType = ( opts : Options < NamedTypeNode > ) : string | number | boolean => {
269+ const getNamedType = ( opts : Options < NamedTypeNode | ObjectTypeDefinitionNode > ) : string | number | boolean => {
259270 if ( ! opts . currentType ) {
260271 return '' ;
261272 }
0 commit comments