File tree Expand file tree Collapse file tree 5 files changed +20
-2
lines changed Expand file tree Collapse file tree 5 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " eslint-import-resolver-typescript " : patch
3+ ---
4+
5+ fix: resolve modules if folder contains a package.json file
Original file line number Diff line number Diff line change @@ -250,6 +250,10 @@ const isFile = (path?: string | undefined): path is string => {
250250 }
251251}
252252
253+ const isModule = ( modulePath ?: string | undefined ) : modulePath is string => {
254+ return ! ! modulePath && isFile ( path . resolve ( modulePath , 'package.json' ) )
255+ }
256+
253257/**
254258 * @param {string } source the module to resolve; i.e './some-module'
255259 * @param {string } file the importing file's full path; i.e. '/usr/local/bin/file.js'
@@ -267,7 +271,7 @@ function getMappedPath(
267271 const originalExtensions = extensions
268272 extensions = [ '' , ...extensions ]
269273
270- let paths : string [ ] | undefined = [ ]
274+ let paths : Array < string | undefined > | undefined = [ ]
271275
272276 if ( RELATIVE_PATH_PATTERN . test ( source ) ) {
273277 const resolved = path . resolve ( path . dirname ( file ) , source )
@@ -283,7 +287,7 @@ function getMappedPath(
283287 ] ) ,
284288 )
285289 . flat ( 2 )
286- . filter ( isFile )
290+ . filter ( mappedPath => isFile ( mappedPath ) || isModule ( mappedPath ) )
287291 }
288292
289293 if ( retry && paths . length === 0 ) {
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ import 'folder/tsxImportee'
1010import 'folder/subfolder/tsImportee'
1111import 'folder/subfolder/tsxImportee'
1212
13+ // import module with typings set in package.json
14+ import 'folder/module'
15+
1316// import from node_module
1417import 'typescript'
1518import 'dummy.js'
Original file line number Diff line number Diff line change 1+ export { }
Original file line number Diff line number Diff line change 1+ {
2+ "type" : " commonjs" ,
3+ "typings" : " ./module.d.ts" ,
4+ "private" : true
5+ }
You can’t perform that action at this time.
0 commit comments