@@ -699,9 +699,11 @@ namespace ts {
699699 case SyntaxKind . JsxText :
700700 return emitJsxText ( < JsxText > node ) ;
701701 case SyntaxKind . JsxOpeningElement :
702- return emitJsxOpeningElement ( < JsxOpeningElement > node ) ;
702+ case SyntaxKind . JsxOpeningFragment :
703+ return emitJsxOpeningElementOrFragment ( < JsxOpeningElement > node ) ;
703704 case SyntaxKind . JsxClosingElement :
704- return emitJsxClosingElement ( < JsxClosingElement > node ) ;
705+ case SyntaxKind . JsxClosingFragment :
706+ return emitJsxClosingElementOrFragment ( < JsxClosingElement > node ) ;
705707 case SyntaxKind . JsxAttribute :
706708 return emitJsxAttribute ( < JsxAttribute > node ) ;
707709 case SyntaxKind . JsxAttributes :
@@ -836,6 +838,8 @@ namespace ts {
836838 return emitJsxElement ( < JsxElement > node ) ;
837839 case SyntaxKind . JsxSelfClosingElement :
838840 return emitJsxSelfClosingElement ( < JsxSelfClosingElement > node ) ;
841+ case SyntaxKind . JsxFragment :
842+ return emitJsxFragment ( < JsxFragment > node ) ;
839843
840844 // Transformation nodes
841845 case SyntaxKind . PartiallyEmittedExpression :
@@ -2060,7 +2064,7 @@ namespace ts {
20602064
20612065 function emitJsxElement ( node : JsxElement ) {
20622066 emit ( node . openingElement ) ;
2063- emitList ( node , node . children , ListFormat . JsxElementChildren ) ;
2067+ emitList ( node , node . children , ListFormat . JsxElementOrFragmentChildren ) ;
20642068 emit ( node . closingElement ) ;
20652069 }
20662070
@@ -2075,24 +2079,36 @@ namespace ts {
20752079 write ( "/>" ) ;
20762080 }
20772081
2078- function emitJsxOpeningElement ( node : JsxOpeningElement ) {
2082+ function emitJsxFragment ( node : JsxFragment ) {
2083+ emit ( node . openingFragment ) ;
2084+ emitList ( node , node . children , ListFormat . JsxElementOrFragmentChildren ) ;
2085+ emit ( node . closingFragment ) ;
2086+ }
2087+
2088+ function emitJsxOpeningElementOrFragment ( node : JsxOpeningElement | JsxOpeningFragment ) {
20792089 write ( "<" ) ;
2080- emitJsxTagName ( node . tagName ) ;
2081- writeIfAny ( node . attributes . properties , " " ) ;
2082- // We are checking here so we won't re-enter the emitting pipeline and emit extra sourcemap
2083- if ( node . attributes . properties && node . attributes . properties . length > 0 ) {
2084- emit ( node . attributes ) ;
2090+
2091+ if ( isJsxOpeningElement ( node ) ) {
2092+ emitJsxTagName ( node . tagName ) ;
2093+ // We are checking here so we won't re-enter the emitting pipeline and emit extra sourcemap
2094+ if ( node . attributes . properties && node . attributes . properties . length > 0 ) {
2095+ write ( " " ) ;
2096+ emit ( node . attributes ) ;
2097+ }
20852098 }
2099+
20862100 write ( ">" ) ;
20872101 }
20882102
20892103 function emitJsxText ( node : JsxText ) {
20902104 writer . writeLiteral ( getTextOfNode ( node , /*includeTrivia*/ true ) ) ;
20912105 }
20922106
2093- function emitJsxClosingElement ( node : JsxClosingElement ) {
2107+ function emitJsxClosingElementOrFragment ( node : JsxClosingElement | JsxClosingFragment ) {
20942108 write ( "</" ) ;
2095- emitJsxTagName ( node . tagName ) ;
2109+ if ( isJsxClosingElement ( node ) ) {
2110+ emitJsxTagName ( node . tagName ) ;
2111+ }
20962112 write ( ">" ) ;
20972113 }
20982114
@@ -2611,12 +2627,6 @@ namespace ts {
26112627 writer . decreaseIndent ( ) ;
26122628 }
26132629
2614- function writeIfAny ( nodes : NodeArray < Node > , text : string ) {
2615- if ( some ( nodes ) ) {
2616- write ( text ) ;
2617- }
2618- }
2619-
26202630 function writeToken ( token : SyntaxKind , pos : number , contextNode ?: Node ) {
26212631 return onEmitSourceMapOfToken
26222632 ? onEmitSourceMapOfToken ( contextNode , token , pos , writeTokenText )
@@ -3176,7 +3186,7 @@ namespace ts {
31763186 EnumMembers = CommaDelimited | Indented | MultiLine ,
31773187 CaseBlockClauses = Indented | MultiLine ,
31783188 NamedImportsOrExportsElements = CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | SingleLine | SpaceBetweenBraces ,
3179- JsxElementChildren = SingleLine | NoInterveningComments ,
3189+ JsxElementOrFragmentChildren = SingleLine | NoInterveningComments ,
31803190 JsxElementAttributes = SingleLine | SpaceBetweenSiblings | NoInterveningComments ,
31813191 CaseOrDefaultClauseStatements = Indented | MultiLine | NoTrailingNewLine | OptionalIfEmpty ,
31823192 HeritageClauseTypes = CommaDelimited | SpaceBetweenSiblings | SingleLine ,
0 commit comments