@@ -381,38 +381,45 @@ namespace ts {
381
381
host . log ?.( "getExportInfoMap: cache miss or empty; calculating new results" ) ;
382
382
const compilerOptions = program . getCompilerOptions ( ) ;
383
383
let moduleCount = 0 ;
384
- forEachExternalModuleToImportFrom ( program , host , /*useAutoImportProvider*/ true , ( moduleSymbol , moduleFile , program , isFromPackageJson ) => {
385
- if ( ++ moduleCount % 100 === 0 ) cancellationToken ?. throwIfCancellationRequested ( ) ;
386
- const seenExports = new Map < __String , true > ( ) ;
387
- const checker = program . getTypeChecker ( ) ;
388
- const defaultInfo = getDefaultLikeExportInfo ( moduleSymbol , checker , compilerOptions ) ;
389
- // Note: I think we shouldn't actually see resolved module symbols here, but weird merges
390
- // can cause it to happen: see 'completionsImport_mergedReExport.ts'
391
- if ( defaultInfo && isImportableSymbol ( defaultInfo . symbol , checker ) ) {
392
- cache . add (
393
- importingFile . path ,
394
- defaultInfo . symbol ,
395
- defaultInfo . exportKind === ExportKind . Default ? InternalSymbolName . Default : InternalSymbolName . ExportEquals ,
396
- moduleSymbol ,
397
- moduleFile ,
398
- defaultInfo . exportKind ,
399
- isFromPackageJson ,
400
- checker ) ;
401
- }
402
- checker . forEachExportAndPropertyOfModule ( moduleSymbol , ( exported , key ) => {
403
- if ( exported !== defaultInfo ?. symbol && isImportableSymbol ( exported , checker ) && addToSeen ( seenExports , key ) ) {
384
+ try {
385
+ forEachExternalModuleToImportFrom ( program , host , /*useAutoImportProvider*/ true , ( moduleSymbol , moduleFile , program , isFromPackageJson ) => {
386
+ if ( ++ moduleCount % 100 === 0 ) cancellationToken ?. throwIfCancellationRequested ( ) ;
387
+ const seenExports = new Map < __String , true > ( ) ;
388
+ const checker = program . getTypeChecker ( ) ;
389
+ const defaultInfo = getDefaultLikeExportInfo ( moduleSymbol , checker , compilerOptions ) ;
390
+ // Note: I think we shouldn't actually see resolved module symbols here, but weird merges
391
+ // can cause it to happen: see 'completionsImport_mergedReExport.ts'
392
+ if ( defaultInfo && isImportableSymbol ( defaultInfo . symbol , checker ) ) {
404
393
cache . add (
405
394
importingFile . path ,
406
- exported ,
407
- key ,
395
+ defaultInfo . symbol ,
396
+ defaultInfo . exportKind === ExportKind . Default ? InternalSymbolName . Default : InternalSymbolName . ExportEquals ,
408
397
moduleSymbol ,
409
398
moduleFile ,
410
- ExportKind . Named ,
399
+ defaultInfo . exportKind ,
411
400
isFromPackageJson ,
412
401
checker ) ;
413
402
}
403
+ checker . forEachExportAndPropertyOfModule ( moduleSymbol , ( exported , key ) => {
404
+ if ( exported !== defaultInfo ?. symbol && isImportableSymbol ( exported , checker ) && addToSeen ( seenExports , key ) ) {
405
+ cache . add (
406
+ importingFile . path ,
407
+ exported ,
408
+ key ,
409
+ moduleSymbol ,
410
+ moduleFile ,
411
+ ExportKind . Named ,
412
+ isFromPackageJson ,
413
+ checker ) ;
414
+ }
415
+ } ) ;
414
416
} ) ;
415
- } ) ;
417
+ }
418
+ catch ( err ) {
419
+ // Ensure cache is reset if operation is cancelled
420
+ cache . clear ( ) ;
421
+ throw err ;
422
+ }
416
423
417
424
host . log ?.( `getExportInfoMap: done in ${ timestamp ( ) - start } ms` ) ;
418
425
return cache ;
0 commit comments