From 4fce4129e3d3fd273333e685ce1fe8fd1969bad3 Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Wed, 2 Sep 2020 10:59:39 -0700 Subject: [PATCH 1/2] Remove internal paths from test dependencies --- packages/definitions-parser/src/lib/module-info.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/definitions-parser/src/lib/module-info.ts b/packages/definitions-parser/src/lib/module-info.ts index 6e9b5f1abf..f25fa13e8f 100644 --- a/packages/definitions-parser/src/lib/module-info.ts +++ b/packages/definitions-parser/src/lib/module-info.ts @@ -373,7 +373,8 @@ export function getTestDependencies( for (const { fileName: ref } of referencedFiles) { throw new Error(`Test files should not use ''. '${filePath()}' references '${ref}'.`); } - for (const { fileName: referencedPackage } of typeReferenceDirectives) { + for (const { fileName: ref } of typeReferenceDirectives) { + const referencedPackage = rootName(ref, typeFiles, packageName); if (dependencies.has(referencedPackage)) { throw new Error( `'${filePath()}' unnecessarily references '${referencedPackage}', which is already referenced in the type definition.` From 08f55b57e7a942fc7d0f412f2ed57df5e8a3cd0b Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Wed, 2 Sep 2020 11:01:10 -0700 Subject: [PATCH 2/2] Add tests --- .../definitions-parser/test/module-info.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/definitions-parser/test/module-info.test.ts b/packages/definitions-parser/test/module-info.test.ts index 62797f9276..5de8b3f83e 100644 --- a/packages/definitions-parser/test/module-info.test.ts +++ b/packages/definitions-parser/test/module-info.test.ts @@ -133,5 +133,18 @@ testo({ const i = getModuleInfo("boring", types); const d = getTestDependencies("boring", types, tests.keys(), i.dependencies, fs.subDir("types").subDir("boring")); expect(d).toEqual(new Set(["super-big-fun-hus"])); + }, + getTestDependenciesRemovesInternalPaths() { + const pkg = new Dir(undefined); + pkg.set( + "mock-tests.ts", + `/// +` + ); + const memFS = new InMemoryFS(pkg, "types/mock"); + const { types, tests } = allReferencedFiles(["mock-tests.ts"], memFS, "mock", "types/mock"); + const { dependencies } = getModuleInfo("mock", types); + const testDependencies = getTestDependencies("mock", types, tests.keys(), dependencies, memFS); + expect(Array.from(testDependencies)).toEqual(["test-dependency"]); } });