@@ -20,7 +20,6 @@ import {
2020 Kind ,
2121 GraphQLEnumType ,
2222} from 'graphql' ;
23- import flatMap from 'array.prototype.flatmap' ;
2423import { BaseVisitor , ParsedConfig , RawConfig } from './base-visitor' ;
2524import { DEFAULT_SCALARS } from './scalars' ;
2625import { normalizeDeclarationKind } from './declaration-kinds' ;
@@ -329,7 +328,7 @@ export class BaseTypesVisitor<
329328 }
330329
331330 NonNullType ( node : NonNullTypeNode ) : string {
332- const asString = ( node . type as any ) as string ;
331+ const asString = node . type as any as string ;
333332
334333 return asString ;
335334 }
@@ -339,7 +338,7 @@ export class BaseTypesVisitor<
339338 . export ( )
340339 . asKind ( this . _parsedConfig . declarationKind . input )
341340 . withName ( this . convertName ( node ) )
342- . withComment ( ( node . description as any ) as string )
341+ . withComment ( node . description as any as string )
343342 . withBlock ( node . fields . join ( '\n' ) ) ;
344343 }
345344
@@ -348,7 +347,7 @@ export class BaseTypesVisitor<
348347 }
349348
350349 InputValueDefinition ( node : InputValueDefinitionNode ) : string {
351- const comment = transformComment ( ( node . description as any ) as string , 1 ) ;
350+ const comment = transformComment ( node . description as any as string , 1 ) ;
352351 const { input } = this . _parsedConfig . declarationKind ;
353352
354353 return comment + indent ( `${ node . name } : ${ node . type } ${ this . getPunctuation ( input ) } ` ) ;
@@ -359,7 +358,7 @@ export class BaseTypesVisitor<
359358 }
360359
361360 FieldDefinition ( node : FieldDefinitionNode ) : string {
362- const typeString = ( node . type as any ) as string ;
361+ const typeString = node . type as any as string ;
363362 const { type } = this . _parsedConfig . declarationKind ;
364363 const comment = this . getFieldComment ( node ) ;
365364
@@ -377,7 +376,7 @@ export class BaseTypesVisitor<
377376 . export ( )
378377 . asKind ( 'type' )
379378 . withName ( this . convertName ( node ) )
380- . withComment ( ( node . description as any ) as string )
379+ . withComment ( node . description as any as string )
381380 . withContent ( possibleTypes ) . string ;
382381 }
383382
@@ -414,7 +413,7 @@ export class BaseTypesVisitor<
414413 . export ( )
415414 . asKind ( type )
416415 . withName ( this . convertName ( node ) )
417- . withComment ( ( node . description as any ) as string ) ;
416+ . withComment ( node . description as any as string ) ;
418417
419418 if ( type === 'interface' || type === 'class' ) {
420419 if ( interfacesNames . length > 0 ) {
@@ -463,7 +462,7 @@ export class BaseTypesVisitor<
463462 . export ( )
464463 . asKind ( this . _parsedConfig . declarationKind . interface )
465464 . withName ( this . convertName ( node ) )
466- . withComment ( ( node . description as any ) as string ) ;
465+ . withComment ( node . description as any as string ) ;
467466
468467 return declarationBlock . withBlock ( node . fields . join ( '\n' ) ) ;
469468 }
@@ -509,28 +508,30 @@ export class BaseTypesVisitor<
509508 }
510509
511510 public getEnumsImports ( ) : string [ ] {
512- return flatMap ( Object . keys ( this . config . enumValues ) , enumName => {
513- const mappedValue = this . config . enumValues [ enumName ] ;
514-
515- if ( mappedValue . sourceFile ) {
516- if ( mappedValue . isDefault ) {
517- return [ this . _buildTypeImport ( mappedValue . typeIdentifier , mappedValue . sourceFile , true ) ] ;
511+ return Object . keys ( this . config . enumValues )
512+ . flatMap ( enumName => {
513+ const mappedValue = this . config . enumValues [ enumName ] ;
514+
515+ if ( mappedValue . sourceFile ) {
516+ if ( mappedValue . isDefault ) {
517+ return [ this . _buildTypeImport ( mappedValue . typeIdentifier , mappedValue . sourceFile , true ) ] ;
518+ }
519+
520+ return this . handleEnumValueMapper (
521+ mappedValue . typeIdentifier ,
522+ mappedValue . importIdentifier ,
523+ mappedValue . sourceIdentifier ,
524+ mappedValue . sourceFile
525+ ) ;
518526 }
519527
520- return this . handleEnumValueMapper (
521- mappedValue . typeIdentifier ,
522- mappedValue . importIdentifier ,
523- mappedValue . sourceIdentifier ,
524- mappedValue . sourceFile
525- ) ;
526- }
527-
528- return [ ] ;
529- } ) . filter ( a => a ) ;
528+ return [ ] ;
529+ } )
530+ . filter ( Boolean ) ;
530531 }
531532
532533 EnumTypeDefinition ( node : EnumTypeDefinitionNode ) : string {
533- const enumName = ( node . name as any ) as string ;
534+ const enumName = node . name as any as string ;
534535
535536 // In case of mapped external enum string
536537 if ( this . config . enumValues [ enumName ] && this . config . enumValues [ enumName ] . sourceFile ) {
@@ -541,7 +542,7 @@ export class BaseTypesVisitor<
541542 . export ( )
542543 . asKind ( 'enum' )
543544 . withName ( this . convertName ( node , { useTypesPrefix : this . config . enumPrefix } ) )
544- . withComment ( ( node . description as any ) as string )
545+ . withComment ( node . description as any as string )
545546 . withBlock ( this . buildEnumValuesBlock ( enumName , node . values ) ) . string ;
546547 }
547548
@@ -567,7 +568,7 @@ export class BaseTypesVisitor<
567568 const optionName = this . makeValidEnumIdentifier (
568569 this . convertName ( enumOption , { useTypesPrefix : false , transformUnderscore : true } )
569570 ) ;
570- const comment = transformComment ( ( enumOption . description as any ) as string , 1 ) ;
571+ const comment = transformComment ( enumOption . description as any as string , 1 ) ;
571572 const schemaEnumValue =
572573 schemaEnumType && ! this . config . ignoreEnumValuesFromSchema
573574 ? schemaEnumType . getValue ( enumOption . name as any ) . value
@@ -644,7 +645,7 @@ export class BaseTypesVisitor<
644645 }
645646
646647 protected _getTypeForNode ( node : NamedTypeNode ) : string {
647- const typeAsString = ( node . name as any ) as string ;
648+ const typeAsString = node . name as any as string ;
648649
649650 if ( this . scalars [ typeAsString ] ) {
650651 return this . _getScalar ( typeAsString ) ;
@@ -674,7 +675,7 @@ export class BaseTypesVisitor<
674675 }
675676
676677 ListType ( node : ListTypeNode ) : string {
677- const asString = ( node . type as any ) as string ;
678+ const asString = node . type as any as string ;
678679
679680 return this . wrapWithListType ( asString ) ;
680681 }
0 commit comments