@@ -210,23 +210,23 @@ export class ImportManager {
210
210
// If no symbol name has been specified, the default import is requested. In that
211
211
// case we search for non-namespace and non-specifier imports.
212
212
if ( ! symbolName && ! importData . namespace && ! importData . specifiers ) {
213
- return ts . createIdentifier ( importData . name ! . text ) ;
213
+ return ts . factory . createIdentifier ( importData . name ! . text ) ;
214
214
}
215
215
216
216
// In case a "Type" symbol is imported, we can't use namespace imports
217
217
// because these only export symbols available at runtime (no types)
218
218
if ( importData . namespace && ! typeImport ) {
219
- return ts . createPropertyAccess (
220
- ts . createIdentifier ( importData . name ! . text ) ,
221
- ts . createIdentifier ( symbolName || 'default' ) ,
219
+ return ts . factory . createPropertyAccessExpression (
220
+ ts . factory . createIdentifier ( importData . name ! . text ) ,
221
+ ts . factory . createIdentifier ( symbolName || 'default' ) ,
222
222
) ;
223
223
} else if ( importData . specifiers && symbolName ) {
224
224
const existingSpecifier = importData . specifiers . find ( s =>
225
225
s . propertyName ? s . propertyName . text === symbolName : s . name . text === symbolName ,
226
226
) ;
227
227
228
228
if ( existingSpecifier ) {
229
- return ts . createIdentifier ( existingSpecifier . name . text ) ;
229
+ return ts . factory . createIdentifier ( existingSpecifier . name . text ) ;
230
230
}
231
231
232
232
// In case the symbol could not be found in an existing import, we
@@ -239,7 +239,7 @@ export class ImportManager {
239
239
// If there is an existing import that matches the specified module, we
240
240
// just update the import specifiers to also import the requested symbol.
241
241
if ( existingImport ) {
242
- const propertyIdentifier = ts . createIdentifier ( symbolName ! ) ;
242
+ const propertyIdentifier = ts . factory . createIdentifier ( symbolName ! ) ;
243
243
const generatedUniqueIdentifier = this . _getUniqueIdentifier (
244
244
sourceFile ,
245
245
symbolName ! ,
@@ -267,7 +267,7 @@ export class ImportManager {
267
267
let newImport : AnalyzedImport | null = null ;
268
268
269
269
if ( symbolName ) {
270
- const propertyIdentifier = ts . createIdentifier ( symbolName ) ;
270
+ const propertyIdentifier = ts . factory . createIdentifier ( symbolName ) ;
271
271
const generatedUniqueIdentifier = this . _getUniqueIdentifier (
272
272
sourceFile ,
273
273
symbolName ,
@@ -276,11 +276,11 @@ export class ImportManager {
276
276
const needsGeneratedUniqueName = generatedUniqueIdentifier . text !== symbolName ;
277
277
identifier = needsGeneratedUniqueName ? generatedUniqueIdentifier : propertyIdentifier ;
278
278
279
- const newImportDecl = ts . createImportDeclaration (
279
+ const newImportDecl = ts . factory . createImportDeclaration (
280
280
undefined ,
281
281
undefined ,
282
- ts . createImportClause ( undefined , ts . createNamedImports ( [ ] ) ) ,
283
- ts . createStringLiteral ( moduleName ) ,
282
+ ts . factory . createImportClause ( false , undefined , ts . factory . createNamedImports ( [ ] ) ) ,
283
+ ts . factory . createStringLiteral ( moduleName ) ,
284
284
) ;
285
285
286
286
newImport = {
@@ -300,11 +300,11 @@ export class ImportManager {
300
300
'defaultExport' ,
301
301
ignoreIdentifierCollisions ,
302
302
) ;
303
- const newImportDecl = ts . createImportDeclaration (
303
+ const newImportDecl = ts . factory . createImportDeclaration (
304
304
undefined ,
305
305
undefined ,
306
- ts . createImportClause ( identifier , undefined ) ,
307
- ts . createStringLiteral ( moduleName ) ,
306
+ ts . factory . createImportClause ( false , identifier , undefined ) ,
307
+ ts . factory . createStringLiteral ( moduleName ) ,
308
308
) ;
309
309
newImport = {
310
310
moduleName,
@@ -351,19 +351,19 @@ export class ImportManager {
351
351
const importSpecifiers = importData . specifiers . map ( s =>
352
352
createImportSpecifier ( s . propertyName , s . name ) ,
353
353
) ;
354
- const updatedBindings = ts . updateNamedImports ( namedBindings , importSpecifiers ) ;
354
+ const updatedBindings = ts . factory . updateNamedImports ( namedBindings , importSpecifiers ) ;
355
355
356
356
// In case an import has been added newly, we need to print the whole import
357
357
// declaration and insert it at the import start index. Otherwise, we just
358
358
// update the named bindings to not re-print the whole import (which could
359
359
// cause unnecessary formatting changes)
360
360
if ( hasFlag ( importData , ImportState . ADDED ) ) {
361
- const updatedImport = ts . updateImportDeclaration (
361
+ const updatedImport = ts . factory . updateImportDeclaration (
362
362
importData . node ,
363
363
undefined ,
364
364
undefined ,
365
- ts . createImportClause ( undefined , updatedBindings ) ,
366
- ts . createStringLiteral ( importData . moduleName ) ,
365
+ ts . factory . createImportClause ( false , undefined , updatedBindings ) ,
366
+ ts . factory . createStringLiteral ( importData . moduleName ) ,
367
367
undefined ,
368
368
) ;
369
369
const newImportText = this . _printer . printNode (
@@ -452,7 +452,7 @@ export class ImportManager {
452
452
) : ts . Identifier {
453
453
if ( this . _isUniqueIdentifierName ( sourceFile , symbolName , ignoreIdentifierCollisions ) ) {
454
454
this . _recordUsedIdentifier ( sourceFile , symbolName ) ;
455
- return ts . createIdentifier ( symbolName ) ;
455
+ return ts . factory . createIdentifier ( symbolName ) ;
456
456
}
457
457
458
458
let name : string | null = null ;
@@ -462,7 +462,7 @@ export class ImportManager {
462
462
} while ( ! this . _isUniqueIdentifierName ( sourceFile , name , ignoreIdentifierCollisions ) ) ;
463
463
464
464
this . _recordUsedIdentifier ( sourceFile , name ! ) ;
465
- return ts . createIdentifier ( name ! ) ;
465
+ return ts . factory . createIdentifier ( name ! ) ;
466
466
}
467
467
468
468
/**
@@ -535,6 +535,6 @@ function createImportSpecifier(
535
535
name : ts . Identifier ,
536
536
) : ts . ImportSpecifier {
537
537
return PARSED_TS_VERSION > 4.4
538
- ? ts . createImportSpecifier ( false , propertyName , name )
538
+ ? ts . factory . createImportSpecifier ( false , propertyName , name )
539
539
: ( ts . createImportSpecifier as any ) ( propertyName , name ) ;
540
540
}
0 commit comments