Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

Handle local references in scoped packages #768

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions src/lib/module-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from "path";
import * as ts from "typescript";

import { FS } from "../get-definitely-typed";
import { hasWindowsSlashes, joinPaths, normalizeSlashes, sort } from "../util/util";
import { hasWindowsSlashes, joinPaths, normalizeSlashes, sort, unmangleScopedPackage } from "../util/util";

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

Expand Down Expand Up @@ -219,16 +219,15 @@ function findReferencedFiles(src: ts.SourceFile, packageName: string, subDirecto
// only <reference types="../packagename/x" /> references are local (or "packagename/x", though in 3.7 that doesn't work in DT).
if (ref.fileName.startsWith("../" + packageName + "/")) {
addReference({ text: ref.fileName, exact: false });
} else if (ref.fileName.startsWith(packageName + "/")) {
} else if (ref.fileName.startsWith((unmangleScopedPackage(packageName) || packageName) + "/")) {
addReference({ text: convertToRelativeReference(ref.fileName), exact: false });
}
}

for (const ref of imports(src)) {
if (ref.startsWith(".")) {
addReference({ text: ref, exact: false });
}
if (ref.startsWith(packageName + "/")) {
} else if (ref.startsWith((unmangleScopedPackage(packageName) || packageName) + "/")) {
addReference({ text: convertToRelativeReference(ref), exact: false });
}
}
Expand Down