When loading a module from node_modules, get packageId even in the loadModuleFromFile case (#18185)

* When loading a module from node_modules, get packageId even in the `loadModuleFromFile` case

* Support packageId for <reference types> too
This commit is contained in:
Andy 2017-09-07 14:31:20 -07:00 committed by GitHub
parent ed4e2e6e3b
commit 2e02778960
42 changed files with 493 additions and 123 deletions

View file

@ -51,13 +51,17 @@ namespace ts {
DtsOnly /** Only '.d.ts' */
}
interface PathAndPackageId {
readonly fileName: string;
readonly packageId: PackageId;
}
/** Used with `Extensions.DtsOnly` to extract the path from TypeScript results. */
function resolvedTypeScriptOnly(resolved: Resolved | undefined): string | undefined {
function resolvedTypeScriptOnly(resolved: Resolved | undefined): PathAndPackageId | undefined {
if (!resolved) {
return undefined;
}
Debug.assert(extensionIsTypeScript(resolved.extension));
return resolved.path;
return { fileName: resolved.path, packageId: resolved.packageId };
}
function createResolvedModuleWithFailedLookupLocations(resolved: Resolved | undefined, isExternalLibraryImport: boolean, failedLookupLocations: string[]): ResolvedModuleWithFailedLookupLocations {
@ -201,18 +205,18 @@ namespace ts {
let resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined;
if (resolved) {
if (!options.preserveSymlinks) {
resolved = realPath(resolved, host, traceEnabled);
resolved = { ...resolved, fileName: realPath(resolved.fileName, host, traceEnabled) };
}
if (traceEnabled) {
trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary);
trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary);
}
resolvedTypeReferenceDirective = { primary, resolvedFileName: resolved };
resolvedTypeReferenceDirective = { primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId };
}
return { resolvedTypeReferenceDirective, failedLookupLocations };
function primaryLookup(): string | undefined {
function primaryLookup(): PathAndPackageId | undefined {
// Check primary library paths
if (typeRoots && typeRoots.length) {
if (traceEnabled) {
@ -237,8 +241,8 @@ namespace ts {
}
}
function secondaryLookup(): string | undefined {
let resolvedFile: string;
function secondaryLookup(): PathAndPackageId | undefined {
let resolvedFile: PathAndPackageId;
const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile);
if (initialLocationForSecondaryLookup !== undefined) {
@ -675,7 +679,7 @@ namespace ts {
if (extension !== undefined) {
const path = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state);
if (path !== undefined) {
return { path, extension, packageId: undefined };
return noPackageId({ path, ext: extension });
}
}
@ -875,38 +879,49 @@ namespace ts {
return undefined;
}
function loadNodeModuleFromDirectory(extensions: Extensions, candidate: string, failedLookupLocations: Push<string>, onlyRecordFailures: boolean, state: ModuleResolutionState, considerPackageJson = true): Resolved | undefined {
const directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host);
function loadNodeModuleFromDirectory(extensions: Extensions, candidate: string, failedLookupLocations: Push<string>, onlyRecordFailures: boolean, state: ModuleResolutionState, considerPackageJson = true) {
const { packageJsonContent, packageId } = considerPackageJson
? getPackageJsonInfo(candidate, "", failedLookupLocations, onlyRecordFailures, state)
: { packageJsonContent: undefined, packageId: undefined };
return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent));
}
let packageId: PackageId | undefined;
if (considerPackageJson) {
const packageJsonPath = pathToPackageJson(candidate);
if (directoryExists && state.host.fileExists(packageJsonPath)) {
if (state.traceEnabled) {
trace(state.host, Diagnostics.Found_package_json_at_0, packageJsonPath);
}
const jsonContent = readJson(packageJsonPath, state.host);
if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") {
packageId = { name: jsonContent.name, version: jsonContent.version };
}
const fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state);
if (fromPackageJson) {
return withPackageId(packageId, fromPackageJson);
}
}
else {
if (directoryExists && state.traceEnabled) {
trace(state.host, Diagnostics.File_0_does_not_exist, packageJsonPath);
}
// record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results
failedLookupLocations.push(packageJsonPath);
}
function loadNodeModuleFromDirectoryWorker(extensions: Extensions, candidate: string, failedLookupLocations: Push<string>, onlyRecordFailures: boolean, state: ModuleResolutionState, packageJsonContent: PackageJson | undefined): PathAndExtension | undefined {
const fromPackageJson = packageJsonContent && loadModuleFromPackageJson(packageJsonContent, extensions, candidate, failedLookupLocations, state);
if (fromPackageJson) {
return fromPackageJson;
}
const directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host);
return loadModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state);
}
return withPackageId(packageId, loadModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state));
function getPackageJsonInfo(
nodeModuleDirectory: string,
subModuleName: string,
failedLookupLocations: Push<string>,
onlyRecordFailures: boolean,
{ host, traceEnabled }: ModuleResolutionState,
): { packageJsonContent: PackageJson | undefined, packageId: PackageId | undefined } {
const directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host);
const packageJsonPath = pathToPackageJson(nodeModuleDirectory);
if (directoryExists && host.fileExists(packageJsonPath)) {
if (traceEnabled) {
trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath);
}
const packageJsonContent = readJson(packageJsonPath, host);
const packageId: PackageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string"
? { name: packageJsonContent.name, subModuleName, version: packageJsonContent.version }
: undefined;
return { packageJsonContent, packageId };
}
else {
if (directoryExists && traceEnabled) {
trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
}
// record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results
failedLookupLocations.push(packageJsonPath);
return { packageJsonContent: undefined, packageId: undefined };
}
}
function loadModuleFromPackageJson(jsonContent: PackageJson, extensions: Extensions, candidate: string, failedLookupLocations: Push<string>, state: ModuleResolutionState): PathAndExtension | undefined {
@ -961,10 +976,18 @@ namespace ts {
}
function loadModuleFromNodeModulesFolder(extensions: Extensions, moduleName: string, nodeModulesFolder: string, nodeModulesFolderExists: boolean, failedLookupLocations: Push<string>, state: ModuleResolutionState): Resolved | undefined {
const { top, rest } = getNameOfTopDirectory(moduleName);
const packageRootPath = combinePaths(nodeModulesFolder, top);
const { packageJsonContent, packageId } = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state);
const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
const pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) ||
loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state, packageJsonContent);
return withPackageId(packageId, pathAndExtension);
}
return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) ||
loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state);
function getNameOfTopDirectory(name: string): { top: string, rest: string } {
const idx = name.indexOf(directorySeparator);
return idx === -1 ? { top: name, rest: "" } : { top: name.slice(0, idx), rest: name.slice(idx + 1) };
}
function loadModuleFromNodeModules(extensions: Extensions, moduleName: string, directory: string, failedLookupLocations: Push<string>, state: ModuleResolutionState, cache: NonRelativeModuleNameResolutionCache): SearchResult<Resolved> {

View file

@ -1427,7 +1427,7 @@ namespace ts {
}
function processRootFile(fileName: string, isDefaultLib: boolean) {
processSourceFile(normalizePath(fileName), isDefaultLib);
processSourceFile(normalizePath(fileName), isDefaultLib, /*packageId*/ undefined);
}
function fileReferenceIsEqualTo(a: FileReference, b: FileReference): boolean {
@ -1591,9 +1591,9 @@ namespace ts {
}
/** This has side effects through `findSourceFile`. */
function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): void {
function processSourceFile(fileName: string, isDefaultLib: boolean, packageId: PackageId | undefined, refFile?: SourceFile, refPos?: number, refEnd?: number): void {
getSourceFileFromReferenceWorker(fileName,
fileName => findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, /*packageId*/ undefined),
fileName => findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId),
(diagnostic, ...args) => {
fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined
? createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...args)
@ -1675,7 +1675,7 @@ namespace ts {
});
if (packageId) {
const packageIdKey = `${packageId.name}@${packageId.version}`;
const packageIdKey = `${packageId.name}/${packageId.subModuleName}@${packageId.version}`;
const fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
if (fileFromPackageId) {
// Some other SourceFile already exists with this package name and version.
@ -1735,7 +1735,7 @@ namespace ts {
function processReferencedFiles(file: SourceFile, isDefaultLib: boolean) {
forEach(file.referencedFiles, ref => {
const referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName);
processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end);
processSourceFile(referencedFileName, isDefaultLib, /*packageId*/ undefined, file, ref.pos, ref.end);
});
}
@ -1766,7 +1766,7 @@ namespace ts {
if (resolvedTypeReferenceDirective) {
if (resolvedTypeReferenceDirective.primary) {
// resolved from the primary path
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd);
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd);
}
else {
// If we already resolved to this file, it must have been a secondary reference. Check file contents
@ -1789,7 +1789,7 @@ namespace ts {
}
else {
// First resolution of this library
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd);
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd);
}
}
}

