Skip to content

Commit 30c4149

Browse files
author
Andy
authored
moduleSpecifiers: Allow "*" as a path mapping (#25881)
1 parent 2146a91 commit 30c4149

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

Diff for: src/compiler/moduleSpecifiers.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,7 @@ namespace ts.moduleSpecifiers {
218218
for (const patternText of paths[key]) {
219219
const pattern = removeFileExtension(normalizePath(patternText));
220220
const indexOfStar = pattern.indexOf("*");
221-
if (indexOfStar === 0 && pattern.length === 1) {
222-
continue;
223-
}
224-
else if (indexOfStar !== -1) {
221+
if (indexOfStar !== -1) {
225222
const prefix = pattern.substr(0, indexOfStar);
226223
const suffix = pattern.substr(indexOfStar + 1);
227224
if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @Filename: /a.ts
4+
////export const foo = 0;
5+
6+
// @Filename: /b.ts
7+
////foo;
8+
9+
// @Filename: /tsconfig.json
10+
////{
11+
//// "compilerOptions": {
12+
//// "baseUrl": ".",
13+
//// "paths": {
14+
//// "@root/*": ["*"],
15+
//// }
16+
//// }
17+
////}
18+
19+
goTo.file("/b.ts");
20+
verify.importFixAtPosition([
21+
`import { foo } from "@root/a";
22+
23+
foo;`,
24+
]);

0 commit comments

Comments
 (0)