@@ -135,6 +135,7 @@ import {
135135 RequireOrImportCall ,
136136 RequireVariableStatement ,
137137 sameMap ,
138+ ScriptKind ,
138139 SemanticMeaning ,
139140 shouldUseUriStyleNodeCoreModules ,
140141 single ,
@@ -1255,7 +1256,6 @@ function getNewImportFixes(
12551256 preferences : UserPreferences ,
12561257 fromCacheOnly ?: boolean ,
12571258) : { computedWithoutCacheCount : number ; fixes : readonly ( FixAddNewImport | FixAddJsdocTypeImport ) [ ] ; } {
1258- const isJs = hasJSFileExtension ( sourceFile . fileName ) ;
12591259 const compilerOptions = program . getCompilerOptions ( ) ;
12601260 const moduleSpecifierResolutionHost = createModuleSpecifierResolutionHost ( program , host ) ;
12611261 const getChecker = createGetChecker ( program , host ) ;
@@ -1276,9 +1276,17 @@ function getNewImportFixes(
12761276 if ( rejectNodeModulesRelativePaths && pathContainsNodeModules ( moduleSpecifier ) ) {
12771277 return undefined ;
12781278 }
1279- if ( ! importedSymbolHasValueMeaning && isJs && usagePosition !== undefined ) {
1280- // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
1281- return { kind : ImportFixKind . JsdocTypeImport , moduleSpecifierKind, moduleSpecifier, usagePosition, exportInfo, isReExport : i > 0 } ;
1279+ if ( ! importedSymbolHasValueMeaning && usagePosition !== undefined ) {
1280+ const scriptKind = 'scriptKind' in sourceFile
1281+ ? sourceFile . scriptKind
1282+ : host . getScriptKind ?.( sourceFile . fileName ) ;
1283+ const isJs = scriptKind !== undefined
1284+ ? scriptKind === ScriptKind . JS || scriptKind === ScriptKind . JSX
1285+ : hasJSFileExtension ( sourceFile . fileName ) ;
1286+ if ( isJs ) {
1287+ // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types.
1288+ return { kind : ImportFixKind . JsdocTypeImport , moduleSpecifierKind, moduleSpecifier, usagePosition, exportInfo, isReExport : i > 0 } ;
1289+ }
12821290 }
12831291 const importKind = getImportKind ( sourceFile , exportInfo . exportKind , program ) ;
12841292 let qualification : Qualification | undefined ;
0 commit comments