Skip to content

Commit b8fbada

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

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/compiler/moduleNameResolver.ts

Lines changed: 5 additions & 2 deletions
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

@@ -1645,8 +1647,9 @@ namespace ts {
16451647

16461648
function checkPnpExternalLibraryImport(resolvedValue: Resolved) {
16471649
const pnpApi = getPnpApi();
1648-
16491650
const ownerPackage = pnpApi.findPackageLocator(resolvedValue.path);
1651+
1652+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
16501653
Debug.assert(!!ownerPackage);
16511654

16521655
const rootLocators = pnpApi.getDependencyTreeRoots();

0 commit comments

Comments
 (0)