Skip to content

Commit

Permalink
Add explicit isDTS detection
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeAbby committed Dec 22, 2024
1 parent cccd364 commit 86c7536
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/utils/trie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,14 @@ export class TrieNode<T> {
const name = base.slice(0, dotIndex);
const extension = base.slice(dotIndex);

const normalizedExtension = extension.replace(
/^\.([mc])?ts(x)?$/,
'.$1js$2'
);
let normalizedExtension = extension;

if (!isDTS(extension)) {
normalizedExtension = extension.replace(
/\.([mc])?ts(x)?$/,
'.$1js$2'
);
}

path = dir + sep + name + normalizedExtension;

Expand Down Expand Up @@ -126,3 +130,7 @@ export class TrieNode<T> {
return aliasTrie;
}
}

function isDTS(extension: string): boolean {
return /\.d(\..*)?\.[mc]?ts(x)?$/.test(extension);
}

0 comments on commit 86c7536

Please sign in to comment.