Skip to content

Commit 86c7536

Browse files
committed
Add explicit isDTS detection
1 parent cccd364 commit 86c7536

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/utils/trie.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,14 @@ export class TrieNode<T> {
8787
const name = base.slice(0, dotIndex);
8888
const extension = base.slice(dotIndex);
8989

90-
const normalizedExtension = extension.replace(
91-
/^\.([mc])?ts(x)?$/,
92-
'.$1js$2'
93-
);
90+
let normalizedExtension = extension;
91+
92+
if (!isDTS(extension)) {
93+
normalizedExtension = extension.replace(
94+
/\.([mc])?ts(x)?$/,
95+
'.$1js$2'
96+
);
97+
}
9498

9599
path = dir + sep + name + normalizedExtension;
96100

@@ -126,3 +130,7 @@ export class TrieNode<T> {
126130
return aliasTrie;
127131
}
128132
}
133+
134+
function isDTS(extension: string): boolean {
135+
return /\.d(\..*)?\.[mc]?ts(x)?$/.test(extension);
136+
}

0 commit comments

Comments
 (0)