@@ -65,10 +65,9 @@ namespace ts.codefix {
65
65
function collectExportRenames ( sourceFile : SourceFile , checker : TypeChecker , identifiers : Identifiers ) : ExportRenames {
66
66
const res = createMap < string > ( ) ;
67
67
forEachExportReference ( sourceFile , node => {
68
- const name = node . name as Identifier ;
69
- const { text, originalKeywordKind } = name ;
68
+ const { text, originalKeywordKind } = node . name ;
70
69
if ( ! res . has ( text ) && ( originalKeywordKind !== undefined && isNonContextualKeyword ( originalKeywordKind )
71
- || checker . resolveName ( name . text , node , SymbolFlags . Value , /*excludeGlobals*/ true ) ) ) {
70
+ || checker . resolveName ( node . name . text , node , SymbolFlags . Value , /*excludeGlobals*/ true ) ) ) {
72
71
// Unconditionally add an underscore in case `text` is a keyword.
73
72
res . set ( text , makeUniqueName ( `_${ text } ` , identifiers ) ) ;
74
73
}
@@ -81,7 +80,7 @@ namespace ts.codefix {
81
80
if ( isAssignmentLhs ) {
82
81
return ;
83
82
}
84
- const { text } = node . name as Identifier ;
83
+ const { text } = node . name ;
85
84
changes . replaceNode ( sourceFile , node , createIdentifier ( exports . get ( text ) || text ) ) ;
86
85
} ) ;
87
86
}
@@ -151,7 +150,7 @@ namespace ts.codefix {
151
150
}
152
151
else if ( isPropertyAccessExpression ( initializer ) && isRequireCall ( initializer . expression , /*checkArgumentIsStringLiteralLike*/ true ) ) {
153
152
foundImport = true ;
154
- return convertPropertyAccessImport ( name , ( initializer . name as Identifier ) . text , initializer . expression . arguments [ 0 ] , identifiers , quotePreference ) ;
153
+ return convertPropertyAccessImport ( name , initializer . name . text , initializer . expression . arguments [ 0 ] , identifiers , quotePreference ) ;
155
154
}
156
155
}
157
156
// Move it out to its own variable statement. (This will not be used if `!foundImport`)
@@ -252,7 +251,7 @@ namespace ts.codefix {
252
251
exports : ExportRenames ,
253
252
) : void {
254
253
// If "originalKeywordKind" was set, this is e.g. `exports.
255
- const { text } = assignment . left . name as Identifier ;
254
+ const { text } = assignment . left . name ;
256
255
const rename = exports . get ( text ) ;
257
256
if ( rename !== undefined ) {
258
257
/*
@@ -290,7 +289,7 @@ namespace ts.codefix {
290
289
}
291
290
292
291
function convertExportsPropertyAssignment ( { left, right, parent } : BinaryExpression & { left : PropertyAccessExpression } , sourceFile : SourceFile , changes : textChanges . ChangeTracker ) : void {
293
- const name = ( left . name as Identifier ) . text ;
292
+ const name = left . name . text ;
294
293
if ( ( isFunctionExpression ( right ) || isArrowFunction ( right ) || isClassExpression ( right ) ) && ( ! right . name || right . name . text === name ) ) {
295
294
// `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`.
296
295
changes . replaceRange ( sourceFile , { pos : left . getStart ( sourceFile ) , end : right . getStart ( sourceFile ) } , createToken ( SyntaxKind . ExportKeyword ) , { suffix : " " } ) ;
@@ -399,9 +398,7 @@ namespace ts.codefix {
399
398
400
399
const { parent } = use ;
401
400
if ( isPropertyAccessExpression ( parent ) ) {
402
- const { expression, name } = parent ;
403
- // TODO: PrivateName fix
404
- const { text : propertyName } = name as Identifier ;
401
+ const { expression, name : { text : propertyName } } = parent ;
405
402
Debug . assert ( expression === use ) ; // Else shouldn't have been in `collectIdentifiers`
406
403
let idName = namedBindingsNames . get ( propertyName ) ;
407
404
if ( idName === undefined ) {
0 commit comments