Skip to content

Commit 1a63c67

Browse files
authored
Merge pull request #27260 from valera-rozuvan/fix-27086
Fix 27086. Ignore directories starting with a dot.
2 parents 1b880f8 + 8bd7f4e commit 1a63c67

9 files changed

+73
-2
lines changed

src/compiler/moduleNameResolver.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,13 @@ namespace ts {
381381
// tslint:disable-next-line:no-null-keyword
382382
const isNotNeededPackage = host.fileExists(packageJsonPath) && (readJson(packageJsonPath, host) as PackageJson).typings === null;
383383
if (!isNotNeededPackage) {
384-
// Return just the type directive names
385-
result.push(getBaseFileName(normalized));
384+
const baseFileName = getBaseFileName(normalized);
385+
386+
// At this stage, skip results with leading dot.
387+
if (baseFileName.charCodeAt(0) !== CharacterCodes.dot) {
388+
// Return just the type directive names
389+
result.push(baseFileName);
390+
}
386391
}
387392
}
388393
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//// [tests/cases/compiler/moduleResolution_automaticTypeDirectiveNames.ts] ////
2+
3+
//// [index.d.ts]
4+
declare const a: number;
5+
6+
//// [index.d.ts]
7+
declare const a: string;
8+
9+
//// [a.ts]
10+
a;
11+
12+
13+
//// [a.js]
14+
a;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== /a.ts ===
2+
a;
3+
>a : Symbol(a, Decl(index.d.ts, 0, 13))
4+
5+
=== /node_modules/@types/a/index.d.ts ===
6+
declare const a: string;
7+
>a : Symbol(a, Decl(index.d.ts, 0, 13))
8+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== /a.ts ===
2+
a;
3+
>a : string
4+
5+
=== /node_modules/@types/a/index.d.ts ===
6+
declare const a: string;
7+
>a : string
8+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [tests/cases/compiler/moduleResolution_noLeadingDot.ts] ////
2+
3+
//// [README.md]
4+
This is a test.
5+
6+
//// [a.ts]
7+
true;
8+
9+
10+
//// [a.js]
11+
true;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== /a.ts ===
2+
true;
3+
No type information for this code.
4+
No type information for this code.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== /a.ts ===
2+
true;
3+
>true : true
4+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @noImplicitReferences: true
2+
3+
// @Filename: /node_modules/@types/.a/index.d.ts
4+
declare const a: number;
5+
6+
// @Filename: /node_modules/@types/a/index.d.ts
7+
declare const a: string;
8+
9+
// @Filename: /a.ts
10+
a;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @noImplicitReferences: true
2+
3+
// @Filename: /node_modules/@types/.svn/README.md
4+
This is a test.
5+
6+
// @Filename: /a.ts
7+
true;

0 commit comments

Comments
 (0)