@@ -628,24 +628,25 @@ namespace ts {
628
628
}
629
629
}
630
630
631
- if ( state . skipTsx )
632
- extensions = filter ( extensions , ext => ext !== "tsx" ) ;
633
-
634
631
// 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
+ } ) ;
637
638
if ( keepOrAddExtension ) {
638
639
return keepOrAddExtension ;
639
640
}
640
641
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"
642
643
return forEach ( supportedJavascriptExtensions , jsExt => {
644
+ if ( state . skipTsx && jsExt === ".jsx" ) {
645
+ return ;
646
+ }
643
647
const extensionless = tryRemoveExtension ( candidate , jsExt ) ;
644
648
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 ) ) ;
649
650
}
650
651
} ) ;
651
652
0 commit comments