@@ -1718,6 +1718,9 @@ export function transformClassFields(context: TransformationContext): (x: Source
1718
1718
}
1719
1719
else if ( isPrivateIdentifierClassElementDeclaration ( member ) ) {
1720
1720
containsInstancePrivateElements = true ;
1721
+ if ( resolver . getNodeCheckFlags ( member ) & NodeCheckFlags . ContainsConstructorReference ) {
1722
+ facts |= ClassFacts . NeedsClassConstructorReference ;
1723
+ }
1721
1724
}
1722
1725
else if ( isPropertyDeclaration ( member ) ) {
1723
1726
containsPublicInstanceFields = true ;
@@ -1849,6 +1852,7 @@ export function transformClassFields(context: TransformationContext): (x: Source
1849
1852
}
1850
1853
}
1851
1854
1855
+ const isClassWithConstructorReference = resolver . getNodeCheckFlags ( node ) & NodeCheckFlags . ContainsConstructorReference ;
1852
1856
const isExport = hasSyntacticModifier ( node , ModifierFlags . Export ) ;
1853
1857
const isDefault = hasSyntacticModifier ( node , ModifierFlags . Default ) ;
1854
1858
let modifiers = visitNodes ( node . modifiers , modifierVisitor , isModifier ) ;
@@ -1887,6 +1891,12 @@ export function transformClassFields(context: TransformationContext): (x: Source
1887
1891
) ) ;
1888
1892
}
1889
1893
1894
+ const alias = getClassLexicalEnvironment ( ) . classConstructor ;
1895
+ if ( isClassWithConstructorReference && alias ) {
1896
+ enableSubstitutionForClassAliases ( ) ;
1897
+ classAliases [ getOriginalNodeId ( node ) ] = alias ;
1898
+ }
1899
+
1890
1900
const classDecl = factory . updateClassDeclaration (
1891
1901
node ,
1892
1902
modifiers ,
@@ -1918,7 +1928,8 @@ export function transformClassFields(context: TransformationContext): (x: Source
1918
1928
// these statements after the class expression variable statement.
1919
1929
const isDecoratedClassDeclaration = ! ! ( facts & ClassFacts . ClassWasDecorated ) ;
1920
1930
const staticPropertiesOrClassStaticBlocks = getStaticPropertiesAndClassStaticBlock ( node ) ;
1921
- const isClassWithConstructorReference = resolver . getNodeCheckFlags ( node ) & NodeCheckFlags . ClassWithConstructorReference ;
1931
+ const classCheckFlags = resolver . getNodeCheckFlags ( node ) ;
1932
+ const isClassWithConstructorReference = classCheckFlags & NodeCheckFlags . ContainsConstructorReference ;
1922
1933
1923
1934
let temp : Identifier | undefined ;
1924
1935
function createClassTempVar ( ) {
@@ -1935,7 +1946,6 @@ export function transformClassFields(context: TransformationContext): (x: Source
1935
1946
return getClassLexicalEnvironment ( ) . classConstructor = node . emitNode . classThis ;
1936
1947
}
1937
1948
1938
- const classCheckFlags = resolver . getNodeCheckFlags ( node ) ;
1939
1949
const requiresBlockScopedVar = classCheckFlags & NodeCheckFlags . BlockScopedBindingInLoop ;
1940
1950
const temp = factory . createTempVariable ( requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration , /*reservedInNestedScopes*/ true ) ;
1941
1951
getClassLexicalEnvironment ( ) . classConstructor = factory . cloneNode ( temp ) ;
@@ -3236,7 +3246,7 @@ export function transformClassFields(context: TransformationContext): (x: Source
3236
3246
3237
3247
function trySubstituteClassAlias ( node : Identifier ) : Expression | undefined {
3238
3248
if ( enabledSubstitutions & ClassPropertySubstitutionFlags . ClassAliases ) {
3239
- if ( resolver . getNodeCheckFlags ( node ) & NodeCheckFlags . ConstructorReferenceInClass ) {
3249
+ if ( resolver . getNodeCheckFlags ( node ) & NodeCheckFlags . ConstructorReference ) {
3240
3250
// Due to the emit for class decorators, any reference to the class from inside of the class body
3241
3251
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
3242
3252
// behavior of class names in ES6.
0 commit comments