@@ -46,12 +46,7 @@ export interface TypeScriptDocumentsParsedConfig extends ParsedDocumentsConfig {
4646 noExport : boolean ;
4747 maybeValue : string ;
4848 allowUndefinedQueryVariables : boolean ;
49- enumType :
50- | { type : 'string-literal' }
51- | { type : 'numeric-enums' }
52- | { type : 'as-const' }
53- | { type : 'native-const' }
54- | { type : 'native' } ;
49+ enumType : 'string-literal' | 'numeric' | 'const' | 'native-const' | 'native' ;
5550 futureProofEnums : boolean ;
5651 enumValues : ParsedEnumValuesMap ;
5752}
@@ -75,7 +70,7 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<
7570 preResolveTypes : getConfigValue ( config . preResolveTypes , true ) ,
7671 mergeFragmentTypes : getConfigValue ( config . mergeFragmentTypes , false ) ,
7772 allowUndefinedQueryVariables : getConfigValue ( config . allowUndefinedQueryVariables , false ) ,
78- enumType : getConfigValue ( config . enumType , { type : 'string-literal' } ) ,
73+ enumType : getConfigValue ( config . enumType , 'string-literal' ) ,
7974 enumValues : parseEnumValues ( {
8075 schema,
8176 mapOrStr : config . enumValues ,
@@ -208,7 +203,17 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<
208203 this . config . futureProofEnums ? [ indent ( '| ' + wrapWithSingleQuotes ( '%future added value' ) ) ] : [ ] ,
209204 ] ;
210205
211- if ( this . config . enumType . type === 'string-literal' ) {
206+ // handle:
207+ // - enumValues x
208+ // - future added values
209+
210+ // - ✅ enumsAsTypes
211+ // - numericEnums
212+ // - enumsAsConst
213+ // - native const enum
214+ // - native enum
215+
216+ if ( this . config . enumType === 'string-literal' ) {
212217 return new DeclarationBlock ( this . _declarationBlockConfig )
213218 . asKind ( 'type' )
214219 . withComment ( node . description ?. value )
@@ -228,16 +233,6 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<
228233 ) . string ;
229234 }
230235
231- // handle:
232- // - enumValues x
233- // - future added values
234-
235- // - enumsAsTypes
236- // - numericEnums
237- // - enumsAsConst
238- // - native const enum
239- // - native enum
240-
241236 return 'FOUND ' ;
242237 }
243238
0 commit comments