Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/definitions-parser/src/lib/module-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as ts from "typescript";
import { sort, joinPaths, FS, normalizeSlashes, hasWindowsSlashes } from "@definitelytyped/utils";

import { readFileAndThrowOnBOM } from "./definition-parser";
import { getMangledNameForScopedPackage } from "../packages";

export function getModuleInfo(packageName: string, all: Map<string, ts.SourceFile>): ModuleInfo {
const dependencies = new Set<string>();
Expand Down Expand Up @@ -235,8 +236,7 @@ function findReferencedFiles(src: ts.SourceFile, packageName: string, subDirecto
for (const ref of imports(src)) {
if (ref.startsWith(".")) {
addReference({ text: ref, exact: false });
}
if (ref.startsWith(packageName + "/")) {
} else if (getMangledNameForScopedPackage(ref).startsWith(packageName + "/")) {
addReference({ text: convertToRelativeReference(ref), exact: false });
hasNonRelativeImports = true;
}
Expand Down
18 changes: 18 additions & 0 deletions packages/definitions-parser/test/module-info.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ testo({
const i = getModuleInfo("fail", types);
expect(i.dependencies).toEqual(new Set([]));
},
selfInScopedPackage() {
const scoped = new Dir(undefined);
scoped.set(
"index.d.ts",
`import "@rdfjs/to-ntriples/component";
`
);
scoped.set("component.d.ts", "");
const memFS = new InMemoryFS(scoped, "types/rdfjs__to-ntriples");
const { types, tests } = allReferencedFiles(
["index.d.ts"],
memFS,
"rdfjs__to-ntriples",
"types/rdfjs__to-ntriples"
);
expect(Array.from(types.keys())).toEqual(["index.d.ts", "component.d.ts"]);
expect(Array.from(tests.keys())).toEqual([]);
},
selfInTypesVersionsParent() {
const pkg = new Dir(undefined);
const ts20 = pkg.subdir("ts2.0");
Expand Down