@@ -423,39 +423,11 @@ import {
423423 WriteFileCallbackData ,
424424 YieldExpression ,
425425} from "./_namespaces/ts.js" ;
426- import {
427- isTypeReferenceNode ,
428- TypeChecker ,
429- TypeFlags ,
430- } from "./_namespaces/ts.js" ;
431426import * as performance from "./_namespaces/ts.performance.js" ;
427+
432428const brackets = createBracketsMap ( ) ;
433429
434430/** @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-
459431export function isBuildInfoFile ( file : string ) : boolean {
460432 return fileExtensionIs ( file , Extension . TsBuildInfo ) ;
461433}
@@ -769,7 +741,6 @@ export function emitFiles(
769741 onlyBuildInfo : boolean ,
770742 forceDtsEmit ?: boolean ,
771743 skipBuildInfo ?: boolean ,
772- emitTypeChecker ?: TypeChecker ,
773744) : EmitResult {
774745 // Why var? It avoids TDZ checks in the runtime which can be costly.
775746 // See: https://github.com/microsoft/TypeScript/issues/52924
@@ -870,7 +841,7 @@ export function emitFiles(
870841 extendedDiagnostics : compilerOptions . extendedDiagnostics ,
871842 } ;
872843
873- const typeChecker = emitTypeChecker ;
844+ // Create a printer to print the nodes
874845 const printer = createPrinter ( printerOptions , {
875846 // resolver hooks
876847 hasGlobalName : resolver . hasGlobalName ,
@@ -879,11 +850,12 @@ export function emitFiles(
879850 onEmitNode : transform . emitNodeWithNotification ,
880851 isEmitNotificationEnabled : transform . isEmitNotificationEnabled ,
881852 substituteNode : transform . substituteNode ,
882- } , typeChecker ) ;
853+ } ) ;
883854
884855 Debug . assert ( transform . transformed . length === 1 , "Should only see one output from the transform" ) ;
885856 printSourceFileOrBundle ( jsFilePath , sourceMapFilePath , transform , printer , compilerOptions ) ;
886857
858+ // Clean up emit nodes on parse tree
887859 transform . dispose ( ) ;
888860
889861 if ( emittedFilesList ) {
@@ -928,8 +900,6 @@ export function emitFiles(
928900 }
929901 }
930902
931- // TypeChecker is already captured in the closure above
932-
933903 const declBlocked = ( ! ! declarationTransform . diagnostics && ! ! declarationTransform . diagnostics . length ) || ! ! host . isEmitBlocked ( declarationFilePath ) || ! ! compilerOptions . noEmit ;
934904 emitSkipped = emitSkipped || declBlocked ;
935905 if ( ! declBlocked || forceDtsEmit ) {
@@ -1221,7 +1191,7 @@ export const createPrinterWithRemoveCommentsNeverAsciiEscape: () => Printer = /*
12211191/** @internal */
12221192export const createPrinterWithRemoveCommentsOmitTrailingSemicolon : ( ) => Printer = /* @__PURE__ */ memoize ( ( ) => createPrinter ( { removeComments : true , omitTrailingSemicolon : true } ) ) ;
12231193
1224- export function createPrinter ( printerOptions : PrinterOptions = { } , handlers : PrintHandlers = { } , typeChecker ?: TypeChecker ) : Printer {
1194+ export function createPrinter ( printerOptions : PrinterOptions = { } , handlers : PrintHandlers = { } ) : Printer {
12251195 // Why var? It avoids TDZ checks in the runtime which can be costly.
12261196 // See: https://github.com/microsoft/TypeScript/issues/52924
12271197 /* eslint-disable no-var */
@@ -3373,6 +3343,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
33733343 writeSpace ( ) ;
33743344 emit ( node . caseBlock ) ;
33753345 }
3346+
33763347 function emitLabeledStatement ( node : LabeledStatement ) {
33773348 emit ( node . label ) ;
33783349 emitTokenWithComment ( SyntaxKind . ColonToken , node . label . end , writePunctuation , node ) ;
@@ -3425,17 +3396,12 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
34253396 writeKeyword ( "using" ) ;
34263397 }
34273398 else {
3428- // Check if unique symbol and use const instead of var
3429- const isUnique = typeChecker && isUniqueSymbolDeclaration ( node , typeChecker ) ;
34303399 const head = isLet ( node ) ? "let" :
34313400 isVarConst ( node ) ? "const" :
34323401 isVarUsing ( node ) ? "using" :
3433- isUnique ? "const" :
34343402 "var" ;
3435-
34363403 writeKeyword ( head ) ;
34373404 }
3438-
34393405 writeSpace ( ) ;
34403406 emitList ( node , node . declarations , ListFormat . VariableDeclarationList ) ;
34413407 }
0 commit comments