Skip to content

Commit

Permalink
Tolerates running TS from a non-owning directory
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanis committed Apr 22, 2020
1 parent c670e7f commit 6a55e6a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/compiler/moduleNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ namespace ts {
const pnpapi = getPnpApi();

const currentPackage = pnpapi.findPackageLocator(`${currentDirectory}/`);
Debug.assert(!!currentPackage);
if (!currentPackage) {
return [];
}

const {packageDependencies} = pnpapi.getPackageInformation(currentPackage!);

Expand Down Expand Up @@ -1647,13 +1649,15 @@ namespace ts {
const pnpApi = getPnpApi();

const ownerPackage = pnpApi.findPackageLocator(resolvedValue.path);
Debug.assert(!!ownerPackage);
if (!ownerPackage) {
return true;
}

const rootLocators = pnpApi.getDependencyTreeRoots();

// External if none of the root locators owns the file
return !rootLocators.some(root => {
return root.name === ownerPackage!.name && root.reference === ownerPackage!.reference;
return root.name === ownerPackage.name && root.reference === ownerPackage.reference;
});
}
}

0 comments on commit 6a55e6a

Please sign in to comment.