@@ -1893,7 +1893,23 @@ var __param = this.__param || function(index, decorator) { return function (targ
1893
1893
emit ( node . expression ) ;
1894
1894
}
1895
1895
1896
+ function shouldEmitPublishOfExportedValue ( node : PrefixUnaryExpression | PostfixUnaryExpression ) : boolean {
1897
+ if ( ! currentFileIsEmittedAsSystemModule ( ) || node . operand . kind !== SyntaxKind . Identifier ) {
1898
+ return false ;
1899
+ }
1900
+
1901
+ return isExportedSourceLevelDeclaration ( resolver . getReferencedValueDeclaration ( < Identifier > node . operand ) ) ;
1902
+ }
1903
+
1896
1904
function emitPrefixUnaryExpression ( node : PrefixUnaryExpression ) {
1905
+ const emitPublishOfExportedValue = shouldEmitPublishOfExportedValue ( node ) ;
1906
+
1907
+ if ( emitPublishOfExportedValue ) {
1908
+ write ( `${ exportFunctionForFile } ("` ) ;
1909
+ emitNodeWithoutSourceMap ( node . operand ) ;
1910
+ write ( `", ` ) ;
1911
+ }
1912
+
1897
1913
write ( tokenToString ( node . operator ) ) ;
1898
1914
// In some cases, we need to emit a space between the operator and the operand. One obvious case
1899
1915
// is when the operator is an identifier, like delete or typeof. We also need to do this for plus
@@ -1917,11 +1933,35 @@ var __param = this.__param || function(index, decorator) { return function (targ
1917
1933
}
1918
1934
}
1919
1935
emit ( node . operand ) ;
1936
+
1937
+ if ( emitPublishOfExportedValue ) {
1938
+ write ( ")" ) ;
1939
+ }
1920
1940
}
1921
1941
1922
1942
function emitPostfixUnaryExpression ( node : PostfixUnaryExpression ) {
1943
+ const emitPublishOfExportedValue = shouldEmitPublishOfExportedValue ( node ) ;
1944
+ if ( emitPublishOfExportedValue ) {
1945
+ write ( `${ exportFunctionForFile } ("` ) ;
1946
+ emitNodeWithoutSourceMap ( node . operand ) ;
1947
+ write ( `", ` ) ;
1948
+ }
1949
+
1923
1950
emit ( node . operand ) ;
1924
1951
write ( tokenToString ( node . operator ) ) ;
1952
+
1953
+ if ( emitPublishOfExportedValue ) {
1954
+ write ( "), " ) ;
1955
+ emitNodeWithoutSourceMap ( node . operand ) ;
1956
+ write ( node . operator === SyntaxKind . PlusPlusToken ? " - 1" : " + 1" ) ;
1957
+ }
1958
+ }
1959
+
1960
+ function isExportedSourceLevelDeclaration ( decl : Declaration ) : boolean {
1961
+ if ( ! decl ) {
1962
+ return false ;
1963
+ }
1964
+ return ( getCombinedNodeFlags ( decl ) & NodeFlags . Export ) && isSourceFileLevelDeclaration ( decl ) ;
1925
1965
}
1926
1966
1927
1967
function emitBinaryExpression ( node : BinaryExpression ) {
@@ -1936,11 +1976,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
1936
1976
node . left . kind === SyntaxKind . Identifier &&
1937
1977
node . operatorToken . kind >= SyntaxKind . FirstAssignment &&
1938
1978
node . operatorToken . kind <= SyntaxKind . LastAssignment ) {
1939
-
1940
- let referencedDecl = resolver . getReferencedValueDeclaration ( < Identifier > node . left ) ;
1941
- if ( referencedDecl && ( getCombinedNodeFlags ( referencedDecl ) & NodeFlags . Export ) && isSourceFileLevelDeclaration ( referencedDecl ) ) {
1942
- emitPublishOfExportedValue = true ;
1943
- }
1979
+ emitPublishOfExportedValue = isExportedSourceLevelDeclaration ( resolver . getReferencedValueDeclaration ( < Identifier > node . left ) ) ;
1944
1980
}
1945
1981
1946
1982
if ( emitPublishOfExportedValue ) {
0 commit comments