File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -802,21 +802,22 @@ namespace ts.codefix {
802802 }
803803
804804 export function moduleSymbolToValidIdentifier ( moduleSymbol : Symbol , target : ScriptTarget ) : string {
805- return moduleSpecifierToValidIdentifier ( removeFileExtension ( getBaseFileName ( moduleSymbol . name ) ) , target ) ;
805+ return moduleSpecifierToValidIdentifier ( removeFileExtension ( stripQuotes ( moduleSymbol . name ) ) , target ) ;
806806 }
807807
808808 export function moduleSpecifierToValidIdentifier ( moduleSpecifier : string , target : ScriptTarget ) : string {
809+ const baseName = getBaseFileName ( removeSuffix ( moduleSpecifier , "/index" ) ) ;
809810 let res = "" ;
810811 let lastCharWasValid = true ;
811- const firstCharCode = moduleSpecifier . charCodeAt ( 0 ) ;
812+ const firstCharCode = baseName . charCodeAt ( 0 ) ;
812813 if ( isIdentifierStart ( firstCharCode , target ) ) {
813814 res += String . fromCharCode ( firstCharCode ) ;
814815 }
815816 else {
816817 lastCharWasValid = false ;
817818 }
818- for ( let i = 1 ; i < moduleSpecifier . length ; i ++ ) {
819- const ch = moduleSpecifier . charCodeAt ( i ) ;
819+ for ( let i = 1 ; i < baseName . length ; i ++ ) {
820+ const ch = baseName . charCodeAt ( i ) ;
820821 const isValid = isIdentifierPart ( ch , target ) ;
821822 if ( isValid ) {
822823 let char = String . fromCharCode ( ch ) ;
Original file line number Diff line number Diff line change 1+ /// <reference path="fourslash.ts" />
2+
3+ // @Filename : /foo-bar/index.ts
4+ ////export default 0;
5+
6+ // @Filename : /b.ts
7+ ////[|foo/**/Bar|]
8+
9+ goTo . file ( "/b.ts" ) ;
10+ verify . importFixAtPosition ( [ `import fooBar from "./foo-bar";
11+
12+ fooBar` ] ) ;
You can’t perform that action at this time.
0 commit comments