@@ -231,11 +231,11 @@ namespace ts.codefix {
231231 function getInfoWithChecker ( checker : TypeChecker , isFromPackageJson : boolean ) : SymbolExportInfo | undefined {
232232 const defaultInfo = getDefaultLikeExportInfo ( moduleSymbol , checker , compilerOptions ) ;
233233 if ( defaultInfo && skipAlias ( defaultInfo . symbol , checker ) === symbol ) {
234- return { symbol : defaultInfo . symbol , moduleSymbol, moduleFileName : undefined , exportKind : defaultInfo . exportKind , isTypeOnly : isTypeOnlySymbol ( symbol , checker ) , isFromPackageJson } ;
234+ return { symbol : defaultInfo . symbol , moduleSymbol, moduleFileName : undefined , exportKind : defaultInfo . exportKind , targetFlags : skipAlias ( symbol , checker ) . flags , isFromPackageJson } ;
235235 }
236236 const named = checker . tryGetMemberInModuleExportsAndProperties ( symbol . name , moduleSymbol ) ;
237237 if ( named && skipAlias ( named , checker ) === symbol ) {
238- return { symbol : named , moduleSymbol, moduleFileName : undefined , exportKind : ExportKind . Named , isTypeOnly : isTypeOnlySymbol ( symbol , checker ) , isFromPackageJson } ;
238+ return { symbol : named , moduleSymbol, moduleFileName : undefined , exportKind : ExportKind . Named , targetFlags : skipAlias ( symbol , checker ) . flags , isFromPackageJson } ;
239239 }
240240 }
241241 }
@@ -256,12 +256,12 @@ namespace ts.codefix {
256256
257257 const defaultInfo = getDefaultLikeExportInfo ( moduleSymbol , checker , compilerOptions ) ;
258258 if ( defaultInfo && ( defaultInfo . name === symbolName || moduleSymbolToValidIdentifier ( moduleSymbol , compilerOptions . target ) === symbolName ) && skipAlias ( defaultInfo . symbol , checker ) === exportedSymbol && isImportable ( program , moduleFile , isFromPackageJson ) ) {
259- result . push ( { symbol : defaultInfo . symbol , moduleSymbol, moduleFileName : moduleFile ?. fileName , exportKind : defaultInfo . exportKind , isTypeOnly : isTypeOnlySymbol ( defaultInfo . symbol , checker ) , isFromPackageJson } ) ;
259+ result . push ( { symbol : defaultInfo . symbol , moduleSymbol, moduleFileName : moduleFile ?. fileName , exportKind : defaultInfo . exportKind , targetFlags : skipAlias ( defaultInfo . symbol , checker ) . flags , isFromPackageJson } ) ;
260260 }
261261
262262 for ( const exported of checker . getExportsAndPropertiesOfModule ( moduleSymbol ) ) {
263263 if ( exported . name === symbolName && skipAlias ( exported , checker ) === exportedSymbol && isImportable ( program , moduleFile , isFromPackageJson ) ) {
264- result . push ( { symbol : exported , moduleSymbol, moduleFileName : moduleFile ?. fileName , exportKind : ExportKind . Named , isTypeOnly : isTypeOnlySymbol ( exported , checker ) , isFromPackageJson } ) ;
264+ result . push ( { symbol : exported , moduleSymbol, moduleFileName : moduleFile ?. fileName , exportKind : ExportKind . Named , targetFlags : skipAlias ( exported , checker ) . flags , isFromPackageJson } ) ;
265265 }
266266 }
267267 } ) ;
@@ -294,10 +294,6 @@ namespace ts.codefix {
294294 return result && { ...result , computedWithoutCacheCount } ;
295295 }
296296
297- function isTypeOnlySymbol ( s : Symbol , checker : TypeChecker ) : boolean {
298- return ! ( skipAlias ( s , checker ) . flags & SymbolFlags . Value ) ;
299- }
300-
301297 function isTypeOnlyPosition ( sourceFile : SourceFile , position : number ) {
302298 return isValidTypeOnlyAliasUseSite ( getTokenAtPosition ( sourceFile , position ) ) ;
303299 }
@@ -395,9 +391,9 @@ namespace ts.codefix {
395391 } ) ;
396392 }
397393
398- function getExistingImportDeclarations ( { moduleSymbol, exportKind, isTypeOnly : exportedSymbolIsTypeOnly } : SymbolExportInfo , checker : TypeChecker , importingFile : SourceFile , compilerOptions : CompilerOptions ) : readonly FixAddToExistingImportInfo [ ] {
394+ function getExistingImportDeclarations ( { moduleSymbol, exportKind, targetFlags } : SymbolExportInfo , checker : TypeChecker , importingFile : SourceFile , compilerOptions : CompilerOptions ) : readonly FixAddToExistingImportInfo [ ] {
399395 // Can't use an es6 import for a type in JS.
400- if ( exportedSymbolIsTypeOnly && isSourceFileJS ( importingFile ) ) return emptyArray ;
396+ if ( ! ( targetFlags & SymbolFlags . Value ) && isSourceFileJS ( importingFile ) ) return emptyArray ;
401397 const importKind = getImportKind ( importingFile , exportKind , compilerOptions ) ;
402398 return mapDefined ( importingFile . imports , ( moduleSpecifier ) : FixAddToExistingImportInfo | undefined => {
403399 const i = importFromModuleSpecifier ( moduleSpecifier ) ;
@@ -462,7 +458,7 @@ namespace ts.codefix {
462458 computedWithoutCacheCount += computedWithoutCache ? 1 : 0 ;
463459 return moduleSpecifiers ?. map ( ( moduleSpecifier ) : FixAddNewImport | FixUseImportType =>
464460 // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
465- exportInfo . isTypeOnly && isJs && position !== undefined
461+ ! ( exportInfo . targetFlags & SymbolFlags . Value ) && isJs && position !== undefined
466462 ? { kind : ImportFixKind . ImportType , moduleSpecifier, position, exportInfo }
467463 : {
468464 kind : ImportFixKind . AddNew ,
@@ -547,7 +543,7 @@ namespace ts.codefix {
547543 if ( ! umdSymbol ) return undefined ;
548544 const symbol = checker . getAliasedSymbol ( umdSymbol ) ;
549545 const symbolName = umdSymbol . name ;
550- const exportInfos : readonly SymbolExportInfo [ ] = [ { symbol : umdSymbol , moduleSymbol : symbol , moduleFileName : undefined , exportKind : ExportKind . UMD , isTypeOnly : false , isFromPackageJson : false } ] ;
546+ const exportInfos : readonly SymbolExportInfo [ ] = [ { symbol : umdSymbol , moduleSymbol : symbol , moduleFileName : undefined , exportKind : ExportKind . UMD , targetFlags : symbol . flags , isFromPackageJson : false } ] ;
551547 const useRequire = shouldUseRequire ( sourceFile , program ) ;
552548 const fixes = getImportFixes ( exportInfos , symbolName , isIdentifier ( token ) ? token . getStart ( sourceFile ) : undefined , /*preferTypeOnlyImport*/ false , useRequire , program , sourceFile , host , preferences ) ;
553549 return { fixes, symbolName } ;
@@ -653,7 +649,7 @@ namespace ts.codefix {
653649 ! toFile && packageJsonFilter . allowsImportingAmbientModule ( moduleSymbol , moduleSpecifierResolutionHost )
654650 ) {
655651 const checker = program . getTypeChecker ( ) ;
656- originalSymbolToExportInfos . add ( getUniqueSymbolId ( exportedSymbol , checker ) . toString ( ) , { symbol : exportedSymbol , moduleSymbol, moduleFileName : toFile ?. fileName , exportKind, isTypeOnly : isTypeOnlySymbol ( exportedSymbol , checker ) , isFromPackageJson } ) ;
652+ originalSymbolToExportInfos . add ( getUniqueSymbolId ( exportedSymbol , checker ) . toString ( ) , { symbol : exportedSymbol , moduleSymbol, moduleFileName : toFile ?. fileName , exportKind, targetFlags : skipAlias ( exportedSymbol , checker ) . flags , isFromPackageJson } ) ;
657653 }
658654 }
659655 forEachExternalModuleToImportFrom ( program , host , useAutoImportProvider , ( moduleSymbol , sourceFile , program , isFromPackageJson ) => {
0 commit comments