File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 isStatement ,
88 isClassBody ,
99 isTSInterfaceBody ,
10+ isTSEnumDeclaration ,
1011} from "@babel/types" ;
1112import type {
1213 RecordAndTuplePluginOptions ,
@@ -1103,7 +1104,8 @@ class Printer {
11031104 singleLine &&
11041105 ! isStatement ( node ) &&
11051106 ! isClassBody ( parent ) &&
1106- ! isTSInterfaceBody ( parent ) ;
1107+ ! isTSInterfaceBody ( parent ) &&
1108+ ! isTSEnumDeclaration ( parent ) ;
11071109
11081110 if ( type === COMMENT_TYPE . LEADING ) {
11091111 this . _printComment (
Original file line number Diff line number Diff line change @@ -634,6 +634,37 @@ describe("generation", function () {
634634 ` ) ;
635635 } ) ;
636636
637+ it ( "comments without loc3" , ( ) => {
638+ const ast = parse (
639+ `
640+ /** This describes how the endpoint is implemented when the lease is deployed */
641+ export enum Endpoint_Kind {
642+ /** SHARED_HTTP - Describes an endpoint that becomes a Kubernetes Ingress */
643+ SHARED_HTTP = 0,
644+ /** RANDOM_PORT - Describes an endpoint that becomes a Kubernetes NodePort */
645+ RANDOM_PORT = 1,
646+ UNRECOGNIZED = -1,
647+ }
648+ ` ,
649+ { sourceType : "module" , plugins : [ "typescript" ] } ,
650+ ) ;
651+
652+ for ( const comment of ast . comments ) {
653+ comment . loc = undefined ;
654+ }
655+
656+ expect ( generate ( ast ) . code ) . toMatchInlineSnapshot ( `
657+ "/** This describes how the endpoint is implemented when the lease is deployed */
658+ export enum Endpoint_Kind {
659+ /** SHARED_HTTP - Describes an endpoint that becomes a Kubernetes Ingress */
660+ SHARED_HTTP = 0,
661+ /** RANDOM_PORT - Describes an endpoint that becomes a Kubernetes NodePort */
662+ RANDOM_PORT = 1,
663+ UNRECOGNIZED = -1,
664+ }"
665+ ` ) ;
666+ } ) ;
667+
637668 it ( "comments without node.loc" , ( ) => {
638669 const ast = parse (
639670 `
You can’t perform that action at this time.
0 commit comments