Skip to content

Commit 1dff2c7

Browse files
committed
feat: resolve .d.ts path automatically for .jsx? files
1 parent 18eafa2 commit 1dff2c7

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Diff for: index.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,27 @@ function resolveFile(source, file, config) {
5454

5555
// note that even if we match via tsconfig-paths, we still need to do a final resolve
5656
let foundNodePath;
57+
const basedir = path.dirname(path.resolve(file))
5758
try {
5859
foundNodePath = resolve.sync(foundTsPath || source, {
5960
extensions,
60-
basedir: path.dirname(path.resolve(file)),
61+
basedir,
6162
packageFilter,
6263
});
6364
} catch (err) {
6465
foundNodePath = null;
6566
}
6667

68+
if (foundNodePath && /\.jsx?$/.test(foundNodePath)) {
69+
try {
70+
foundNodePath = resolve.sync(foundTsPath || source, {
71+
extensions: ['.d.ts'],
72+
basedir,
73+
packageFilter,
74+
});
75+
} catch (err) {}
76+
}
77+
6778
if (foundNodePath) {
6879
log('matched node path:', foundNodePath);
6980

@@ -73,7 +84,7 @@ function resolveFile(source, file, config) {
7384
};
7485
}
7586

76-
log('didnt find', source);
87+
log("didn't find", source);
7788

7889
return {
7990
found: false,

Diff for: package-lock.json

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)