View file

@ -4055,6 +4055,11 @@ namespace ts {
* If accessing a non-index file, this should include its name e.g. "foo/bar".
*/
name: string;
/**
* Name of a submodule within this package.
* May be "".
*/
subModuleName: string;
/** Version of the package, e.g. "1.2.3" */
version: string;
}
@ -4078,6 +4083,7 @@ namespace ts {
primary: boolean;
// The location of the .d.ts file we located, or undefined if resolution failed
resolvedFileName?: string;
packageId?: PackageId;
}
export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations {

View file

@ -104,7 +104,7 @@ namespace ts {
}
function packageIdIsEqual(a: PackageId | undefined, b: PackageId | undefined): boolean {
return a === b || a && b && a.name === b.name && a.version === b.version;
return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
}
export function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean {

View file

@ -198,33 +198,34 @@ namespace ts {
const moduleFile = { name: "/a/b/node_modules/foo.ts" };
const resolution = nodeModuleNameResolver("foo", containingFile.name, {}, createModuleResolutionHost(hasDirectoryExists, containingFile, moduleFile));
checkResolvedModuleWithFailedLookupLocations(resolution, createResolvedModule(moduleFile.name, /*isExternalLibraryImport*/ true), [
"/a/b/c/d/node_modules/foo/package.json",
"/a/b/c/d/node_modules/foo.ts",
"/a/b/c/d/node_modules/foo.tsx",
"/a/b/c/d/node_modules/foo.d.ts",
"/a/b/c/d/node_modules/foo/package.json",
"/a/b/c/d/node_modules/foo/index.ts",
"/a/b/c/d/node_modules/foo/index.tsx",
"/a/b/c/d/node_modules/foo/index.d.ts",
"/a/b/c/d/node_modules/@types/foo.d.ts",
"/a/b/c/d/node_modules/@types/foo/package.json",
"/a/b/c/d/node_modules/@types/foo.d.ts",
"/a/b/c/d/node_modules/@types/foo/index.d.ts",
"/a/b/c/node_modules/foo/package.json",
"/a/b/c/node_modules/foo.ts",
"/a/b/c/node_modules/foo.tsx",
"/a/b/c/node_modules/foo.d.ts",
"/a/b/c/node_modules/foo/package.json",
"/a/b/c/node_modules/foo/index.ts",
"/a/b/c/node_modules/foo/index.tsx",
"/a/b/c/node_modules/foo/index.d.ts",
"/a/b/c/node_modules/@types/foo.d.ts",
"/a/b/c/node_modules/@types/foo/package.json",
"/a/b/c/node_modules/@types/foo.d.ts",
"/a/b/c/node_modules/@types/foo/index.d.ts",
"/a/b/node_modules/foo/package.json",
]);
}
});
@ -250,52 +251,52 @@ namespace ts {
const moduleFile: File = { name: "/a/node_modules/foo/index.d.ts" };
const resolution = nodeModuleNameResolver("foo", containingFile.name, {}, createModuleResolutionHost(hasDirectoryExists, containingFile, moduleFile));
checkResolvedModuleWithFailedLookupLocations(resolution, createResolvedModule(moduleFile.name, /*isExternalLibraryImport*/ true), [
"/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json",
"/a/node_modules/b/c/node_modules/d/node_modules/foo.ts",
"/a/node_modules/b/c/node_modules/d/node_modules/foo.tsx",
"/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts",
"/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json",
"/a/node_modules/b/c/node_modules/d/node_modules/foo/index.ts",
"/a/node_modules/b/c/node_modules/d/node_modules/foo/index.tsx",
"/a/node_modules/b/c/node_modules/d/node_modules/foo/index.d.ts",
"/a/node_modules/b/c/node_modules/d/node_modules/@types/foo.d.ts",
"/a/node_modules/b/c/node_modules/d/node_modules/@types/foo/package.json",
"/a/node_modules/b/c/node_modules/d/node_modules/@types/foo.d.ts",
"/a/node_modules/b/c/node_modules/d/node_modules/@types/foo/index.d.ts",
"/a/node_modules/b/c/node_modules/foo/package.json",
"/a/node_modules/b/c/node_modules/foo.ts",
"/a/node_modules/b/c/node_modules/foo.tsx",
"/a/node_modules/b/c/node_modules/foo.d.ts",
"/a/node_modules/b/c/node_modules/foo/package.json",
"/a/node_modules/b/c/node_modules/foo/index.ts",
"/a/node_modules/b/c/node_modules/foo/index.tsx",
"/a/node_modules/b/c/node_modules/foo/index.d.ts",
"/a/node_modules/b/c/node_modules/@types/foo.d.ts",
"/a/node_modules/b/c/node_modules/@types/foo/package.json",
"/a/node_modules/b/c/node_modules/@types/foo.d.ts",
"/a/node_modules/b/c/node_modules/@types/foo/index.d.ts",
"/a/node_modules/b/node_modules/foo/package.json",
"/a/node_modules/b/node_modules/foo.ts",
"/a/node_modules/b/node_modules/foo.tsx",
"/a/node_modules/b/node_modules/foo.d.ts",
"/a/node_modules/b/node_modules/foo/package.json",
"/a/node_modules/b/node_modules/foo/index.ts",
"/a/node_modules/b/node_modules/foo/index.tsx",
"/a/node_modules/b/node_modules/foo/index.d.ts",
"/a/node_modules/b/node_modules/@types/foo.d.ts",
"/a/node_modules/b/node_modules/@types/foo/package.json",
"/a/node_modules/b/node_modules/@types/foo.d.ts",
"/a/node_modules/b/node_modules/@types/foo/index.d.ts",
"/a/node_modules/foo/package.json",
"/a/node_modules/foo.ts",
"/a/node_modules/foo.tsx",
"/a/node_modules/foo.d.ts",
"/a/node_modules/foo/package.json",
"/a/node_modules/foo/index.ts",
"/a/node_modules/foo/index.tsx"
@ -707,21 +708,23 @@ import b = require("./moduleB");
"/root/generated/file6/index.d.ts",
// fallback to standard node behavior
"/root/folder1/node_modules/file6/package.json",
// load from file
"/root/folder1/node_modules/file6.ts",
"/root/folder1/node_modules/file6.tsx",
"/root/folder1/node_modules/file6.d.ts",
// load from folder
"/root/folder1/node_modules/file6/package.json",
"/root/folder1/node_modules/file6/index.ts",
"/root/folder1/node_modules/file6/index.tsx",
"/root/folder1/node_modules/file6/index.d.ts",
"/root/folder1/node_modules/@types/file6.d.ts",
"/root/folder1/node_modules/@types/file6/package.json",
"/root/folder1/node_modules/@types/file6.d.ts",
"/root/folder1/node_modules/@types/file6/index.d.ts",
"/root/node_modules/file6/package.json",
// success on /root/node_modules/file6.ts
], /*isExternalLibraryImport*/ true);

View file

@ -441,20 +441,20 @@ namespace ts {
"======== Resolving module 'a' from 'file1.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a.ts' does not exist.",
"File 'node_modules/a.tsx' does not exist.",
"File 'node_modules/a.d.ts' does not exist.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a/index.ts' does not exist.",
"File 'node_modules/a/index.tsx' does not exist.",
"File 'node_modules/a/index.d.ts' does not exist.",
"File 'node_modules/@types/a.d.ts' does not exist.",
"File 'node_modules/@types/a/package.json' does not exist.",
"File 'node_modules/@types/a.d.ts' does not exist.",
"File 'node_modules/@types/a/index.d.ts' does not exist.",
"Loading module 'a' from 'node_modules' folder, target file type 'JavaScript'.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a.js' does not exist.",
"File 'node_modules/a.jsx' does not exist.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a/index.js' does not exist.",
"File 'node_modules/a/index.jsx' does not exist.",
"======== Module name 'a' was not resolved. ========"
@ -474,10 +474,10 @@ namespace ts {
"======== Resolving module 'a' from 'file1.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a.ts' does not exist.",
"File 'node_modules/a.tsx' does not exist.",
"File 'node_modules/a.d.ts' does not exist.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a/index.ts' does not exist.",
"File 'node_modules/a/index.tsx' does not exist.",
"File 'node_modules/a/index.d.ts' exist - use it as a name resolution result.",
@ -510,14 +510,14 @@ namespace ts {
"File '/fs.ts' does not exist.",
"File '/fs.tsx' does not exist.",
"File '/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/package.json' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/package.json' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/b/fs.js' does not exist.",
"File '/a/b/fs.jsx' does not exist.",
@ -552,14 +552,14 @@ namespace ts {
"File '/fs.ts' does not exist.",
"File '/fs.tsx' does not exist.",
"File '/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/package.json' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/package.json' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/b/fs.js' does not exist.",
"File '/a/b/fs.jsx' does not exist.",

View file

@ -2510,8 +2510,8 @@ namespace ts.projectSystem {
"======== Module name 'lib' was not resolved. ========",
`Auto discovery for typings is enabled in project '${proj.getProjectName()}'. Running extra resolution pass for module 'lib' using cache location '/a/cache'.`,
"File '/a/cache/node_modules/lib.d.ts' does not exist.",
"File '/a/cache/node_modules/@types/lib.d.ts' does not exist.",
"File '/a/cache/node_modules/@types/lib/package.json' does not exist.",
"File '/a/cache/node_modules/@types/lib.d.ts' does not exist.",
"File '/a/cache/node_modules/@types/lib/index.d.ts' exist - use it as a name resolution result.",
]);
checkProjectActualFiles(proj, [file1.path, lib.path]);

View file

@ -0,0 +1,22 @@
//// [tests/cases/compiler/duplicatePackage_packageIdIncludesSubModule.ts] ////
//// [Foo.d.ts]
export default class Foo {
protected source: boolean;
}
//// [Bar.d.ts]
// This is *not* the same!
export const x: number;
//// [package.json]
{ "name": "foo", "version": "1.2.3" }
//// [index.ts]
import Foo from "foo/Foo";
import { x } from "foo/Bar";
//// [index.js]
"use strict";
exports.__esModule = true;

View file

@ -0,0 +1,20 @@
=== /index.ts ===
import Foo from "foo/Foo";
>Foo : Symbol(Foo, Decl(index.ts, 0, 6))
import { x } from "foo/Bar";
>x : Symbol(x, Decl(index.ts, 1, 8))
=== /node_modules/foo/Foo.d.ts ===
export default class Foo {
>Foo : Symbol(Foo, Decl(Foo.d.ts, 0, 0))
protected source: boolean;
>source : Symbol(Foo.source, Decl(Foo.d.ts, 0, 26))
}
=== /node_modules/foo/Bar.d.ts ===
// This is *not* the same!
export const x: number;
>x : Symbol(x, Decl(Bar.d.ts, 1, 12))

View file

@ -0,0 +1,20 @@
=== /index.ts ===
import Foo from "foo/Foo";
>Foo : typeof Foo
import { x } from "foo/Bar";
>x : number
=== /node_modules/foo/Foo.d.ts ===
export default class Foo {
>Foo : Foo
protected source: boolean;
>source : boolean
}
=== /node_modules/foo/Bar.d.ts ===
// This is *not* the same!
export const x: number;
>x : number

View file

@ -0,0 +1,31 @@
//// [tests/cases/compiler/duplicatePackage_referenceTypes.ts] ////
//// [index.d.ts]
/// <reference types="foo" />
import { Foo } from "foo";
export const foo: Foo;
//// [index.d.ts]
export class Foo { private x; }
//// [package.json]
{ "name": "foo", "version": "1.2.3" }
//// [index.d.ts]
export class Foo { private x; }
//// [package.json]
{ "name": "foo", "version": "1.2.3" }
//// [index.ts]
import * as a from "a";
import { Foo } from "foo";
let foo: Foo = a.foo;
//// [index.js]
"use strict";
exports.__esModule = true;
var a = require("a");
var foo = a.foo;

View file

@ -0,0 +1,33 @@
=== /index.ts ===
import * as a from "a";
>a : Symbol(a, Decl(index.ts, 0, 6))
import { Foo } from "foo";
>Foo : Symbol(Foo, Decl(index.ts, 1, 8))
let foo: Foo = a.foo;
>foo : Symbol(foo, Decl(index.ts, 3, 3))
>Foo : Symbol(Foo, Decl(index.ts, 1, 8))
>a.foo : Symbol(a.foo, Decl(index.d.ts, 2, 12))
>a : Symbol(a, Decl(index.ts, 0, 6))
>foo : Symbol(a.foo, Decl(index.d.ts, 2, 12))
=== /node_modules/a/index.d.ts ===
/// <reference types="foo" />
import { Foo } from "foo";
>Foo : Symbol(Foo, Decl(index.d.ts, 1, 8))
export const foo: Foo;
>foo : Symbol(foo, Decl(index.d.ts, 2, 12))
>Foo : Symbol(Foo, Decl(index.d.ts, 1, 8))
=== /node_modules/a/node_modules/foo/index.d.ts ===
export class Foo { private x; }
>Foo : Symbol(Foo, Decl(index.d.ts, 0, 0))
>x : Symbol(Foo.x, Decl(index.d.ts, 0, 18))
=== /node_modules/@types/foo/index.d.ts ===
export class Foo { private x; }
>Foo : Symbol(Foo, Decl(index.d.ts, 0, 0))
>x : Symbol(Foo.x, Decl(index.d.ts, 0, 18))

View file

@ -0,0 +1,33 @@
=== /index.ts ===
import * as a from "a";
>a : typeof a
import { Foo } from "foo";
>Foo : typeof Foo
let foo: Foo = a.foo;
>foo : Foo
>Foo : Foo
>a.foo : Foo
>a : typeof a
>foo : Foo
=== /node_modules/a/index.d.ts ===
/// <reference types="foo" />
import { Foo } from "foo";
>Foo : typeof Foo
export const foo: Foo;
>foo : Foo
>Foo : Foo
=== /node_modules/a/node_modules/foo/index.d.ts ===
export class Foo { private x; }
>Foo : Foo
>x : any
=== /node_modules/@types/foo/index.d.ts ===
export class Foo { private x; }
>Foo : Foo
>x : any

View file

@ -0,0 +1,34 @@
//// [tests/cases/compiler/duplicatePackage_subModule.ts] ////
//// [index.d.ts]
import Foo from "foo/Foo";
export const o: Foo;
//// [Foo.d.ts]
export default class Foo {
protected source: boolean;
}
//// [package.json]
{ "name": "foo", "version": "1.2.3" }
//// [Foo.d.ts]
export default class Foo {
protected source: boolean;
}
//// [package.json]
{ "name": "foo", "version": "1.2.3" }
//// [index.ts]
import Foo from "foo/Foo";
import * as a from "a";
const o: Foo = a.o;
//// [index.js]
"use strict";
exports.__esModule = true;
var a = require("a");
var o = a.o;

View file

@ -0,0 +1,38 @@
=== /index.ts ===
import Foo from "foo/Foo";
>Foo : Symbol(Foo, Decl(index.ts, 0, 6))
import * as a from "a";
>a : Symbol(a, Decl(index.ts, 1, 6))
const o: Foo = a.o;
>o : Symbol(o, Decl(index.ts, 3, 5))
>Foo : Symbol(Foo, Decl(index.ts, 0, 6))
>a.o : Symbol(a.o, Decl(index.d.ts, 1, 12))
>a : Symbol(a, Decl(index.ts, 1, 6))
>o : Symbol(a.o, Decl(index.d.ts, 1, 12))
=== /node_modules/a/index.d.ts ===
import Foo from "foo/Foo";
>Foo : Symbol(Foo, Decl(index.d.ts, 0, 6))
export const o: Foo;
>o : Symbol(o, Decl(index.d.ts, 1, 12))
>Foo : Symbol(Foo, Decl(index.d.ts, 0, 6))
=== /node_modules/a/node_modules/foo/Foo.d.ts ===
export default class Foo {
>Foo : Symbol(Foo, Decl(Foo.d.ts, 0, 0))
protected source: boolean;
>source : Symbol(Foo.source, Decl(Foo.d.ts, 0, 26))
}
=== /node_modules/foo/Foo.d.ts ===
export default class Foo {
>Foo : Symbol(Foo, Decl(Foo.d.ts, 0, 0))
protected source: boolean;
>source : Symbol(Foo.source, Decl(Foo.d.ts, 0, 26))
}

View file

@ -0,0 +1,38 @@
=== /index.ts ===
import Foo from "foo/Foo";
>Foo : typeof Foo
import * as a from "a";
>a : typeof a
const o: Foo = a.o;
>o : Foo
>Foo : Foo
>a.o : Foo
>a : typeof a
>o : Foo
=== /node_modules/a/index.d.ts ===
import Foo from "foo/Foo";
>Foo : typeof Foo
export const o: Foo;
>o : Foo
>Foo : Foo
=== /node_modules/a/node_modules/foo/Foo.d.ts ===
export default class Foo {
>Foo : Foo
protected source: boolean;
>source : boolean
}
=== /node_modules/foo/Foo.d.ts ===
export default class Foo {
>Foo : Foo
protected source: boolean;
>source : boolean
}

View file

@ -3,8 +3,8 @@
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/a/b'.",
"Directory '/a/b/node_modules' does not exist, skipping all lookups in it.",
"File '/a/node_modules/jquery.d.ts' does not exist.",
"Found 'package.json' at '/a/node_modules/jquery/package.json'.",
"File '/a/node_modules/jquery.d.ts' does not exist.",
"'package.json' has 'typings' field 'jquery.d.ts' that references '/a/node_modules/jquery/jquery.d.ts'.",
"File '/a/node_modules/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/a/node_modules/jquery/jquery.d.ts', result '/a/node_modules/jquery/jquery.d.ts'.",

View file

@ -3,8 +3,8 @@
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/a/b'.",
"Directory '/a/b/node_modules' does not exist, skipping all lookups in it.",
"File '/a/node_modules/jquery.d.ts' does not exist.",
"Found 'package.json' at '/a/node_modules/jquery/package.json'.",
"File '/a/node_modules/jquery.d.ts' does not exist.",
"'package.json' does not have a 'typings' field.",
"'package.json' has 'types' field 'dist/jquery.d.ts' that references '/a/node_modules/jquery/dist/jquery.d.ts'.",
"File '/a/node_modules/jquery/dist/jquery.d.ts' exist - use it as a name resolution result.",

View file

@ -2,8 +2,8 @@
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"File '/src/node_modules/jquery.d.ts' does not exist.",
"File '/src/node_modules/jquery/package.json' does not exist.",
"File '/src/node_modules/jquery.d.ts' does not exist.",
"File '/src/node_modules/jquery/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/node_modules/jquery/index.d.ts', result '/src/node_modules/jquery/index.d.ts'.",
"======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: false. ========"

View file

@ -3,8 +3,8 @@
"Resolving with primary search path '/src'.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"Directory '/src/node_modules' does not exist, skipping all lookups in it.",
"File '/node_modules/foo.d.ts' does not exist.",
"File '/node_modules/foo/package.json' does not exist.",
"File '/node_modules/foo.d.ts' does not exist.",
"File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/foo/index.d.ts', result '/node_modules/foo/index.d.ts'.",
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========",
@ -12,24 +12,24 @@
"Resolving with primary search path '/src'.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"Directory '/src/node_modules' does not exist, skipping all lookups in it.",
"File '/node_modules/bar.d.ts' does not exist.",
"File '/node_modules/bar/package.json' does not exist.",
"File '/node_modules/bar.d.ts' does not exist.",
"File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/bar/index.d.ts', result '/node_modules/bar/index.d.ts'.",
"======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory '/src'. ========",
"Resolving with primary search path '/src'.",
"Looking up in 'node_modules' folder, initial location '/node_modules/foo'.",
"File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/foo/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/foo/node_modules/alpha/index.d.ts', result '/node_modules/foo/node_modules/alpha/index.d.ts'.",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory '/src'. ========",
"Resolving with primary search path '/src'.",
"Looking up in 'node_modules' folder, initial location '/node_modules/bar'.",
"File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/bar/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/bar/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'.",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========"

View file

@ -4,8 +4,8 @@
"Directory 'types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"Directory '/src/node_modules' does not exist, skipping all lookups in it.",
"File '/node_modules/foo.d.ts' does not exist.",
"File '/node_modules/foo/package.json' does not exist.",
"File '/node_modules/foo.d.ts' does not exist.",
"File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/foo/index.d.ts', result '/node_modules/foo/index.d.ts'.",
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========",
@ -14,8 +14,8 @@
"Directory 'types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"Directory '/src/node_modules' does not exist, skipping all lookups in it.",
"File '/node_modules/bar.d.ts' does not exist.",
"File '/node_modules/bar/package.json' does not exist.",
"File '/node_modules/bar.d.ts' does not exist.",
"File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/bar/index.d.ts', result '/node_modules/bar/index.d.ts'.",
"======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========",
@ -23,8 +23,8 @@
"Resolving with primary search path 'types'.",
"Directory 'types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/node_modules/foo'.",
"File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/foo/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/foo/node_modules/alpha/index.d.ts', result '/node_modules/foo/node_modules/alpha/index.d.ts'.",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========",
@ -32,8 +32,8 @@
"Resolving with primary search path 'types'.",
"Directory 'types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/node_modules/bar'.",
"File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/bar/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/bar/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'.",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========"

View file

@ -2,8 +2,8 @@
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"File '/src/node_modules/jquery.d.ts' does not exist.",
"File '/src/node_modules/jquery/package.json' does not exist.",
"File '/src/node_modules/jquery.d.ts' does not exist.",
"File '/src/node_modules/jquery/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/node_modules/jquery/index.d.ts', result '/src/node_modules/jquery/index.d.ts'.",
"======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: false. ========"

View file

@ -4,8 +4,8 @@
"Directory 'types/@beep' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/'.",
"Scoped package detected, looking in 'beep__boop'",
"File '/node_modules/@types/beep__boop.d.ts' does not exist.",
"File '/node_modules/@types/beep__boop/package.json' does not exist.",
"File '/node_modules/@types/beep__boop.d.ts' does not exist.",
"File '/node_modules/@types/beep__boop/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/beep__boop/index.d.ts', result '/node_modules/@types/beep__boop/index.d.ts'.",
"======== Type reference directive '@beep/boop' was successfully resolved to '/node_modules/@types/beep__boop/index.d.ts', primary: false. ========"

View file

@ -2,18 +2,18 @@
"======== Resolving module 'shortid' from '/index.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module 'shortid' from 'node_modules' folder, target file type 'TypeScript'.",
"File '/node_modules/shortid/package.json' does not exist.",
"File '/node_modules/shortid.ts' does not exist.",
"File '/node_modules/shortid.tsx' does not exist.",
"File '/node_modules/shortid.d.ts' does not exist.",
"File '/node_modules/shortid/package.json' does not exist.",
"File '/node_modules/shortid/index.ts' does not exist.",
"File '/node_modules/shortid/index.tsx' does not exist.",
"File '/node_modules/shortid/index.d.ts' does not exist.",
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Loading module 'shortid' from 'node_modules' folder, target file type 'JavaScript'.",
"File '/node_modules/shortid/package.json' does not exist.",
"File '/node_modules/shortid.js' does not exist.",
"File '/node_modules/shortid.jsx' does not exist.",
"File '/node_modules/shortid/package.json' does not exist.",
"File '/node_modules/shortid/index.js' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/shortid/index.js', result '/node_modules/shortid/index.js'.",
"======== Module name 'shortid' was successfully resolved to '/node_modules/shortid/index.js'. ========"

View file

@ -2,10 +2,10 @@
"======== Resolving module 'normalize.css' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'normalize.css' from 'node_modules' folder, target file type 'TypeScript'.",
"Found 'package.json' at '/node_modules/normalize.css/package.json'.",
"File '/node_modules/normalize.css.ts' does not exist.",
"File '/node_modules/normalize.css.tsx' does not exist.",
"File '/node_modules/normalize.css.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/normalize.css/package.json'.",
"'package.json' does not have a 'typings' field.",
"'package.json' does not have a 'types' field.",
"File '/node_modules/normalize.css/index.ts' does not exist.",
@ -13,9 +13,9 @@
"File '/node_modules/normalize.css/index.d.ts' does not exist.",
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Loading module 'normalize.css' from 'node_modules' folder, target file type 'JavaScript'.",
"Found 'package.json' at '/node_modules/normalize.css/package.json'.",
"File '/node_modules/normalize.css.js' does not exist.",
"File '/node_modules/normalize.css.jsx' does not exist.",
"Found 'package.json' at '/node_modules/normalize.css/package.json'.",
"'package.json' has 'main' field 'normalize.css' that references '/node_modules/normalize.css/normalize.css'.",
"File '/node_modules/normalize.css/normalize.css' exist - use it as a name resolution result.",
"File '/node_modules/normalize.css/normalize.css' has an unsupported extension, so skipping it.",

View file

@ -2,10 +2,10 @@
"======== Resolving module 'foo' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"File '/node_modules/foo.ts' does not exist.",
"File '/node_modules/foo.tsx' does not exist.",
"File '/node_modules/foo.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"'package.json' does not have a 'typings' field.",
"'package.json' has 'types' field 'foo.js' that references '/node_modules/foo/foo.js'.",
"File '/node_modules/foo/foo.js' exist - use it as a name resolution result.",
@ -24,9 +24,9 @@
"File '/node_modules/foo/index.d.ts' does not exist.",
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"File '/node_modules/foo.js' does not exist.",
"File '/node_modules/foo.jsx' does not exist.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"'package.json' does not have a 'main' field.",
"File '/node_modules/foo/index.js' does not exist.",
"File '/node_modules/foo/index.jsx' does not exist.",

View file

@ -2,18 +2,18 @@
"======== Resolving module 'js' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'js' from 'node_modules' folder, target file type 'TypeScript'.",
"File '/node_modules/js/package.json' does not exist.",
"File '/node_modules/js.ts' does not exist.",
"File '/node_modules/js.tsx' does not exist.",
"File '/node_modules/js.d.ts' does not exist.",
"File '/node_modules/js/package.json' does not exist.",
"File '/node_modules/js/index.ts' does not exist.",
"File '/node_modules/js/index.tsx' does not exist.",
"File '/node_modules/js/index.d.ts' does not exist.",
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Loading module 'js' from 'node_modules' folder, target file type 'JavaScript'.",
"File '/node_modules/js/package.json' does not exist.",
"File '/node_modules/js.js' does not exist.",
"File '/node_modules/js.jsx' does not exist.",
"File '/node_modules/js/package.json' does not exist.",
"File '/node_modules/js/index.js' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/js/index.js', result '/node_modules/js/index.js'.",
"======== Module name 'js' was successfully resolved to '/node_modules/js/index.js'. ========"

View file

@ -20,10 +20,10 @@
"======== Resolving module 'library-a' from '/src/library-b/index.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'library-a' from 'node_modules' folder, target file type 'TypeScript'.",
"File '/src/library-b/node_modules/library-a/package.json' does not exist.",
"File '/src/library-b/node_modules/library-a.ts' does not exist.",
"File '/src/library-b/node_modules/library-a.tsx' does not exist.",
"File '/src/library-b/node_modules/library-a.d.ts' does not exist.",
"File '/src/library-b/node_modules/library-a/package.json' does not exist.",
"File '/src/library-b/node_modules/library-a/index.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/library-b/node_modules/library-a/index.ts', result '/src/library-a/index.ts'.",
"======== Module name 'library-a' was successfully resolved to '/src/library-a/index.ts'. ========"

View file

@ -2,18 +2,18 @@
"======== Resolving type reference directive 'linked', containing file '/app/app.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/app'.",
"File '/app/node_modules/linked.d.ts' does not exist.",
"File '/app/node_modules/linked/package.json' does not exist.",
"File '/app/node_modules/linked.d.ts' does not exist.",
"File '/app/node_modules/linked/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'linked' was successfully resolved to '/app/node_modules/linked/index.d.ts', primary: false. ========",
"======== Resolving module 'real' from '/app/node_modules/linked/index.d.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module 'real' from 'node_modules' folder, target file type 'TypeScript'.",
"Directory '/app/node_modules/linked/node_modules' does not exist, skipping all lookups in it.",
"File '/app/node_modules/real/package.json' does not exist.",
"File '/app/node_modules/real.ts' does not exist.",
"File '/app/node_modules/real.tsx' does not exist.",
"File '/app/node_modules/real.d.ts' does not exist.",
"File '/app/node_modules/real/package.json' does not exist.",
"File '/app/node_modules/real/index.ts' does not exist.",
"File '/app/node_modules/real/index.tsx' does not exist.",
"File '/app/node_modules/real/index.d.ts' exist - use it as a name resolution result.",
@ -21,10 +21,10 @@
"======== Resolving module 'linked' from '/app/app.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module 'linked' from 'node_modules' folder, target file type 'TypeScript'.",
"File '/app/node_modules/linked/package.json' does not exist.",
"File '/app/node_modules/linked.ts' does not exist.",
"File '/app/node_modules/linked.tsx' does not exist.",
"File '/app/node_modules/linked.d.ts' does not exist.",
"File '/app/node_modules/linked/package.json' does not exist.",
"File '/app/node_modules/linked/index.ts' does not exist.",
"File '/app/node_modules/linked/index.tsx' does not exist.",
"File '/app/node_modules/linked/index.d.ts' exist - use it as a name resolution result.",
@ -32,10 +32,10 @@
"======== Resolving module 'linked2' from '/app/app.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module 'linked2' from 'node_modules' folder, target file type 'TypeScript'.",
"File '/app/node_modules/linked2/package.json' does not exist.",
"File '/app/node_modules/linked2.ts' does not exist.",
"File '/app/node_modules/linked2.tsx' does not exist.",
"File '/app/node_modules/linked2.d.ts' does not exist.",
"File '/app/node_modules/linked2/package.json' does not exist.",
"File '/app/node_modules/linked2/index.ts' does not exist.",
"File '/app/node_modules/linked2/index.tsx' does not exist.",
"File '/app/node_modules/linked2/index.d.ts' exist - use it as a name resolution result.",
@ -44,10 +44,10 @@
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module 'real' from 'node_modules' folder, target file type 'TypeScript'.",
"Directory '/app/node_modules/linked2/node_modules' does not exist, skipping all lookups in it.",
"File '/app/node_modules/real/package.json' does not exist.",
"File '/app/node_modules/real.ts' does not exist.",
"File '/app/node_modules/real.tsx' does not exist.",
"File '/app/node_modules/real.d.ts' does not exist.",
"File '/app/node_modules/real/package.json' does not exist.",
"File '/app/node_modules/real/index.ts' does not exist.",
"File '/app/node_modules/real/index.tsx' does not exist.",
"File '/app/node_modules/real/index.d.ts' exist - use it as a name resolution result.",

View file

@ -3,8 +3,8 @@
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/'.",
"File '/node_modules/library-a.d.ts' does not exist.",
"File '/node_modules/@types/library-a.d.ts' does not exist.",
"File '/node_modules/@types/library-a/package.json' does not exist.",
"File '/node_modules/@types/library-a.d.ts' does not exist.",
"File '/node_modules/@types/library-a/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/library-a/index.d.ts', result '/node_modules/@types/library-a/index.d.ts'.",
"======== Type reference directive 'library-a' was successfully resolved to '/node_modules/@types/library-a/index.d.ts', primary: false. ========",
@ -12,8 +12,8 @@
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/'.",
"File '/node_modules/library-b.d.ts' does not exist.",
"File '/node_modules/@types/library-b.d.ts' does not exist.",
"File '/node_modules/@types/library-b/package.json' does not exist.",
"File '/node_modules/@types/library-b.d.ts' does not exist.",
"File '/node_modules/@types/library-b/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/library-b/index.d.ts', result '/node_modules/@types/library-b/index.d.ts'.",
"======== Type reference directive 'library-b' was successfully resolved to '/node_modules/@types/library-b/index.d.ts', primary: false. ========",
@ -21,8 +21,8 @@
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/node_modules/@types/library-b'.",
"File '/node_modules/@types/library-b/node_modules/library-a.d.ts' does not exist.",
"File '/node_modules/@types/library-b/node_modules/@types/library-a.d.ts' does not exist.",
"File '/node_modules/@types/library-b/node_modules/@types/library-a/package.json' does not exist.",
"File '/node_modules/@types/library-b/node_modules/@types/library-a.d.ts' does not exist.",
"File '/node_modules/@types/library-b/node_modules/@types/library-a/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/library-b/node_modules/@types/library-a/index.d.ts', result '/node_modules/@types/library-a/index.d.ts'.",
"======== Type reference directive 'library-a' was successfully resolved to '/node_modules/@types/library-a/index.d.ts', primary: false. ========"

View file

@ -20,10 +20,10 @@
"======== Resolving module 'library-a' from '/src/library-b/index.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'library-a' from 'node_modules' folder, target file type 'TypeScript'.",
"File '/src/library-b/node_modules/library-a/package.json' does not exist.",
"File '/src/library-b/node_modules/library-a.ts' does not exist.",
"File '/src/library-b/node_modules/library-a.tsx' does not exist.",
"File '/src/library-b/node_modules/library-a.d.ts' does not exist.",
"File '/src/library-b/node_modules/library-a/package.json' does not exist.",
"File '/src/library-b/node_modules/library-a/index.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/library-b/node_modules/library-a/index.ts', result '/src/library-a/index.ts'.",
"======== Module name 'library-a' was successfully resolved to '/src/library-a/index.ts'. ========"

View file

@ -2,10 +2,10 @@
"======== Resolving module 'foo' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"File '/node_modules/foo.ts' does not exist.",
"File '/node_modules/foo.tsx' does not exist.",
"File '/node_modules/foo.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"'package.json' does not have a 'typings' field.",
"'package.json' does not have a 'types' field.",
"File '/node_modules/foo/index.ts' does not exist.",
@ -13,9 +13,9 @@
"File '/node_modules/foo/index.d.ts' does not exist.",
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"File '/node_modules/foo.js' does not exist.",
"File '/node_modules/foo.jsx' does not exist.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.",
"File '/node_modules/foo/oof' does not exist.",
"Loading module as file / folder, candidate module location '/node_modules/foo/oof', target file type 'JavaScript'.",
@ -25,10 +25,10 @@
"======== Resolving module 'bar' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'bar' from 'node_modules' folder, target file type 'TypeScript'.",
"Found 'package.json' at '/node_modules/bar/package.json'.",
"File '/node_modules/bar.ts' does not exist.",
"File '/node_modules/bar.tsx' does not exist.",
"File '/node_modules/bar.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/bar/package.json'.",
"'package.json' does not have a 'typings' field.",
"'package.json' does not have a 'types' field.",
"File '/node_modules/bar/index.ts' does not exist.",
@ -36,9 +36,9 @@
"File '/node_modules/bar/index.d.ts' does not exist.",
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Loading module 'bar' from 'node_modules' folder, target file type 'JavaScript'.",
"Found 'package.json' at '/node_modules/bar/package.json'.",
"File '/node_modules/bar.js' does not exist.",
"File '/node_modules/bar.jsx' does not exist.",
"Found 'package.json' at '/node_modules/bar/package.json'.",
"'package.json' has 'main' field 'rab.js' that references '/node_modules/bar/rab.js'.",
"File '/node_modules/bar/rab.js' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/bar/rab.js', result '/node_modules/bar/rab.js'.",
@ -46,10 +46,10 @@
"======== Resolving module 'baz' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'baz' from 'node_modules' folder, target file type 'TypeScript'.",
"Found 'package.json' at '/node_modules/baz/package.json'.",
"File '/node_modules/baz.ts' does not exist.",
"File '/node_modules/baz.tsx' does not exist.",
"File '/node_modules/baz.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/baz/package.json'.",
"'package.json' does not have a 'typings' field.",
"'package.json' does not have a 'types' field.",
"File '/node_modules/baz/index.ts' does not exist.",
@ -57,9 +57,9 @@
"File '/node_modules/baz/index.d.ts' does not exist.",
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Loading module 'baz' from 'node_modules' folder, target file type 'JavaScript'.",
"Found 'package.json' at '/node_modules/baz/package.json'.",
"File '/node_modules/baz.js' does not exist.",
"File '/node_modules/baz.jsx' does not exist.",
"Found 'package.json' at '/node_modules/baz/package.json'.",
"'package.json' has 'main' field 'zab' that references '/node_modules/baz/zab'.",
"File '/node_modules/baz/zab' does not exist.",
"Loading module as file / folder, candidate module location '/node_modules/baz/zab', target file type 'JavaScript'.",

View file

@ -2,10 +2,10 @@
"======== Resolving module 'foo' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"File '/node_modules/foo.ts' does not exist.",
"File '/node_modules/foo.tsx' does not exist.",
"File '/node_modules/foo.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"'package.json' does not have a 'typings' field.",
"'package.json' does not have a 'types' field.",
"File '/node_modules/foo/index.ts' does not exist.",
@ -13,9 +13,9 @@
"File '/node_modules/foo/index.d.ts' does not exist.",
"Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"File '/node_modules/foo.js' does not exist.",
"File '/node_modules/foo.jsx' does not exist.",
"Found 'package.json' at '/node_modules/foo/package.json'.",
"'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.",
"File '/node_modules/foo/oof' does not exist.",
"Loading module as file / folder, candidate module location '/node_modules/foo/oof', target file type 'JavaScript'.",

View file

@ -23,10 +23,10 @@
"Loading module 'file4' from 'node_modules' folder, target file type 'TypeScript'.",
"Directory 'c:/root/folder2/node_modules' does not exist, skipping all lookups in it.",
"Directory 'c:/root/node_modules' does not exist, skipping all lookups in it.",
"File 'c:/node_modules/file4/package.json' does not exist.",
"File 'c:/node_modules/file4.ts' does not exist.",
"File 'c:/node_modules/file4.tsx' does not exist.",
"File 'c:/node_modules/file4.d.ts' does not exist.",
"File 'c:/node_modules/file4/package.json' does not exist.",
"File 'c:/node_modules/file4/index.ts' does not exist.",
"File 'c:/node_modules/file4/index.tsx' does not exist.",
"File 'c:/node_modules/file4/index.d.ts' exist - use it as a name resolution result.",

View file

@ -23,10 +23,10 @@
"Loading module 'file4' from 'node_modules' folder, target file type 'TypeScript'.",
"Directory 'c:/root/folder2/node_modules' does not exist, skipping all lookups in it.",
"Directory 'c:/root/node_modules' does not exist, skipping all lookups in it.",
"File 'c:/node_modules/file4/package.json' does not exist.",
"File 'c:/node_modules/file4.ts' does not exist.",
"File 'c:/node_modules/file4.tsx' does not exist.",
"File 'c:/node_modules/file4.d.ts' does not exist.",
"File 'c:/node_modules/file4/package.json' does not exist.",
"File 'c:/node_modules/file4/index.ts' does not exist.",
"File 'c:/node_modules/file4/index.tsx' does not exist.",
"File 'c:/node_modules/file4/index.d.ts' exist - use it as a name resolution result.",

View file

@ -2,10 +2,10 @@
"======== Resolving module '@cow/boy' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module '@cow/boy' from 'node_modules' folder, target file type 'TypeScript'.",
"File '/node_modules/@cow/package.json' does not exist.",
"File '/node_modules/@cow/boy.ts' does not exist.",
"File '/node_modules/@cow/boy.tsx' does not exist.",
"File '/node_modules/@cow/boy.d.ts' does not exist.",
"File '/node_modules/@cow/boy/package.json' does not exist.",
"File '/node_modules/@cow/boy/index.ts' does not exist.",
"File '/node_modules/@cow/boy/index.tsx' does not exist.",
"File '/node_modules/@cow/boy/index.d.ts' exist - use it as a name resolution result.",
@ -15,8 +15,8 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module '@be/bop' from 'node_modules' folder, target file type 'TypeScript'.",
"Scoped package detected, looking in 'be__bop'",
"File '/node_modules/@types/be__bop.d.ts' does not exist.",
"File '/node_modules/@types/be__bop/package.json' does not exist.",
"File '/node_modules/@types/be__bop.d.ts' does not exist.",
"File '/node_modules/@types/be__bop/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/be__bop/index.d.ts', result '/node_modules/@types/be__bop/index.d.ts'.",
"======== Module name '@be/bop' was successfully resolved to '/node_modules/@types/be__bop/index.d.ts'. ========",
@ -24,6 +24,7 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module '@be/bop/e/z' from 'node_modules' folder, target file type 'TypeScript'.",
"Scoped package detected, looking in 'be__bop/e/z'",
"File '/node_modules/@types/be__bop/package.json' does not exist.",
"File '/node_modules/@types/be__bop/e/z.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/be__bop/e/z.d.ts', result '/node_modules/@types/be__bop/e/z.d.ts'.",
"======== Module name '@be/bop/e/z' was successfully resolved to '/node_modules/@types/be__bop/e/z.d.ts'. ========"

View file

@ -2,8 +2,8 @@
"======== Resolving module '@see/saw' from '/a.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"Scoped package detected, looking in 'see__saw'",
"File '/node_modules/@types/see__saw.d.ts' does not exist.",
"File '/node_modules/@types/see__saw/package.json' does not exist.",
"File '/node_modules/@types/see__saw.d.ts' does not exist.",
"File '/node_modules/@types/see__saw/index.d.ts' exist - use it as a name resolution result.",
"======== Module name '@see/saw' was successfully resolved to '/node_modules/@types/see__saw/index.d.ts'. ========"
]

View file

@ -5,8 +5,8 @@
"File '/node_modules/jquery.ts' does not exist.",
"File '/node_modules/jquery.tsx' does not exist.",
"File '/node_modules/jquery.d.ts' does not exist.",
"File '/node_modules/@types/jquery.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/@types/jquery/package.json'.",
"File '/node_modules/@types/jquery.d.ts' does not exist.",
"'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.",
"File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/jquery/jquery.d.ts', result '/node_modules/@types/jquery/jquery.d.ts'.",
@ -17,8 +17,8 @@
"File '/node_modules/kquery.ts' does not exist.",
"File '/node_modules/kquery.tsx' does not exist.",
"File '/node_modules/kquery.d.ts' does not exist.",
"File '/node_modules/@types/kquery.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/@types/kquery/package.json'.",
"File '/node_modules/@types/kquery.d.ts' does not exist.",
"'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.",
"File '/node_modules/@types/kquery/kquery' does not exist.",
"Loading module as file / folder, candidate module location '/node_modules/@types/kquery/kquery', target file type 'TypeScript'.",
@ -33,8 +33,8 @@
"File '/node_modules/lquery.ts' does not exist.",
"File '/node_modules/lquery.tsx' does not exist.",
"File '/node_modules/lquery.d.ts' does not exist.",
"File '/node_modules/@types/lquery.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/@types/lquery/package.json'.",
"File '/node_modules/@types/lquery.d.ts' does not exist.",
"'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.",
"File '/node_modules/@types/lquery/lquery' does not exist.",
"Loading module as file / folder, candidate module location '/node_modules/@types/lquery/lquery', target file type 'TypeScript'.",
@ -47,8 +47,8 @@
"File '/node_modules/mquery.ts' does not exist.",
"File '/node_modules/mquery.tsx' does not exist.",
"File '/node_modules/mquery.d.ts' does not exist.",
"File '/node_modules/@types/mquery.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/@types/mquery/package.json'.",
"File '/node_modules/@types/mquery.d.ts' does not exist.",
"'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.",
"File '/node_modules/@types/mquery/mquery' does not exist.",
"Loading module as file / folder, candidate module location '/node_modules/@types/mquery/mquery', target file type 'TypeScript'.",

View file

@ -11,8 +11,8 @@
"File '/b.tsx' does not exist.",
"File '/b.d.ts' does not exist.",
"Directory '/x/y/node_modules' does not exist, skipping all lookups in it.",
"File '/x/node_modules/@types/b.d.ts' does not exist.",
"File '/x/node_modules/@types/b/package.json' does not exist.",
"File '/x/node_modules/@types/b.d.ts' does not exist.",
"File '/x/node_modules/@types/b/index.d.ts' exist - use it as a name resolution result.",
"======== Module name 'b' was successfully resolved to '/x/node_modules/@types/b/index.d.ts'. ========",
"======== Resolving module 'a' from '/x/node_modules/@types/b/index.d.ts'. ========",
@ -35,8 +35,8 @@
"Directory '/x/node_modules/@types/b/node_modules' does not exist, skipping all lookups in it.",
"Directory '/x/node_modules/@types/node_modules' does not exist, skipping all lookups in it.",
"File '/x/node_modules/@types/a.d.ts' does not exist.",
"File '/node_modules/@types/a.d.ts' does not exist.",
"File '/node_modules/@types/a/package.json' does not exist.",
"File '/node_modules/@types/a.d.ts' does not exist.",
"File '/node_modules/@types/a/index.d.ts' exist - use it as a name resolution result.",
"======== Module name 'a' was successfully resolved to '/node_modules/@types/a/index.d.ts'. ========",
"======== Resolving type reference directive 'a', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",

View file

@ -0,0 +1,17 @@
// @noImplicitReferences: true
// @Filename: /node_modules/foo/Foo.d.ts
export default class Foo {
protected source: boolean;
}
// @Filename: /node_modules/foo/Bar.d.ts
// This is *not* the same!
export const x: number;
// @Filename: /node_modules/foo/package.json
{ "name": "foo", "version": "1.2.3" }
// @Filename: /index.ts
import Foo from "foo/Foo";
import { x } from "foo/Bar";

View file

@ -0,0 +1,24 @@
// @noImplicitReferences: true
// @Filename: /node_modules/a/index.d.ts
/// <reference types="foo" />
import { Foo } from "foo";
export const foo: Foo;
// @Filename: /node_modules/a/node_modules/foo/index.d.ts
export class Foo { private x; }
// @Filename: /node_modules/a/node_modules/foo/package.json
{ "name": "foo", "version": "1.2.3" }
// @Filename: /node_modules/@types/foo/index.d.ts
export class Foo { private x; }
// @Filename: /node_modules/@types/foo/package.json
{ "name": "foo", "version": "1.2.3" }
// @Filename: /index.ts
import * as a from "a";
import { Foo } from "foo";
let foo: Foo = a.foo;

View file

@ -0,0 +1,27 @@
// @noImplicitReferences: true
// @Filename: /node_modules/a/index.d.ts
import Foo from "foo/Foo";
export const o: Foo;
// @Filename: /node_modules/a/node_modules/foo/Foo.d.ts
export default class Foo {
protected source: boolean;
}
// @Filename: /node_modules/a/node_modules/foo/package.json
{ "name": "foo", "version": "1.2.3" }
// @Filename: /node_modules/foo/Foo.d.ts
export default class Foo {
protected source: boolean;
}
// @Filename: /node_modules/foo/package.json
{ "name": "foo", "version": "1.2.3" }
// @Filename: /index.ts
import Foo from "foo/Foo";
import * as a from "a";
const o: Foo = a.o;