@@ -1950,7 +1950,7 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
1950
1950
? < Declaration > node . parent
1951
1951
: resolver . getReferencedValueDeclaration ( < Identifier > node ) ;
1952
1952
1953
- return isSourceFileLevelDeclarationInSystemExternalModule ( targetDeclaration , /*isExported*/ true ) ;
1953
+ return isSourceFileLevelDeclarationInSystemJsModule ( targetDeclaration , /*isExported*/ true ) ;
1954
1954
}
1955
1955
1956
1956
function emitPrefixUnaryExpression ( node : PrefixUnaryExpression ) {
@@ -2021,6 +2021,10 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
2021
2021
}
2022
2022
}
2023
2023
2024
+ function shouldHoistDeclarationInSystemJsModule ( node : Node ) : boolean {
2025
+ return isSourceFileLevelDeclarationInSystemJsModule ( node , /*isExported*/ false ) ;
2026
+ }
2027
+
2024
2028
/*
2025
2029
* Checks if given node is a source file level declaration (not nested in module/function).
2026
2030
* If 'isExported' is true - then declaration must also be exported.
@@ -2031,7 +2035,7 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
2031
2035
* i.e non-exported variable statement 'var x = 1' is hoisted so
2032
2036
* we we emit variable statement 'var' should be dropped.
2033
2037
*/
2034
- function isSourceFileLevelDeclarationInSystemExternalModule ( node : Node , isExported : boolean ) : boolean {
2038
+ function isSourceFileLevelDeclarationInSystemJsModule ( node : Node , isExported : boolean ) : boolean {
2035
2039
if ( ! node || languageVersion >= ScriptTarget . ES6 || ! isCurrentFileSystemExternalModule ( ) ) {
2036
2040
return false ;
2037
2041
}
@@ -2682,7 +2686,7 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
2682
2686
let canDefineTempVariablesInPlace = false ;
2683
2687
if ( root . kind === SyntaxKind . VariableDeclaration ) {
2684
2688
let isExported = getCombinedNodeFlags ( root ) & NodeFlags . Export ;
2685
- let isSourceLevelForSystemModuleKind = isSourceFileLevelDeclarationInSystemExternalModule ( root , /*isExported*/ false ) ;
2689
+ let isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule ( root ) ;
2686
2690
canDefineTempVariablesInPlace = ! isExported && ! isSourceLevelForSystemModuleKind ;
2687
2691
}
2688
2692
else if ( root . kind === SyntaxKind . Parameter ) {
@@ -3938,7 +3942,7 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
3938
3942
function emitClassLikeDeclarationBelowES6 ( node : ClassLikeDeclaration ) {
3939
3943
if ( node . kind === SyntaxKind . ClassDeclaration ) {
3940
3944
// source file level classes in system modules are hoisted so 'var's for them are already defined
3941
- if ( ! isSourceFileLevelDeclarationInSystemExternalModule ( node , /*isExported*/ false ) ) {
3945
+ if ( ! shouldHoistDeclarationInSystemJsModule ( node ) ) {
3942
3946
write ( "var " ) ;
3943
3947
}
3944
3948
emitDeclarationName ( node ) ;
@@ -4450,7 +4454,7 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
4450
4454
if ( ! shouldEmit ) {
4451
4455
return emitOnlyPinnedOrTripleSlashComments ( node ) ;
4452
4456
}
4453
- let hoistedInDeclarationScope = isSourceFileLevelDeclarationInSystemExternalModule ( node , /*isExported*/ false ) ;
4457
+ let hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule ( node ) ;
4454
4458
let emitVarForModule = ! hoistedInDeclarationScope && ! isModuleMergedWithES6Class ( node ) ;
4455
4459
4456
4460
if ( emitVarForModule ) {
@@ -5034,7 +5038,7 @@ if (typeof __param !== "function") __param = function (paramIndex, decorator) {
5034
5038
}
5035
5039
5036
5040
function shouldHoistVariable ( node : VariableDeclaration | VariableDeclarationList | BindingElement , checkIfSourceFileLevelDecl : boolean ) : boolean {
5037
- if ( checkIfSourceFileLevelDecl && ! isSourceFileLevelDeclarationInSystemExternalModule ( node , /*isExported*/ false ) ) {
5041
+ if ( checkIfSourceFileLevelDecl && ! shouldHoistDeclarationInSystemJsModule ( node ) ) {
5038
5042
return false ;
5039
5043
}
5040
5044
// hoist variable if
0 commit comments