@@ -74,7 +74,7 @@ namespace ts.codefix {
7474 const symbolName = getNameForExportedSymbol ( exportedSymbol , getEmitScriptTarget ( compilerOptions ) ) ;
7575 const checker = program . getTypeChecker ( ) ;
7676 const symbol = checker . getMergedSymbol ( skipAlias ( exportedSymbol , checker ) ) ;
77- const exportInfos = getAllReExportingModules ( sourceFile , symbol , moduleSymbol , symbolName , host , program , preferences , useAutoImportProvider ) ;
77+ const exportInfos = getAllReExportingModules ( sourceFile , symbol , moduleSymbol , symbolName , /*isJsxTagName*/ false , host , program , preferences , useAutoImportProvider ) ;
7878 const useRequire = shouldUseRequire ( sourceFile , program ) ;
7979 const fix = getImportFixForSymbol ( sourceFile , exportInfos , moduleSymbol , symbolName , program , /*position*/ undefined , ! ! isValidTypeOnlyUseSite , useRequire , host , preferences ) ;
8080 if ( fix ) {
@@ -287,6 +287,7 @@ namespace ts.codefix {
287287 moduleSymbol : Symbol ,
288288 sourceFile : SourceFile ,
289289 symbolName : string ,
290+ isJsxTagName : boolean ,
290291 host : LanguageServiceHost ,
291292 program : Program ,
292293 formatContext : formatting . FormatContext ,
@@ -296,7 +297,7 @@ namespace ts.codefix {
296297 const compilerOptions = program . getCompilerOptions ( ) ;
297298 const exportInfos = pathIsBareSpecifier ( stripQuotes ( moduleSymbol . name ) )
298299 ? [ getSymbolExportInfoForSymbol ( targetSymbol , moduleSymbol , program , host ) ]
299- : getAllReExportingModules ( sourceFile , targetSymbol , moduleSymbol , symbolName , host , program , preferences , /*useAutoImportProvider*/ true ) ;
300+ : getAllReExportingModules ( sourceFile , targetSymbol , moduleSymbol , symbolName , isJsxTagName , host , program , preferences , /*useAutoImportProvider*/ true ) ;
300301 const useRequire = shouldUseRequire ( sourceFile , program ) ;
301302 const isValidTypeOnlyUseSite = isValidTypeOnlyAliasUseSite ( getTokenAtPosition ( sourceFile , position ) ) ;
302303 const fix = Debug . checkDefined ( getImportFixForSymbol ( sourceFile , exportInfos , moduleSymbol , symbolName , program , position , isValidTypeOnlyUseSite , useRequire , host , preferences ) ) ;
@@ -349,7 +350,7 @@ namespace ts.codefix {
349350 }
350351 }
351352
352- function getAllReExportingModules ( importingFile : SourceFile , targetSymbol : Symbol , exportingModuleSymbol : Symbol , symbolName : string , host : LanguageServiceHost , program : Program , preferences : UserPreferences , useAutoImportProvider : boolean ) : readonly SymbolExportInfo [ ] {
353+ function getAllReExportingModules ( importingFile : SourceFile , targetSymbol : Symbol , exportingModuleSymbol : Symbol , symbolName : string , isJsxTagName : boolean , host : LanguageServiceHost , program : Program , preferences : UserPreferences , useAutoImportProvider : boolean ) : readonly SymbolExportInfo [ ] {
353354 const result : SymbolExportInfo [ ] = [ ] ;
354355 const compilerOptions = program . getCompilerOptions ( ) ;
355356 const getModuleSpecifierResolutionHost = memoizeOne ( ( isFromPackageJson : boolean ) => {
@@ -364,7 +365,7 @@ namespace ts.codefix {
364365 }
365366
366367 const defaultInfo = getDefaultLikeExportInfo ( moduleSymbol , checker , compilerOptions ) ;
367- if ( defaultInfo && ( defaultInfo . name === symbolName || moduleSymbolToValidIdentifier ( moduleSymbol , getEmitScriptTarget ( compilerOptions ) ) === symbolName ) && skipAlias ( defaultInfo . symbol , checker ) === targetSymbol && isImportable ( program , moduleFile , isFromPackageJson ) ) {
368+ if ( defaultInfo && ( defaultInfo . name === symbolName || moduleSymbolToValidIdentifier ( moduleSymbol , getEmitScriptTarget ( compilerOptions ) , isJsxTagName ) === symbolName ) && skipAlias ( defaultInfo . symbol , checker ) === targetSymbol && isImportable ( program , moduleFile , isFromPackageJson ) ) {
368369 result . push ( { symbol : defaultInfo . symbol , moduleSymbol, moduleFileName : moduleFile ?. fileName , exportKind : defaultInfo . exportKind , targetFlags : skipAlias ( defaultInfo . symbol , checker ) . flags , isFromPackageJson } ) ;
369370 }
370371
@@ -804,7 +805,7 @@ namespace ts.codefix {
804805
805806 const isValidTypeOnlyUseSite = isValidTypeOnlyAliasUseSite ( symbolToken ) ;
806807 const useRequire = shouldUseRequire ( sourceFile , program ) ;
807- const exportInfos = getExportInfos ( symbolName , getMeaningFromLocation ( symbolToken ) , cancellationToken , sourceFile , program , useAutoImportProvider , host , preferences ) ;
808+ const exportInfos = getExportInfos ( symbolName , isJSXTagName ( symbolToken ) , getMeaningFromLocation ( symbolToken ) , cancellationToken , sourceFile , program , useAutoImportProvider , host , preferences ) ;
808809 const fixes = arrayFrom ( flatMapIterator ( exportInfos . entries ( ) , ( [ _ , exportInfos ] ) =>
809810 getImportFixes ( exportInfos , symbolName , symbolToken . getStart ( sourceFile ) , isValidTypeOnlyUseSite , useRequire , program , sourceFile , host , preferences ) ) ) ;
810811 return { fixes, symbolName } ;
@@ -845,6 +846,7 @@ namespace ts.codefix {
845846 // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
846847 function getExportInfos (
847848 symbolName : string ,
849+ isJsxTagName : boolean ,
848850 currentTokenMeaning : SemanticMeaning ,
849851 cancellationToken : CancellationToken ,
850852 fromFile : SourceFile ,
@@ -876,7 +878,7 @@ namespace ts.codefix {
876878
877879 const compilerOptions = program . getCompilerOptions ( ) ;
878880 const defaultInfo = getDefaultLikeExportInfo ( moduleSymbol , checker , compilerOptions ) ;
879- if ( defaultInfo && ( defaultInfo . name === symbolName || moduleSymbolToValidIdentifier ( moduleSymbol , getEmitScriptTarget ( compilerOptions ) ) === symbolName ) && symbolHasMeaning ( defaultInfo . symbolForMeaning , currentTokenMeaning ) ) {
881+ if ( defaultInfo && ( defaultInfo . name === symbolName || moduleSymbolToValidIdentifier ( moduleSymbol , getEmitScriptTarget ( compilerOptions ) , isJsxTagName ) === symbolName ) && symbolHasMeaning ( defaultInfo . symbolForMeaning , currentTokenMeaning ) ) {
880882 addSymbol ( moduleSymbol , sourceFile , defaultInfo . symbol , defaultInfo . exportKind , program , isFromPackageJson ) ;
881883 }
882884
@@ -1237,17 +1239,20 @@ namespace ts.codefix {
12371239 return some ( declarations , decl => ! ! ( getMeaningFromDeclaration ( decl ) & meaning ) ) ;
12381240 }
12391241
1240- export function moduleSymbolToValidIdentifier ( moduleSymbol : Symbol , target : ScriptTarget | undefined ) : string {
1241- return moduleSpecifierToValidIdentifier ( removeFileExtension ( stripQuotes ( moduleSymbol . name ) ) , target ) ;
1242+ export function moduleSymbolToValidIdentifier ( moduleSymbol : Symbol , target : ScriptTarget | undefined , forceCapitalize : boolean ) : string {
1243+ return moduleSpecifierToValidIdentifier ( removeFileExtension ( stripQuotes ( moduleSymbol . name ) ) , target , forceCapitalize ) ;
12421244 }
12431245
1244- export function moduleSpecifierToValidIdentifier ( moduleSpecifier : string , target : ScriptTarget | undefined ) : string {
1246+ export function moduleSpecifierToValidIdentifier ( moduleSpecifier : string , target : ScriptTarget | undefined , forceCapitalize ?: boolean ) : string {
12451247 const baseName = getBaseFileName ( removeSuffix ( moduleSpecifier , "/index" ) ) ;
12461248 let res = "" ;
12471249 let lastCharWasValid = true ;
12481250 const firstCharCode = baseName . charCodeAt ( 0 ) ;
12491251 if ( isIdentifierStart ( firstCharCode , target ) ) {
12501252 res += String . fromCharCode ( firstCharCode ) ;
1253+ if ( forceCapitalize ) {
1254+ res = res . toUpperCase ( ) ;
1255+ }
12511256 }
12521257 else {
12531258 lastCharWasValid = false ;
0 commit comments