@@ -19,10 +19,11 @@ namespace ts {
1919 }
2020
2121 const enum ClassFacts {
22+ None = 0 ,
2223 HasStaticInitializedProperties = 1 << 0 ,
2324 HasConstructorDecorators = 1 << 1 ,
2425 HasMemberDecorators = 1 << 2 ,
25- IsNamespaceExport = 1 << 3 ,
26+ IsExportOfNamespace = 1 << 3 ,
2627 IsNamedExternalExport = 1 << 4 ,
2728 IsDefaultExternalExport = 1 << 5 ,
2829 HasExtendsClause = 1 << 6 ,
@@ -31,7 +32,7 @@ namespace ts {
3132 HasAnyDecorators = HasConstructorDecorators | HasMemberDecorators ,
3233 NeedsName = HasStaticInitializedProperties | HasMemberDecorators ,
3334 MayNeedImmediatelyInvokedFunctionExpression = HasAnyDecorators | HasStaticInitializedProperties ,
34- IsExported = IsNamespaceExport | IsDefaultExternalExport | IsNamedExternalExport ,
35+ IsExported = IsExportOfNamespace | IsDefaultExternalExport | IsNamedExternalExport ,
3536 }
3637
3738 export function transformTypeScript ( context : TransformationContext ) {
@@ -519,14 +520,14 @@ namespace ts {
519520 }
520521
521522 function getClassFacts ( node : ClassDeclaration , staticProperties : PropertyDeclaration [ ] ) {
522- let facts : ClassFacts = 0 ;
523+ let facts = ClassFacts . None ;
523524 if ( some ( staticProperties ) ) facts |= ClassFacts . HasStaticInitializedProperties ;
524525 if ( getClassExtendsHeritageClauseElement ( node ) ) facts |= ClassFacts . HasExtendsClause ;
525526 if ( shouldEmitDecorateCallForClass ( node ) ) facts |= ClassFacts . HasConstructorDecorators ;
526527 if ( childIsDecorated ( node ) ) facts |= ClassFacts . HasMemberDecorators ;
527- if ( isNamespaceExport ( node ) ) facts |= ClassFacts . IsNamespaceExport ;
528- if ( ( facts & ClassFacts . IsExported ) === 0 && isDefaultExternalModuleExport ( node ) ) facts |= ClassFacts . IsDefaultExternalExport ;
529- if ( ( facts & ClassFacts . IsExported ) === 0 && isNamedExternalModuleExport ( node ) ) facts |= ClassFacts . IsNamedExternalExport ;
528+ if ( isExportOfNamespace ( node ) ) facts |= ClassFacts . IsExportOfNamespace ;
529+ else if ( isDefaultExternalModuleExport ( node ) ) facts |= ClassFacts . IsDefaultExternalExport ;
530+ else if ( isNamedExternalModuleExport ( node ) ) facts |= ClassFacts . IsNamedExternalExport ;
530531 if ( languageVersion <= ScriptTarget . ES5 && ( facts & ClassFacts . MayNeedImmediatelyInvokedFunctionExpression ) ) facts |= ClassFacts . UseImmediatelyInvokedFunctionExpression ;
531532 return facts ;
532533 }
@@ -609,7 +610,7 @@ namespace ts {
609610 // If the class is exported as part of a TypeScript namespace, emit the namespace export.
610611 // Otherwise, if the class was exported at the top level and was decorated, emit an export
611612 // declaration or export default for the class.
612- if ( facts & ClassFacts . IsNamespaceExport ) {
613+ if ( facts & ClassFacts . IsExportOfNamespace ) {
613614 addExportMemberAssignment ( statements , node ) ;
614615 }
615616 else if ( facts & ClassFacts . UseImmediatelyInvokedFunctionExpression || facts & ClassFacts . HasConstructorDecorators ) {
@@ -672,11 +673,6 @@ namespace ts {
672673 /**
673674 * Transforms a decorated class declaration and appends the resulting statements. If
674675 * the class requires an alias to avoid issues with double-binding, the alias is returned.
675- *
676- * @param statements A statement list to which to add the declaration.
677- * @param node A ClassDeclaration node.
678- * @param name The name of the class.
679- * @param facts Precomputed facts about the clas.
680676 */
681677 function createClassDeclarationHeadWithDecorators ( node : ClassDeclaration , name : Identifier , facts : ClassFacts ) {
682678 // When we emit an ES6 class that has a class decorator, we must tailor the
@@ -2223,7 +2219,7 @@ namespace ts {
22232219 /*type*/ undefined ,
22242220 visitFunctionBody ( node . body , visitor , context ) || createBlock ( [ ] )
22252221 ) ;
2226- if ( isNamespaceExport ( node ) ) {
2222+ if ( isExportOfNamespace ( node ) ) {
22272223 const statements : Statement [ ] = [ updated ] ;
22282224 addExportMemberAssignment ( statements , node ) ;
22292225 return statements ;
@@ -2316,7 +2312,7 @@ namespace ts {
23162312 * - The node is exported from a TypeScript namespace.
23172313 */
23182314 function visitVariableStatement ( node : VariableStatement ) : Statement {
2319- if ( isNamespaceExport ( node ) ) {
2315+ if ( isExportOfNamespace ( node ) ) {
23202316 const variables = getInitializedVariables ( node . declarationList ) ;
23212317 if ( variables . length === 0 ) {
23222318 // elide statement if there are no initialized variables.
@@ -2620,7 +2616,7 @@ namespace ts {
26202616 * or `exports.x`).
26212617 */
26222618 function hasNamespaceQualifiedExportName ( node : Node ) {
2623- return isNamespaceExport ( node )
2619+ return isExportOfNamespace ( node )
26242620 || ( isExternalModuleExport ( node )
26252621 && moduleKind !== ModuleKind . ES2015
26262622 && moduleKind !== ModuleKind . System ) ;
@@ -3062,7 +3058,7 @@ namespace ts {
30623058 const moduleReference = createExpressionFromEntityName ( < EntityName > node . moduleReference ) ;
30633059 setEmitFlags ( moduleReference , EmitFlags . NoComments | EmitFlags . NoNestedComments ) ;
30643060
3065- if ( isNamedExternalModuleExport ( node ) || ! isNamespaceExport ( node ) ) {
3061+ if ( isNamedExternalModuleExport ( node ) || ! isExportOfNamespace ( node ) ) {
30663062 // export var ${name} = ${moduleReference};
30673063 // var ${name} = ${moduleReference};
30683064 return setOriginalNode (
@@ -3103,7 +3099,7 @@ namespace ts {
31033099 *
31043100 * @param node The node to test.
31053101 */
3106- function isNamespaceExport ( node : Node ) {
3102+ function isExportOfNamespace ( node : Node ) {
31073103 return currentNamespace !== undefined && hasModifier ( node , ModifierFlags . Export ) ;
31083104 }
31093105
0 commit comments