Skip to content

Commit e1e7678

Browse files
committed
feat: ignore .d.ts-only overrides in tsconfig
Closes #179 Closes #180
1 parent c8e4ec3 commit e1e7678

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/resolver.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ function createResolver(
510510

511511
const hashQueryPattern = /[#?].+$/
512512
const queryPattern = /\?.+$/
513+
const dtsPattern = /\.d\.ts(\?|$)/
513514

514515
return async (viteResolve, id, importer) => {
515516
// Remove query and hash parameters from the importer path.
@@ -551,6 +552,13 @@ function createResolver(
551552
resolutionCache.set(id, resolvedId)
552553
}
553554

555+
// If we get a .d.ts file (ambient type declarations), it's because a
556+
// tsconfig file is being used for opt-in type overrides. This is an
557+
// unusual pattern, but we can just stop here to avoid trouble.
558+
if (dtsPattern.test(resolvedId)) {
559+
return notApplicable
560+
}
561+
554562
// Restore the query if one was removed earlier.
555563
if (query) {
556564
resolvedId += query

0 commit comments

Comments
 (0)