@@ -582,13 +582,14 @@ namespace ts.Completions.StringCompletions {
582
582
if ( fragmentDirectory && isEmitModuleResolutionRespectingExportMaps ( compilerOptions ) ) {
583
583
const nodeModulesDirectoryLookup = ancestorLookup ;
584
584
ancestorLookup = ancestor => {
585
- const components = getPathComponents ( fragmentDirectory ) ;
586
- let packagePath = components . pop ( ) ;
585
+ const components = getPathComponents ( fragment ) ;
586
+ components . shift ( ) ; // shift off empty root
587
+ let packagePath = components . shift ( ) ;
587
588
if ( ! packagePath ) {
588
589
return nodeModulesDirectoryLookup ( ancestor ) ;
589
590
}
590
591
if ( startsWith ( packagePath , "@" ) ) {
591
- const subName = components . pop ( ) ;
592
+ const subName = components . shift ( ) ;
592
593
if ( ! subName ) {
593
594
return nodeModulesDirectoryLookup ( ancestor ) ;
594
595
}
@@ -610,7 +611,14 @@ namespace ts.Completions.StringCompletions {
610
611
const subpath = k . substring ( 2 ) ;
611
612
if ( ! startsWith ( subpath , fragmentSubpath ) ) return undefined ;
612
613
// subpath is a valid export (barring conditions, which we don't currently check here)
613
- return subpath ;
614
+ if ( ! stringContains ( subpath , "*" ) ) {
615
+ return subpath ;
616
+ }
617
+ // pattern export - only return everything up to the `*`, so the user can autocomplete, then
618
+ // keep filling in the pattern (we could speculatively return a list of options by hitting disk,
619
+ // but conditions will make that somewhat awkward, as each condition may have a different set of possible
620
+ // options for the `*`.
621
+ return subpath . slice ( 0 , subpath . indexOf ( "*" ) ) ;
614
622
} ) ;
615
623
forEach ( processedKeys , k => {
616
624
result . push ( nameAndKind ( k , ScriptElementKind . externalModuleName , /*extension*/ undefined ) ) ;
0 commit comments