moduleSpecifiers: Allow "*" as a path mapping (#25881)

This commit is contained in:
Andy 2018-07-23 17:11:30 -07:00 committed by GitHub
parent 2146a91df3
commit 30c41492d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 4 deletions

View File

@ -218,10 +218,7 @@ namespace ts.moduleSpecifiers {
for (const patternText of paths[key]) {
const pattern = removeFileExtension(normalizePath(patternText));
const indexOfStar = pattern.indexOf("*");
if (indexOfStar === 0 && pattern.length === 1) {
continue;
}
else if (indexOfStar !== -1) {
if (indexOfStar !== -1) {
const prefix = pattern.substr(0, indexOfStar);
const suffix = pattern.substr(indexOfStar + 1);
if (relativeToBaseUrl.length >= prefix.length + suffix.length &&

View File

@ -0,0 +1,24 @@
/// <reference path="fourslash.ts" />
// @Filename: /a.ts
////export const foo = 0;
// @Filename: /b.ts
////foo;
// @Filename: /tsconfig.json
////{
//// "compilerOptions": {
//// "baseUrl": ".",
//// "paths": {
//// "@root/*": ["*"],
//// }
//// }
////}
goTo.file("/b.ts");
verify.importFixAtPosition([
`import { foo } from "@root/a";
foo;`,
]);