@@ -628,24 +628,25 @@ namespace ts {
628628 }
629629 }
630630
631- if ( state . skipTsx )
632- extensions = filter ( extensions , ext => ext !== "tsx" ) ;
633-
634631 // First try to keep/add an extension: importing "./foo.ts" can be matched by a file "./foo.ts", and "./foo" by "./foo.d.ts"
635- const keepOrAddExtension = forEach ( extensions , ext =>
636- tryLoad ( fileExtensionIs ( candidate , ext ) ? candidate : candidate + ext ) ) ;
632+ const keepOrAddExtension = forEach ( extensions , ext => {
633+ if ( state . skipTsx && ( ext === ".jsx" || ext === ".tsx" ) ) {
634+ return ;
635+ }
636+ return tryLoad ( fileExtensionIs ( candidate , ext ) ? candidate : candidate + ext ) ;
637+ } ) ;
637638 if ( keepOrAddExtension ) {
638639 return keepOrAddExtension ;
639640 }
640641
641- // Then try stripping a ".js" or ".jsx" extension and replacing it with a different one, e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts"
642+ // Then try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one, e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts"
642643 return forEach ( supportedJavascriptExtensions , jsExt => {
644+ if ( state . skipTsx && jsExt === ".jsx" ) {
645+ return ;
646+ }
643647 const extensionless = tryRemoveExtension ( candidate , jsExt ) ;
644648 if ( extensionless !== undefined ) {
645- return forEach ( supportedTypeScriptExtensions , ext => {
646- if ( ext !== jsExt )
647- return tryLoad ( extensionless + ext ) ;
648- } ) ;
649+ return forEach ( supportedTypeScriptExtensions , tsExt => tryLoad ( extensionless + tsExt ) ) ;
649650 }
650651 } ) ;
651652
0 commit comments