@@ -103,19 +103,18 @@ function resolveDependency(
103103 // Check if file is a file in the project
104104 const resolvedPath = path . join ( fileDirectory , dependency ) ;
105105
106- if ( isProjectFile ( resolvedPath , program ) ) {
107- // JSON files need their extension as part of the import path, caught by this branch
108- return resolvedPath ;
109- }
110-
111- const resolvedFile = resolvedPath + ".ts" ;
112- if ( isProjectFile ( resolvedFile , program ) ) {
113- return resolvedFile ;
114- }
115-
116- const projectIndexPath = path . resolve ( resolvedPath , "index.ts" ) ;
117- if ( isProjectFile ( projectIndexPath , program ) ) {
118- return projectIndexPath ;
106+ const possibleProjectFiles = [
107+ resolvedPath , // JSON files need their extension as part of the import path, caught by this branch,
108+ resolvedPath + ".ts" , // Regular ts file
109+ path . join ( resolvedPath , "index.ts" ) , // Index ts file,
110+ resolvedPath + ".tsx" , // tsx file
111+ path . join ( resolvedPath , "index.tsx" ) , // tsx index
112+ ] ;
113+
114+ for ( const possibleFile of possibleProjectFiles ) {
115+ if ( isProjectFile ( possibleFile , program ) ) {
116+ return possibleFile ;
117+ }
119118 }
120119
121120 // Check if this is a sibling of a required lua file
@@ -215,7 +214,9 @@ function isProjectFile(file: string, program: ts.Program): boolean {
215214function hasSourceFileInProject ( filePath : string , program : ts . Program ) {
216215 const pathWithoutExtension = trimExtension ( filePath ) ;
217216 return (
218- isProjectFile ( pathWithoutExtension + ".ts" , program ) || isProjectFile ( pathWithoutExtension + ".json" , program )
217+ isProjectFile ( pathWithoutExtension + ".ts" , program ) ||
218+ isProjectFile ( pathWithoutExtension + ".tsx" , program ) ||
219+ isProjectFile ( pathWithoutExtension + ".json" , program )
219220 ) ;
220221}
221222
0 commit comments