@@ -423,39 +423,11 @@ import {
423
423
WriteFileCallbackData ,
424
424
YieldExpression ,
425
425
} from "./_namespaces/ts.js" ;
426
- import {
427
- isTypeReferenceNode ,
428
- TypeChecker ,
429
- TypeFlags ,
430
- } from "./_namespaces/ts.js" ;
431
426
import * as performance from "./_namespaces/ts.performance.js" ;
427
+
432
428
const brackets = createBracketsMap ( ) ;
433
429
434
430
/** @internal */
435
- export function isUniqueSymbolDeclaration ( node : VariableDeclarationList , checker : TypeChecker ) : boolean {
436
- return node . declarations . some ( ( decl : VariableDeclaration ) => {
437
- // 1. If type is explicitly written, handle as before
438
- const typeNode : TypeNode | undefined = decl . type ;
439
- if ( typeNode ) {
440
- if ( isTypeReferenceNode ( typeNode ) && isIdentifier ( typeNode . typeName ) ) {
441
- if ( typeNode . typeName . escapedText . toString ( ) === "unique symbol" ) {
442
- return true ;
443
- }
444
- }
445
- if ( ( typeNode . kind as SyntaxKind ) === SyntaxKind . UniqueKeyword ) {
446
- return true ;
447
- }
448
- }
449
- // 2. Otherwise, check the inferred type
450
- const type = checker . getTypeAtLocation ( decl . name ) ;
451
- if ( type . flags & TypeFlags . UniqueESSymbol ) {
452
- return true ;
453
- }
454
-
455
- return false ;
456
- } ) ;
457
- }
458
-
459
431
export function isBuildInfoFile ( file : string ) : boolean {
460
432
return fileExtensionIs ( file , Extension . TsBuildInfo ) ;
461
433
}
@@ -769,7 +741,6 @@ export function emitFiles(
769
741
onlyBuildInfo : boolean ,
770
742
forceDtsEmit ?: boolean ,
771
743
skipBuildInfo ?: boolean ,
772
- emitTypeChecker ?: TypeChecker ,
773
744
) : EmitResult {
774
745
// Why var? It avoids TDZ checks in the runtime which can be costly.
775
746
// See: https://github.com/microsoft/TypeScript/issues/52924
@@ -870,7 +841,7 @@ export function emitFiles(
870
841
extendedDiagnostics : compilerOptions . extendedDiagnostics ,
871
842
} ;
872
843
873
- const typeChecker = emitTypeChecker ;
844
+ // Create a printer to print the nodes
874
845
const printer = createPrinter ( printerOptions , {
875
846
// resolver hooks
876
847
hasGlobalName : resolver . hasGlobalName ,
@@ -879,11 +850,12 @@ export function emitFiles(
879
850
onEmitNode : transform . emitNodeWithNotification ,
880
851
isEmitNotificationEnabled : transform . isEmitNotificationEnabled ,
881
852
substituteNode : transform . substituteNode ,
882
- } , typeChecker ) ;
853
+ } ) ;
883
854
884
855
Debug . assert ( transform . transformed . length === 1 , "Should only see one output from the transform" ) ;
885
856
printSourceFileOrBundle ( jsFilePath , sourceMapFilePath , transform , printer , compilerOptions ) ;
886
857
858
+ // Clean up emit nodes on parse tree
887
859
transform . dispose ( ) ;
888
860
889
861
if ( emittedFilesList ) {
@@ -928,8 +900,6 @@ export function emitFiles(
928
900
}
929
901
}
930
902
931
- // TypeChecker is already captured in the closure above
932
-
933
903
const declBlocked = ( ! ! declarationTransform . diagnostics && ! ! declarationTransform . diagnostics . length ) || ! ! host . isEmitBlocked ( declarationFilePath ) || ! ! compilerOptions . noEmit ;
934
904
emitSkipped = emitSkipped || declBlocked ;
935
905
if ( ! declBlocked || forceDtsEmit ) {
@@ -1221,7 +1191,7 @@ export const createPrinterWithRemoveCommentsNeverAsciiEscape: () => Printer = /*
1221
1191
/** @internal */
1222
1192
export const createPrinterWithRemoveCommentsOmitTrailingSemicolon : ( ) => Printer = /* @__PURE__ */ memoize ( ( ) => createPrinter ( { removeComments : true , omitTrailingSemicolon : true } ) ) ;
1223
1193
1224
- export function createPrinter ( printerOptions : PrinterOptions = { } , handlers : PrintHandlers = { } , typeChecker ?: TypeChecker ) : Printer {
1194
+ export function createPrinter ( printerOptions : PrinterOptions = { } , handlers : PrintHandlers = { } ) : Printer {
1225
1195
// Why var? It avoids TDZ checks in the runtime which can be costly.
1226
1196
// See: https://github.com/microsoft/TypeScript/issues/52924
1227
1197
/* eslint-disable no-var */
@@ -3373,6 +3343,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
3373
3343
writeSpace ( ) ;
3374
3344
emit ( node . caseBlock ) ;
3375
3345
}
3346
+
3376
3347
function emitLabeledStatement ( node : LabeledStatement ) {
3377
3348
emit ( node . label ) ;
3378
3349
emitTokenWithComment ( SyntaxKind . ColonToken , node . label . end , writePunctuation , node ) ;
@@ -3425,17 +3396,12 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
3425
3396
writeKeyword ( "using" ) ;
3426
3397
}
3427
3398
else {
3428
- // Check if unique symbol and use const instead of var
3429
- const isUnique = typeChecker && isUniqueSymbolDeclaration ( node , typeChecker ) ;
3430
3399
const head = isLet ( node ) ? "let" :
3431
3400
isVarConst ( node ) ? "const" :
3432
3401
isVarUsing ( node ) ? "using" :
3433
- isUnique ? "const" :
3434
3402
"var" ;
3435
-
3436
3403
writeKeyword ( head ) ;
3437
3404
}
3438
-
3439
3405
writeSpace ( ) ;
3440
3406
emitList ( node , node . declarations , ListFormat . VariableDeclarationList ) ;
3441
3407
}
0 commit comments