Skip to content

Commit 6a55e6a

Browse files
committed
Tolerates running TS from a non-owning directory
1 parent c670e7f commit 6a55e6a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: src/compiler/moduleNameResolver.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ namespace ts {
290290
const pnpapi = getPnpApi();
291291

292292
const currentPackage = pnpapi.findPackageLocator(`${currentDirectory}/`);
293-
Debug.assert(!!currentPackage);
293+
if (!currentPackage) {
294+
return [];
295+
}
294296

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

@@ -1647,13 +1649,15 @@ namespace ts {
16471649
const pnpApi = getPnpApi();
16481650

16491651
const ownerPackage = pnpApi.findPackageLocator(resolvedValue.path);
1650-
Debug.assert(!!ownerPackage);
1652+
if (!ownerPackage) {
1653+
return true;
1654+
}
16511655

16521656
const rootLocators = pnpApi.getDependencyTreeRoots();
16531657

16541658
// External if none of the root locators owns the file
16551659
return !rootLocators.some(root => {
1656-
return root.name === ownerPackage!.name && root.reference === ownerPackage!.reference;
1660+
return root.name === ownerPackage.name && root.reference === ownerPackage.reference;
16571661
});
16581662
}
16591663
}

0 commit comments

Comments
 (0)