Merge pull request #7775 from Microsoft/libraryDirectives-2
Library directives support
This commit is contained in:
commit
ac6224d600
118 changed files with 2552 additions and 334 deletions
|
@ -317,9 +317,32 @@ namespace ts {
|
|||
}
|
||||
},
|
||||
{
|
||||
name: "traceModuleResolution",
|
||||
name: "typesSearchPaths",
|
||||
type: "list",
|
||||
isTSConfigOnly: true,
|
||||
element: {
|
||||
name: "typesSearchPaths",
|
||||
type: "string",
|
||||
isFilePath: true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "typesRoot",
|
||||
type: "string"
|
||||
},
|
||||
{
|
||||
name: "types",
|
||||
type: "list",
|
||||
element: {
|
||||
name: "types",
|
||||
type: "string"
|
||||
},
|
||||
description: Diagnostics.Type_declaration_files_to_be_included_in_compilation
|
||||
},
|
||||
{
|
||||
name: "traceResolution",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Enable_tracing_of_the_module_resolution_process
|
||||
description: Diagnostics.Enable_tracing_of_the_name_resolution_process
|
||||
},
|
||||
{
|
||||
name: "allowJs",
|
||||
|
@ -641,6 +664,7 @@ namespace ts {
|
|||
const compilerOptions: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName);
|
||||
const options = extend(existingOptions, compilerOptions);
|
||||
const typingOptions: TypingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName);
|
||||
options.configFilePath = configFileName;
|
||||
|
||||
const fileNames = getFileNames(errors);
|
||||
|
||||
|
|
|
@ -1903,10 +1903,10 @@
|
|||
"category": "Error",
|
||||
"code": 2684
|
||||
},
|
||||
"The 'this' types of each signature are incompatible.": {
|
||||
"category": "Error",
|
||||
"code": 2685
|
||||
},
|
||||
"The 'this' types of each signature are incompatible.": {
|
||||
"category": "Error",
|
||||
"code": 2685
|
||||
},
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4000
|
||||
|
@ -2187,6 +2187,11 @@
|
|||
"category": "Error",
|
||||
"code": 4082
|
||||
},
|
||||
"Conflicting library definitions for '{0}' found at '{1}' and '{2}'. Copy the correct file to the 'typings' folder to resolve this conflict.": {
|
||||
"category": "Message",
|
||||
"code": 4090
|
||||
},
|
||||
|
||||
"The current host does not support the '{0}' option.": {
|
||||
"category": "Error",
|
||||
"code": 5001
|
||||
|
@ -2540,7 +2545,7 @@
|
|||
"category": "Message",
|
||||
"code": 6084
|
||||
},
|
||||
"Enable tracing of the module resolution process.": {
|
||||
"Enable tracing of the name resolution process.": {
|
||||
"category": "Message",
|
||||
"code": 6085
|
||||
},
|
||||
|
@ -2588,7 +2593,7 @@
|
|||
"category": "Message",
|
||||
"code": 6096
|
||||
},
|
||||
"File '{0}' exist - use it as a module resolution result.": {
|
||||
"File '{0}' exist - use it as a name resolution result.": {
|
||||
"category": "Message",
|
||||
"code": 6097
|
||||
},
|
||||
|
@ -2600,11 +2605,11 @@
|
|||
"category": "Message",
|
||||
"code": 6099
|
||||
},
|
||||
"'package.json' does not have 'typings' field.": {
|
||||
"'package.json' does not have 'types' field.": {
|
||||
"category": "Message",
|
||||
"code": 6100
|
||||
},
|
||||
"'package.json' has 'typings' field '{0}' that references '{1}'.": {
|
||||
"'package.json' has '{0}' field '{1}' that references '{2}'.": {
|
||||
"category": "Message",
|
||||
"code": 6101
|
||||
},
|
||||
|
@ -2620,7 +2625,7 @@
|
|||
"category": "Message",
|
||||
"code": 6104
|
||||
},
|
||||
"Expected type of 'typings' field in 'package.json' to be 'string', got '{0}'.": {
|
||||
"Expected type of '{0}' field in 'package.json' to be 'string', got '{1}'.": {
|
||||
"category": "Message",
|
||||
"code": 6105
|
||||
},
|
||||
|
@ -2662,8 +2667,60 @@
|
|||
},
|
||||
"Raise error on 'this' expressions with an implied 'any' type.": {
|
||||
"category": "Message",
|
||||
"code": 6115
|
||||
},
|
||||
"code": 6115
|
||||
},
|
||||
"======== Resolving type reference directive '{0}', containing file '{1}', root directory '{2}'. ========": {
|
||||
"category": "Message",
|
||||
"code": 6116
|
||||
},
|
||||
"Resolving using primary search paths...": {
|
||||
"category": "Message",
|
||||
"code": 6117
|
||||
},
|
||||
"Resolving from node_modules folder...": {
|
||||
"category": "Message",
|
||||
"code": 6118
|
||||
},
|
||||
"======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========": {
|
||||
"category": "Message",
|
||||
"code": 6119
|
||||
},
|
||||
"======== Type reference directive '{0}' was not resolved. ========": {
|
||||
"category": "Message",
|
||||
"code": 6120
|
||||
},
|
||||
"Resolving with primary search path '{0}'": {
|
||||
"category": "Message",
|
||||
"code": 6121
|
||||
},
|
||||
"Root directory cannot be determined, skipping primary search paths.": {
|
||||
"category": "Message",
|
||||
"code": 6122
|
||||
},
|
||||
"======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========": {
|
||||
"category": "Message",
|
||||
"code": 6123
|
||||
},
|
||||
"Type declaration files to be included in compilation.": {
|
||||
"category": "Message",
|
||||
"code": 6124
|
||||
},
|
||||
"Looking up in 'node_modules' folder, initial location '{0}'": {
|
||||
"category": "Message",
|
||||
"code": 6125
|
||||
},
|
||||
"Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder.": {
|
||||
"category": "Message",
|
||||
"code": 6126
|
||||
},
|
||||
"======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========": {
|
||||
"category": "Message",
|
||||
"code": 6127
|
||||
},
|
||||
"======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========": {
|
||||
"category": "Message",
|
||||
"code": 6128
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
|
|
|
@ -5509,6 +5509,7 @@ namespace ts {
|
|||
function processReferenceComments(sourceFile: SourceFile): void {
|
||||
const triviaScanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/false, LanguageVariant.Standard, sourceText);
|
||||
const referencedFiles: FileReference[] = [];
|
||||
const typeReferenceDirectives: FileReference[] = [];
|
||||
const amdDependencies: { path: string; name: string }[] = [];
|
||||
let amdModuleName: string;
|
||||
|
||||
|
@ -5535,7 +5536,12 @@ namespace ts {
|
|||
sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib;
|
||||
const diagnosticMessage = referencePathMatchResult.diagnosticMessage;
|
||||
if (fileReference) {
|
||||
referencedFiles.push(fileReference);
|
||||
if (referencePathMatchResult.isTypeReferenceDirective) {
|
||||
typeReferenceDirectives.push(fileReference);
|
||||
}
|
||||
else {
|
||||
referencedFiles.push(fileReference);
|
||||
}
|
||||
}
|
||||
if (diagnosticMessage) {
|
||||
parseDiagnostics.push(createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage));
|
||||
|
@ -5567,6 +5573,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
sourceFile.referencedFiles = referencedFiles;
|
||||
sourceFile.typeReferenceDirectives = typeReferenceDirectives;
|
||||
sourceFile.amdDependencies = amdDependencies;
|
||||
sourceFile.moduleName = amdModuleName;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,12 @@ namespace ts {
|
|||
|
||||
const emptyArray: any[] = [];
|
||||
|
||||
const defaultLibrarySearchPaths = [
|
||||
"types/",
|
||||
"node_modules/",
|
||||
"node_modules/@types/",
|
||||
];
|
||||
|
||||
export const version = "1.9.0";
|
||||
|
||||
export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string {
|
||||
|
@ -35,13 +41,58 @@ namespace ts {
|
|||
return normalizePath(referencedFileName);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: (fileName: string) => string): string {
|
||||
let commonPathComponents: string[];
|
||||
const failed = forEach(fileNames, sourceFile => {
|
||||
// Each file contributes into common source file path
|
||||
const sourcePathComponents = getNormalizedPathComponents(sourceFile, currentDirectory);
|
||||
sourcePathComponents.pop(); // The base file name is not part of the common directory path
|
||||
|
||||
if (!commonPathComponents) {
|
||||
// first file
|
||||
commonPathComponents = sourcePathComponents;
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) {
|
||||
if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) {
|
||||
if (i === 0) {
|
||||
// Failed to find any common path component
|
||||
return true;
|
||||
}
|
||||
|
||||
// New common path found that is 0 -> i-1
|
||||
commonPathComponents.length = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If the sourcePathComponents was shorter than the commonPathComponents, truncate to the sourcePathComponents
|
||||
if (sourcePathComponents.length < commonPathComponents.length) {
|
||||
commonPathComponents.length = sourcePathComponents.length;
|
||||
}
|
||||
});
|
||||
|
||||
// A common path can not be found when paths span multiple drives on windows, for example
|
||||
if (failed) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!commonPathComponents) { // Can happen when all input files are .d.ts files
|
||||
return currentDirectory;
|
||||
}
|
||||
|
||||
return getNormalizedPathFromPathComponents(commonPathComponents);
|
||||
}
|
||||
|
||||
function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void;
|
||||
function trace(host: ModuleResolutionHost, message: DiagnosticMessage): void {
|
||||
host.trace(formatMessage.apply(undefined, arguments));
|
||||
}
|
||||
|
||||
function isTraceEnabled(compilerOptions: CompilerOptions, host: ModuleResolutionHost): boolean {
|
||||
return compilerOptions.traceModuleResolution && host.trace !== undefined;
|
||||
return compilerOptions.traceResolution && host.trace !== undefined;
|
||||
}
|
||||
|
||||
function hasZeroOrOneAsteriskCharacter(str: string): boolean {
|
||||
|
@ -82,6 +133,160 @@ namespace ts {
|
|||
skipTsx: boolean;
|
||||
}
|
||||
|
||||
function tryReadTypesSection(packageJsonPath: string, baseDirectory: string, state: ModuleResolutionState): string {
|
||||
let jsonContent: { typings?: string, types?: string };
|
||||
try {
|
||||
const jsonText = state.host.readFile(packageJsonPath);
|
||||
jsonContent = jsonText ? <{ typings?: string, types?: string }>JSON.parse(jsonText) : {};
|
||||
}
|
||||
catch (e) {
|
||||
// gracefully handle if readFile fails or returns not JSON
|
||||
jsonContent = {};
|
||||
}
|
||||
|
||||
let typesFile: string;
|
||||
let fieldName: string;
|
||||
// first try to read content of 'typings' section (backward compatibility)
|
||||
if (jsonContent.typings) {
|
||||
if (typeof jsonContent.typings === "string") {
|
||||
fieldName = "typings";
|
||||
typesFile = jsonContent.typings;
|
||||
}
|
||||
else {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, "typings", typeof jsonContent.typings);
|
||||
}
|
||||
}
|
||||
}
|
||||
// then read 'types'
|
||||
if (!typesFile && jsonContent.types) {
|
||||
if (typeof jsonContent.types === "string") {
|
||||
fieldName = "types";
|
||||
typesFile = jsonContent.types;
|
||||
}
|
||||
else {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, "types", typeof jsonContent.types);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typesFile) {
|
||||
const typesFilePath = normalizePath(combinePaths(baseDirectory, typesFile));
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath);
|
||||
}
|
||||
return typesFilePath;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const typeReferenceExtensions = [".d.ts"];
|
||||
|
||||
/**
|
||||
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
|
||||
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
|
||||
* is assumed to be the same as root directory of the project.
|
||||
*/
|
||||
export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations {
|
||||
const traceEnabled = isTraceEnabled(options, host);
|
||||
const moduleResolutionState: ModuleResolutionState = {
|
||||
compilerOptions: options,
|
||||
host: host,
|
||||
skipTsx: true,
|
||||
traceEnabled
|
||||
};
|
||||
|
||||
// use typesRoot and fallback to directory that contains tsconfig if typesRoot is not set
|
||||
const rootDir = options.typesRoot || (options.configFilePath ? getDirectoryPath(options.configFilePath) : undefined);
|
||||
|
||||
if (traceEnabled) {
|
||||
if (containingFile === undefined) {
|
||||
if (rootDir === undefined) {
|
||||
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
|
||||
}
|
||||
else {
|
||||
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, rootDir);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (rootDir === undefined) {
|
||||
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
|
||||
}
|
||||
else {
|
||||
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, rootDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const failedLookupLocations: string[] = [];
|
||||
|
||||
// Check primary library paths
|
||||
if (rootDir !== undefined) {
|
||||
const effectivePrimarySearchPaths = options.typesSearchPaths || defaultLibrarySearchPaths;
|
||||
for (const searchPath of effectivePrimarySearchPaths) {
|
||||
const primaryPath = combinePaths(rootDir, searchPath);
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Resolving_with_primary_search_path_0, primaryPath);
|
||||
}
|
||||
const candidate = combinePaths(primaryPath, typeReferenceDirectiveName);
|
||||
const candidateDirectory = getDirectoryPath(candidate);
|
||||
const resolvedFile = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations,
|
||||
!directoryProbablyExists(candidateDirectory, host), moduleResolutionState);
|
||||
|
||||
if (resolvedFile) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, true);
|
||||
}
|
||||
return {
|
||||
resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolvedFile },
|
||||
failedLookupLocations
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths);
|
||||
}
|
||||
}
|
||||
|
||||
let resolvedFile: string;
|
||||
let initialLocationForSecondaryLookup: string;
|
||||
if (containingFile) {
|
||||
initialLocationForSecondaryLookup = getDirectoryPath(containingFile);
|
||||
}
|
||||
else {
|
||||
initialLocationForSecondaryLookup = rootDir;
|
||||
}
|
||||
|
||||
if (initialLocationForSecondaryLookup !== undefined) {
|
||||
// check secondary locations
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
||||
}
|
||||
resolvedFile = loadModuleFromNodeModules(typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState);
|
||||
if (traceEnabled) {
|
||||
if (resolvedFile) {
|
||||
trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false);
|
||||
}
|
||||
else {
|
||||
trace(host, Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder);
|
||||
}
|
||||
}
|
||||
return {
|
||||
resolvedTypeReferenceDirective: resolvedFile
|
||||
? { primary: false, resolvedFileName: resolvedFile }
|
||||
: undefined,
|
||||
failedLookupLocations
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
||||
if (traceEnabled) {
|
||||
|
@ -361,7 +566,7 @@ namespace ts {
|
|||
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
||||
|
||||
const failedLookupLocations: string[] = [];
|
||||
const state = {compilerOptions, host, traceEnabled, skipTsx: false};
|
||||
const state = { compilerOptions, host, traceEnabled, skipTsx: false };
|
||||
let resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName,
|
||||
failedLookupLocations, supportedExtensions, state);
|
||||
|
||||
|
@ -397,7 +602,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
/* @internal */
|
||||
export function directoryProbablyExists(directoryName: string, host: { directoryExists?: (directoryName: string) => boolean } ): boolean {
|
||||
export function directoryProbablyExists(directoryName: string, host: { directoryExists?: (directoryName: string) => boolean }): boolean {
|
||||
// if host does not support 'directoryExists' assume that directory will exist
|
||||
return !host.directoryExists || host.directoryExists(directoryName);
|
||||
}
|
||||
|
@ -407,6 +612,13 @@ namespace ts {
|
|||
* in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations.
|
||||
*/
|
||||
function loadModuleFromFile(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string {
|
||||
if (!onlyRecordFailures) {
|
||||
// check if containig folder exists - if it doesn't then just record failures for all supported extensions without disk probing
|
||||
const directory = getDirectoryPath(candidate);
|
||||
if (directory) {
|
||||
onlyRecordFailures = !directoryProbablyExists(directory, state.host);
|
||||
}
|
||||
}
|
||||
return forEach(extensions, tryLoad);
|
||||
|
||||
function tryLoad(ext: string): string {
|
||||
|
@ -416,7 +628,7 @@ namespace ts {
|
|||
const fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
|
||||
if (!onlyRecordFailures && state.host.fileExists(fileName)) {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.File_0_exist_use_it_as_a_module_resolution_result, fileName);
|
||||
trace(state.host, Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName);
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
@ -437,36 +649,16 @@ namespace ts {
|
|||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Found_package_json_at_0, packageJsonPath);
|
||||
}
|
||||
|
||||
let jsonContent: { typings?: string };
|
||||
|
||||
try {
|
||||
const jsonText = state.host.readFile(packageJsonPath);
|
||||
jsonContent = jsonText ? <{ typings?: string }>JSON.parse(jsonText) : { typings: undefined };
|
||||
}
|
||||
catch (e) {
|
||||
// gracefully handle if readFile fails or returns not JSON
|
||||
jsonContent = { typings: undefined };
|
||||
}
|
||||
|
||||
if (jsonContent.typings) {
|
||||
if (typeof jsonContent.typings === "string") {
|
||||
const typingsFile = normalizePath(combinePaths(candidate, jsonContent.typings));
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.package_json_has_typings_field_0_that_references_1, jsonContent.typings, typingsFile);
|
||||
}
|
||||
const result = loadModuleFromFile(typingsFile, extensions, failedLookupLocation, !directoryProbablyExists(getDirectoryPath(typingsFile), state.host), state);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Expected_type_of_typings_field_in_package_json_to_be_string_got_0, typeof jsonContent.typings);
|
||||
const typesFile = tryReadTypesSection(packageJsonPath, candidate, state);
|
||||
if (typesFile) {
|
||||
const result = loadModuleFromFile(typesFile, extensions, failedLookupLocation, !directoryProbablyExists(getDirectoryPath(typesFile), state.host), state);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.package_json_does_not_have_typings_field);
|
||||
trace(state.host, Diagnostics.package_json_does_not_have_types_field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -481,20 +673,31 @@ namespace ts {
|
|||
return loadModuleFromFile(combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state);
|
||||
}
|
||||
|
||||
function loadModuleFromNodeModulesFolder(moduleName: string, directory: string, failedLookupLocations: string[], state: ModuleResolutionState): string {
|
||||
const nodeModulesFolder = combinePaths(directory, "node_modules");
|
||||
const nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host);
|
||||
const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
|
||||
// Load only typescript files irrespective of allowJs option if loading from node modules
|
||||
let result = loadModuleFromFile(candidate, supportedTypeScriptExtensions, failedLookupLocations, !nodeModulesFolderExists, state);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = loadNodeModuleFromDirectory(supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
function loadModuleFromNodeModules(moduleName: string, directory: string, failedLookupLocations: string[], state: ModuleResolutionState): string {
|
||||
directory = normalizeSlashes(directory);
|
||||
while (true) {
|
||||
const baseName = getBaseFileName(directory);
|
||||
if (baseName !== "node_modules") {
|
||||
const nodeModulesFolder = combinePaths(directory, "node_modules");
|
||||
const nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host);
|
||||
const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
|
||||
// Load only typescript files irrespective of allowJs option if loading from node modules
|
||||
let result = loadModuleFromFile(candidate, supportedTypeScriptExtensions, failedLookupLocations, !nodeModulesFolderExists, state);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = loadNodeModuleFromDirectory(supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state);
|
||||
const result =
|
||||
// first: try to load module as-is
|
||||
loadModuleFromNodeModulesFolder(moduleName, directory, failedLookupLocations, state) ||
|
||||
// second: try to load module from the scope '@types'
|
||||
loadModuleFromNodeModulesFolder(combinePaths("@types", moduleName), directory, failedLookupLocations, state);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
@ -544,7 +747,7 @@ namespace ts {
|
|||
|
||||
|
||||
return referencedSourceFile
|
||||
? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations }
|
||||
? { resolvedModule: { resolvedFileName: referencedSourceFile }, failedLookupLocations }
|
||||
: { resolvedModule: undefined, failedLookupLocations };
|
||||
}
|
||||
|
||||
|
@ -689,9 +892,9 @@ namespace ts {
|
|||
|
||||
export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[] {
|
||||
let diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(
|
||||
program.getSyntacticDiagnostics(sourceFile, cancellationToken),
|
||||
program.getGlobalDiagnostics(cancellationToken),
|
||||
program.getSemanticDiagnostics(sourceFile, cancellationToken));
|
||||
program.getSyntacticDiagnostics(sourceFile, cancellationToken),
|
||||
program.getGlobalDiagnostics(cancellationToken),
|
||||
program.getSemanticDiagnostics(sourceFile, cancellationToken));
|
||||
|
||||
if (program.getCompilerOptions().declaration) {
|
||||
diagnostics = diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken));
|
||||
|
@ -726,68 +929,80 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function loadWithLocalCache<T>(names: string[], containingFile: string, loader: (name: string, containingFile: string) => T): T[] {
|
||||
if (names.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const resolutions: T[] = [];
|
||||
const cache: Map<T> = {};
|
||||
for (const name of names) {
|
||||
let result: T;
|
||||
if (hasProperty(cache, name)) {
|
||||
result = cache[name];
|
||||
}
|
||||
else {
|
||||
result = loader(name, containingFile);
|
||||
cache[name] = result;
|
||||
}
|
||||
resolutions.push(result);
|
||||
}
|
||||
return resolutions;
|
||||
}
|
||||
|
||||
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program {
|
||||
let program: Program;
|
||||
let files: SourceFile[] = [];
|
||||
let fileProcessingDiagnostics = createDiagnosticCollection();
|
||||
const programDiagnostics = createDiagnosticCollection();
|
||||
|
||||
let commonSourceDirectory: string;
|
||||
let diagnosticsProducingTypeChecker: TypeChecker;
|
||||
let noDiagnosticsTypeChecker: TypeChecker;
|
||||
let classifiableNames: Map<string>;
|
||||
|
||||
let resolvedTypeReferenceDirectives: Map<ResolvedTypeReferenceDirective> = {};
|
||||
let fileProcessingDiagnostics = createDiagnosticCollection();
|
||||
let skipDefaultLib = options.noLib;
|
||||
const programDiagnostics = createDiagnosticCollection();
|
||||
const currentDirectory = host.getCurrentDirectory();
|
||||
const supportedExtensions = getSupportedExtensions(options);
|
||||
|
||||
const start = new Date().getTime();
|
||||
|
||||
host = host || createCompilerHost(options);
|
||||
|
||||
// Map storing if there is emit blocking diagnostics for given input
|
||||
const hasEmitBlockingDiagnostics = createFileMap<boolean>(getCanonicalFileName);
|
||||
|
||||
const currentDirectory = host.getCurrentDirectory();
|
||||
const resolveModuleNamesWorker = host.resolveModuleNames
|
||||
? ((moduleNames: string[], containingFile: string) => host.resolveModuleNames(moduleNames, containingFile))
|
||||
: ((moduleNames: string[], containingFile: string) => {
|
||||
const resolvedModuleNames: ResolvedModule[] = [];
|
||||
// resolveModuleName does not store any results between calls.
|
||||
// lookup is a local cache to avoid resolving the same module name several times
|
||||
const lookup: Map<ResolvedModule> = {};
|
||||
for (const moduleName of moduleNames) {
|
||||
let resolvedName: ResolvedModule;
|
||||
if (hasProperty(lookup, moduleName)) {
|
||||
resolvedName = lookup[moduleName];
|
||||
}
|
||||
else {
|
||||
resolvedName = resolveModuleName(moduleName, containingFile, options, host).resolvedModule;
|
||||
lookup[moduleName] = resolvedName;
|
||||
}
|
||||
resolvedModuleNames.push(resolvedName);
|
||||
}
|
||||
return resolvedModuleNames;
|
||||
});
|
||||
let resolveModuleNamesWorker: (moduleNames: string[], containingFile: string) => ResolvedModule[];
|
||||
if (host.resolveModuleNames) {
|
||||
resolveModuleNamesWorker = (moduleNames, containingFile) => host.resolveModuleNames(moduleNames, containingFile);
|
||||
}
|
||||
else {
|
||||
const loader = (moduleName: string, containingFile: string) => resolveModuleName(moduleName, containingFile, options, host).resolvedModule;
|
||||
resolveModuleNamesWorker = (moduleNames, containingFile) => loadWithLocalCache(moduleNames, containingFile, loader);
|
||||
}
|
||||
|
||||
let resolveTypeReferenceDirectiveNamesWorker: (typeDirectiveNames: string[], containingFile: string) => ResolvedTypeReferenceDirective[];
|
||||
if (host.resolveTypeReferenceDirectives) {
|
||||
resolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile) => host.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile);
|
||||
}
|
||||
else {
|
||||
const loader = (typesRef: string, containingFile: string) => resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective;
|
||||
resolveTypeReferenceDirectiveNamesWorker = (typeReferenceDirectiveNames, containingFile) => loadWithLocalCache(typeReferenceDirectiveNames, containingFile, loader);
|
||||
}
|
||||
|
||||
const filesByName = createFileMap<SourceFile>();
|
||||
// stores 'filename -> file association' ignoring case
|
||||
// used to track cases when two file names differ only in casing
|
||||
const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap<SourceFile>(fileName => fileName.toLowerCase()) : undefined;
|
||||
|
||||
if (oldProgram) {
|
||||
// check properties that can affect structure of the program or module resolution strategy
|
||||
// if any of these properties has changed - structure cannot be reused
|
||||
const oldOptions = oldProgram.getCompilerOptions();
|
||||
if ((oldOptions.module !== options.module) ||
|
||||
(oldOptions.noResolve !== options.noResolve) ||
|
||||
(oldOptions.target !== options.target) ||
|
||||
(oldOptions.noLib !== options.noLib) ||
|
||||
(oldOptions.jsx !== options.jsx) ||
|
||||
(oldOptions.allowJs !== options.allowJs)) {
|
||||
oldProgram = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tryReuseStructureFromOldProgram()) {
|
||||
// load type declarations specified via 'types' argument
|
||||
if (options.types && options.types.length) {
|
||||
const resolutions = resolveTypeReferenceDirectiveNamesWorker(options.types, /*containingFile*/ undefined);
|
||||
for (let i = 0; i < options.types.length; i++) {
|
||||
processTypeReferenceDirective(options.types[i], resolutions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
|
||||
// Do not process the default library if:
|
||||
// - The '--noLib' flag is used.
|
||||
|
@ -831,7 +1046,8 @@ namespace ts {
|
|||
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
|
||||
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
|
||||
getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(),
|
||||
getFileProcessingDiagnostics: () => fileProcessingDiagnostics
|
||||
getFileProcessingDiagnostics: () => fileProcessingDiagnostics,
|
||||
resolvedTypeReferenceDirectives
|
||||
};
|
||||
|
||||
verifyCompilerOptions();
|
||||
|
@ -878,6 +1094,21 @@ namespace ts {
|
|||
return false;
|
||||
}
|
||||
|
||||
// check properties that can affect structure of the program or module resolution strategy
|
||||
// if any of these properties has changed - structure cannot be reused
|
||||
const oldOptions = oldProgram.getCompilerOptions();
|
||||
if ((oldOptions.module !== options.module) ||
|
||||
(oldOptions.noResolve !== options.noResolve) ||
|
||||
(oldOptions.target !== options.target) ||
|
||||
(oldOptions.noLib !== options.noLib) ||
|
||||
(oldOptions.jsx !== options.jsx) ||
|
||||
(oldOptions.allowJs !== options.allowJs) ||
|
||||
(oldOptions.rootDir !== options.rootDir) ||
|
||||
(oldOptions.typesSearchPaths !== options.typesSearchPaths) ||
|
||||
(oldOptions.configFilePath !== options.configFilePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Debug.assert(!oldProgram.structureIsReused);
|
||||
|
||||
// there is an old program, check if we can reuse its structure
|
||||
|
@ -886,6 +1117,10 @@ namespace ts {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!arrayIsEqualTo(options.types, oldOptions.types)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if program source files has changed in the way that can affect structure of the program
|
||||
const newSourceFiles: SourceFile[] = [];
|
||||
const filePaths: Path[] = [];
|
||||
|
@ -924,26 +1159,33 @@ namespace ts {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
|
||||
// 'types' references has changed
|
||||
return false;
|
||||
}
|
||||
|
||||
const newSourceFilePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory);
|
||||
if (resolveModuleNamesWorker) {
|
||||
const moduleNames = map(concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral);
|
||||
const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory));
|
||||
const resolutions = resolveModuleNamesWorker(moduleNames, newSourceFilePath);
|
||||
// ensure that module resolution results are still correct
|
||||
for (let i = 0; i < moduleNames.length; i++) {
|
||||
const newResolution = resolutions[i];
|
||||
const oldResolution = getResolvedModule(oldSourceFile, moduleNames[i]);
|
||||
const resolutionChanged = oldResolution
|
||||
? !newResolution ||
|
||||
oldResolution.resolvedFileName !== newResolution.resolvedFileName ||
|
||||
!!oldResolution.isExternalLibraryImport !== !!newResolution.isExternalLibraryImport
|
||||
: newResolution;
|
||||
|
||||
if (resolutionChanged) {
|
||||
return false;
|
||||
}
|
||||
const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo);
|
||||
if (resolutionsChanged) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// pass the cache of module resolutions from the old source file
|
||||
if (resolveTypeReferenceDirectiveNamesWorker) {
|
||||
const typesReferenceDirectives = map(newSourceFile.typeReferenceDirectives, x => x.fileName);
|
||||
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath);
|
||||
// ensure that types resolutions are still correct
|
||||
const resolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo);
|
||||
if (resolutionsChanged) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// pass the cache of module/types resolutions from the old source file
|
||||
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
||||
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
|
||||
modifiedSourceFiles.push(newSourceFile);
|
||||
}
|
||||
else {
|
||||
|
@ -966,6 +1208,7 @@ namespace ts {
|
|||
for (const modifiedFile of modifiedSourceFiles) {
|
||||
fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile);
|
||||
}
|
||||
resolvedTypeReferenceDirectives = oldProgram.resolvedTypeReferenceDirectives;
|
||||
oldProgram.structureIsReused = true;
|
||||
|
||||
return true;
|
||||
|
@ -1058,9 +1301,9 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getDiagnosticsHelper(
|
||||
sourceFile: SourceFile,
|
||||
getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => Diagnostic[],
|
||||
cancellationToken: CancellationToken): Diagnostic[] {
|
||||
sourceFile: SourceFile,
|
||||
getDiagnostics: (sourceFile: SourceFile, cancellationToken: CancellationToken) => Diagnostic[],
|
||||
cancellationToken: CancellationToken): Diagnostic[] {
|
||||
if (sourceFile) {
|
||||
return getDiagnostics(sourceFile, cancellationToken);
|
||||
}
|
||||
|
@ -1534,7 +1777,8 @@ namespace ts {
|
|||
|
||||
const basePath = getDirectoryPath(fileName);
|
||||
if (!options.noResolve) {
|
||||
processReferencedFiles(file, basePath, /*isDefaultLib*/ isDefaultLib);
|
||||
processReferencedFiles(file, basePath, isDefaultLib);
|
||||
processTypeReferenceDirectives(file);
|
||||
}
|
||||
|
||||
// always process imported modules to record module name resolutions
|
||||
|
@ -1558,6 +1802,73 @@ namespace ts {
|
|||
});
|
||||
}
|
||||
|
||||
function processTypeReferenceDirectives(file: SourceFile) {
|
||||
const typeDirectives = map(file.typeReferenceDirectives, l => l.fileName);
|
||||
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.fileName);
|
||||
|
||||
for (let i = 0; i < typeDirectives.length; i++) {
|
||||
const ref = file.typeReferenceDirectives[i];
|
||||
const resolvedTypeReferenceDirective = resolutions[i];
|
||||
// store resolved type directive on the file
|
||||
setResolvedTypeReferenceDirective(file, ref.fileName, resolvedTypeReferenceDirective);
|
||||
processTypeReferenceDirective(ref.fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end);
|
||||
}
|
||||
}
|
||||
|
||||
function processTypeReferenceDirective(typeReferenceDirective: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective,
|
||||
refFile?: SourceFile, refPos?: number, refEnd?: number): void {
|
||||
|
||||
// If we already found this library as a primary reference - nothing to do
|
||||
const previousResolution = resolvedTypeReferenceDirectives[typeReferenceDirective];
|
||||
if (previousResolution && previousResolution.primary) {
|
||||
return;
|
||||
}
|
||||
let saveResolution = true;
|
||||
if (resolvedTypeReferenceDirective) {
|
||||
if (resolvedTypeReferenceDirective.primary) {
|
||||
// resolved from the primary path
|
||||
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd);
|
||||
}
|
||||
else {
|
||||
// If we already resolved to this file, it must have been a secondary reference. Check file contents
|
||||
// for sameness and possibly issue an error
|
||||
if (previousResolution) {
|
||||
const otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
|
||||
if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) {
|
||||
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd,
|
||||
Diagnostics.Conflicting_library_definitions_for_0_found_at_1_and_2_Copy_the_correct_file_to_the_typings_folder_to_resolve_this_conflict,
|
||||
typeReferenceDirective,
|
||||
resolvedTypeReferenceDirective.resolvedFileName,
|
||||
previousResolution.resolvedFileName
|
||||
));
|
||||
}
|
||||
// don't overwrite previous resolution result
|
||||
saveResolution = false;
|
||||
}
|
||||
else {
|
||||
// First resolution of this library
|
||||
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, Diagnostics.Cannot_find_name_0, typeReferenceDirective));
|
||||
}
|
||||
|
||||
if (saveResolution) {
|
||||
resolvedTypeReferenceDirectives[typeReferenceDirective] = resolvedTypeReferenceDirective;
|
||||
}
|
||||
}
|
||||
|
||||
function createDiagnostic(refFile: SourceFile, refPos: number, refEnd: number, message: DiagnosticMessage, ...args: any[]): Diagnostic {
|
||||
if (refFile === undefined || refPos === undefined || refEnd === undefined) {
|
||||
return createCompilerDiagnostic(message, ...args);
|
||||
}
|
||||
else {
|
||||
return createFileDiagnostic(refFile, refPos, refEnd - refPos, message, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
function getCanonicalFileName(fileName: string): string {
|
||||
return host.getCanonicalFileName(fileName);
|
||||
}
|
||||
|
@ -1605,51 +1916,13 @@ namespace ts {
|
|||
}
|
||||
|
||||
function computeCommonSourceDirectory(sourceFiles: SourceFile[]): string {
|
||||
let commonPathComponents: string[];
|
||||
const failed = forEach(files, sourceFile => {
|
||||
// Each file contributes into common source file path
|
||||
if (isDeclarationFile(sourceFile)) {
|
||||
return;
|
||||
const fileNames: string[] = [];
|
||||
for (const file of sourceFiles) {
|
||||
if (!file.isDeclarationFile) {
|
||||
fileNames.push(file.fileName);
|
||||
}
|
||||
|
||||
const sourcePathComponents = getNormalizedPathComponents(sourceFile.fileName, currentDirectory);
|
||||
sourcePathComponents.pop(); // The base file name is not part of the common directory path
|
||||
|
||||
if (!commonPathComponents) {
|
||||
// first file
|
||||
commonPathComponents = sourcePathComponents;
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) {
|
||||
if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) {
|
||||
if (i === 0) {
|
||||
// Failed to find any common path component
|
||||
return true;
|
||||
}
|
||||
|
||||
// New common path found that is 0 -> i-1
|
||||
commonPathComponents.length = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If the sourcePathComponents was shorter than the commonPathComponents, truncate to the sourcePathComponents
|
||||
if (sourcePathComponents.length < commonPathComponents.length) {
|
||||
commonPathComponents.length = sourcePathComponents.length;
|
||||
}
|
||||
});
|
||||
|
||||
// A common path can not be found when paths span multiple drives on windows, for example
|
||||
if (failed) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!commonPathComponents) { // Can happen when all input files are .d.ts files
|
||||
return currentDirectory;
|
||||
}
|
||||
|
||||
return getNormalizedPathFromPathComponents(commonPathComponents);
|
||||
return computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName);
|
||||
}
|
||||
|
||||
function checkSourceFilesBelongToPath(sourceFiles: SourceFile[], rootDirectory: string): boolean {
|
||||
|
@ -1797,7 +2070,7 @@ namespace ts {
|
|||
|
||||
// If we failed to find a good common directory, but outDir is specified and at least one of our files is on a windows drive/URL/other resource, add a failure
|
||||
if (options.outDir && dir === "" && forEach(files, file => getRootLength(file.fileName) > 1)) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1537,6 +1537,7 @@ namespace ts {
|
|||
amdDependencies: AmdDependency[];
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
typeReferenceDirectives: FileReference[];
|
||||
languageVariant: LanguageVariant;
|
||||
isDeclarationFile: boolean;
|
||||
|
||||
|
@ -1584,6 +1585,7 @@ namespace ts {
|
|||
// It is used to resolve module names in the checker.
|
||||
// Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead
|
||||
/* @internal */ resolvedModules: Map<ResolvedModule>;
|
||||
/* @internal */ resolvedTypeReferenceDirectiveNames: Map<ResolvedTypeReferenceDirective>;
|
||||
/* @internal */ imports: LiteralExpression[];
|
||||
/* @internal */ moduleAugmentations: LiteralExpression[];
|
||||
}
|
||||
|
@ -1660,6 +1662,7 @@ namespace ts {
|
|||
/* @internal */ getTypeCount(): number;
|
||||
|
||||
/* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection;
|
||||
/* @internal */ resolvedTypeReferenceDirectives: Map<ResolvedTypeReferenceDirective>;
|
||||
// For testing purposes only.
|
||||
/* @internal */ structureIsReused?: boolean;
|
||||
}
|
||||
|
@ -2418,6 +2421,7 @@ namespace ts {
|
|||
jsx?: JsxEmit;
|
||||
reactNamespace?: string;
|
||||
listFiles?: boolean;
|
||||
typesSearchPaths?: string[];
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
module?: ModuleKind;
|
||||
|
@ -2457,7 +2461,7 @@ namespace ts {
|
|||
baseUrl?: string;
|
||||
paths?: PathSubstitutions;
|
||||
rootDirs?: RootPaths;
|
||||
traceModuleResolution?: boolean;
|
||||
traceResolution?: boolean;
|
||||
allowSyntheticDefaultImports?: boolean;
|
||||
allowJs?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
|
@ -2471,8 +2475,15 @@ namespace ts {
|
|||
// Do not perform validation of output file name in transpile scenarios
|
||||
/* @internal */ suppressOutputPathCheck?: boolean;
|
||||
|
||||
list?: string[];
|
||||
/* @internal */
|
||||
// When options come from a config file, its path is recorded here
|
||||
configFilePath?: string;
|
||||
/* @internal */
|
||||
// Path used to used to compute primary search locations
|
||||
typesRoot?: string;
|
||||
types?: string[];
|
||||
|
||||
list?: string[];
|
||||
[option: string]: CompilerOptionsValue;
|
||||
}
|
||||
|
||||
|
@ -2753,6 +2764,18 @@ namespace ts {
|
|||
failedLookupLocations: string[];
|
||||
}
|
||||
|
||||
export interface ResolvedTypeReferenceDirective {
|
||||
// True if the type declaration file was found in a primary lookup location
|
||||
primary: boolean;
|
||||
// The location of the .d.ts file we located, or undefined if resolution failed
|
||||
resolvedFileName?: string;
|
||||
}
|
||||
|
||||
export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations {
|
||||
resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective;
|
||||
failedLookupLocations: string[];
|
||||
}
|
||||
|
||||
export interface CompilerHost extends ModuleResolutionHost {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
|
@ -2772,6 +2795,10 @@ namespace ts {
|
|||
* 'throw new Error("NotImplemented")'
|
||||
*/
|
||||
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
|
||||
/**
|
||||
* This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files
|
||||
*/
|
||||
resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
|
||||
}
|
||||
|
||||
export interface TextSpan {
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace ts {
|
|||
fileReference?: FileReference;
|
||||
diagnosticMessage?: DiagnosticMessage;
|
||||
isNoDefaultLib?: boolean;
|
||||
isTypeReferenceDirective?: boolean;
|
||||
}
|
||||
|
||||
export interface SynthesizedNode extends Node {
|
||||
|
@ -118,6 +119,43 @@ namespace ts {
|
|||
sourceFile.resolvedModules[moduleNameText] = resolvedModule;
|
||||
}
|
||||
|
||||
export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void {
|
||||
if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
|
||||
sourceFile.resolvedTypeReferenceDirectiveNames = {};
|
||||
}
|
||||
|
||||
sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function moduleResolutionIsEqualTo(oldResolution: ResolvedModule, newResolution: ResolvedModule): boolean {
|
||||
return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean {
|
||||
return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function hasChangesInResolutions<T>(names: string[], newResolutions: T[], oldResolutions: Map<T>, comparer: (oldResolution: T, newResolution: T) => boolean): boolean {
|
||||
if (names.length !== newResolutions.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < names.length; i++) {
|
||||
const newResolution = newResolutions[i];
|
||||
const oldResolution = oldResolutions && hasProperty(oldResolutions, names[i]) ? oldResolutions[names[i]] : undefined;
|
||||
const changed =
|
||||
oldResolution
|
||||
? !newResolution || !comparer(oldResolution, newResolution)
|
||||
: newResolution;
|
||||
if (changed) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns true if this node contains a parse error anywhere underneath it.
|
||||
export function containsParseError(node: Node): boolean {
|
||||
aggregateChildData(node);
|
||||
|
@ -541,6 +579,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
|
||||
export let fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)('|")(.+?)\2.*?\/>/;
|
||||
export let fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
|
||||
|
||||
export function isTypeNode(node: Node): boolean {
|
||||
|
@ -1591,25 +1630,26 @@ namespace ts {
|
|||
};
|
||||
}
|
||||
else {
|
||||
const matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
if (matchResult) {
|
||||
const refMatchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
const refLibResult = !refMatchResult && fullTripleSlashReferenceTypeReferenceDirectiveRegEx.exec(comment);
|
||||
if (refMatchResult || refLibResult) {
|
||||
const start = commentRange.pos;
|
||||
const end = commentRange.end;
|
||||
return {
|
||||
fileReference: {
|
||||
pos: start,
|
||||
end: end,
|
||||
fileName: matchResult[3]
|
||||
fileName: (refMatchResult || refLibResult)[3]
|
||||
},
|
||||
isNoDefaultLib: false
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Invalid_reference_directive_syntax,
|
||||
isNoDefaultLib: false
|
||||
isNoDefaultLib: false,
|
||||
isTypeReferenceDirective: !!refLibResult
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Invalid_reference_directive_syntax,
|
||||
isNoDefaultLib: false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,10 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
});
|
||||
}
|
||||
|
||||
if (tsConfigOptions && tsConfigOptions.configFilePath !== undefined) {
|
||||
tsConfigOptions.configFilePath = ts.combinePaths(rootDir, tsConfigOptions.configFilePath);
|
||||
}
|
||||
|
||||
const output = Harness.Compiler.compileFiles(
|
||||
toBeCompiled, otherFiles, harnessSettings, /*options*/ tsConfigOptions, /*currentDirectory*/ undefined);
|
||||
|
||||
|
@ -140,7 +144,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
});
|
||||
|
||||
it (`Correct module resolution tracing for ${fileName}`, () => {
|
||||
if (options.traceModuleResolution) {
|
||||
if (options.traceResolution) {
|
||||
Harness.Baseline.runBaseline("Correct sourcemap content for " + fileName, justName.replace(/\.tsx?$/, ".trace.json"), () => {
|
||||
return JSON.stringify(result.traceResults || [], undefined, 4);
|
||||
});
|
||||
|
|
|
@ -222,7 +222,7 @@ namespace FourSlash {
|
|||
function tryAdd(path: string) {
|
||||
const inputFile = inputFiles[path];
|
||||
if (inputFile && !Harness.isDefaultLibraryFile(path)) {
|
||||
languageServiceAdapterHost.addScript(path, inputFile);
|
||||
languageServiceAdapterHost.addScript(path, inputFile, /*isRootFile*/ true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -247,6 +247,10 @@ namespace FourSlash {
|
|||
// Create a new Services Adapter
|
||||
this.cancellationToken = new TestCancellationToken();
|
||||
const compilationOptions = convertGlobalOptionsToCompilerOptions(this.testData.globalOptions);
|
||||
if (compilationOptions.typesRoot) {
|
||||
compilationOptions.typesRoot = ts.getNormalizedAbsolutePath(compilationOptions.typesRoot, this.basePath);
|
||||
}
|
||||
|
||||
const languageServiceAdapter = this.getLanguageServiceAdapter(testType, this.cancellationToken, compilationOptions);
|
||||
this.languageServiceAdapterHost = languageServiceAdapter.getHost();
|
||||
this.languageService = languageServiceAdapter.getLanguageService();
|
||||
|
@ -268,7 +272,7 @@ namespace FourSlash {
|
|||
|
||||
if (startResolveFileRef) {
|
||||
// Add the entry-point file itself into the languageServiceShimHost
|
||||
this.languageServiceAdapterHost.addScript(startResolveFileRef.fileName, startResolveFileRef.content);
|
||||
this.languageServiceAdapterHost.addScript(startResolveFileRef.fileName, startResolveFileRef.content, /*isRootFile*/ true);
|
||||
|
||||
const resolvedResult = languageServiceAdapter.getPreProcessedFileInfo(startResolveFileRef.fileName, startResolveFileRef.content);
|
||||
const referencedFiles: ts.FileReference[] = resolvedResult.referencedFiles;
|
||||
|
@ -292,18 +296,18 @@ namespace FourSlash {
|
|||
// Check if no-default-lib flag is false and if so add default library
|
||||
if (!resolvedResult.isLibFile) {
|
||||
this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName,
|
||||
Harness.Compiler.getDefaultLibrarySourceFile().text);
|
||||
Harness.Compiler.getDefaultLibrarySourceFile().text, /*isRootFile*/ false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// resolveReference file-option is not specified then do not resolve any files and include all inputFiles
|
||||
ts.forEachKey(this.inputFiles, fileName => {
|
||||
if (!Harness.isDefaultLibraryFile(fileName)) {
|
||||
this.languageServiceAdapterHost.addScript(fileName, this.inputFiles[fileName]);
|
||||
this.languageServiceAdapterHost.addScript(fileName, this.inputFiles[fileName], /*isRootFile*/ true);
|
||||
}
|
||||
});
|
||||
this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName,
|
||||
Harness.Compiler.getDefaultLibrarySourceFile().text);
|
||||
Harness.Compiler.getDefaultLibrarySourceFile().text, /*isRootFile*/ false);
|
||||
}
|
||||
|
||||
this.formatCodeOptions = {
|
||||
|
|
|
@ -65,6 +65,11 @@ namespace Utils {
|
|||
return Buffer ? (new Buffer(s)).toString("utf8") : s;
|
||||
}
|
||||
|
||||
export function byteLength(s: string, encoding?: string): number {
|
||||
// stub implementation if Buffer is not available (in-browser case)
|
||||
return Buffer ? Buffer.byteLength(s, encoding) : s.length;
|
||||
}
|
||||
|
||||
export function evalFile(fileContents: string, fileName: string, nodeContext?: any) {
|
||||
const environment = getExecutionEnvironment();
|
||||
switch (environment) {
|
||||
|
@ -835,7 +840,7 @@ namespace Harness {
|
|||
export let fourslashSourceFile: ts.SourceFile;
|
||||
|
||||
export function getCanonicalFileName(fileName: string): string {
|
||||
return Harness.IO.useCaseSensitiveFileNames() ? fileName : fileName.toLowerCase();
|
||||
return fileName;
|
||||
}
|
||||
|
||||
export function createCompilerHost(
|
||||
|
@ -883,6 +888,7 @@ namespace Harness {
|
|||
newLineKind === ts.NewLineKind.LineFeed ? lineFeed :
|
||||
Harness.IO.newLine();
|
||||
|
||||
|
||||
return {
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getSourceFile,
|
||||
|
@ -891,8 +897,12 @@ namespace Harness {
|
|||
getCanonicalFileName,
|
||||
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
|
||||
getNewLine: () => newLine,
|
||||
fileExists: fileName => getSourceFile(fileName, ts.ScriptTarget.ES5) !== undefined,
|
||||
readFile: (fileName: string): string => { return Harness.IO.readFile(fileName); }
|
||||
fileExists: fileName => {
|
||||
return fileMap.contains(ts.toPath(fileName, currentDirectory, getCanonicalFileName));
|
||||
},
|
||||
readFile: (fileName: string): string => {
|
||||
return fileMap.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)).getText();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1033,7 +1043,7 @@ namespace Harness {
|
|||
options.newLine);
|
||||
|
||||
let traceResults: string[];
|
||||
if (options.traceModuleResolution) {
|
||||
if (options.traceResolution) {
|
||||
traceResults = [];
|
||||
compilerHost.trace = text => traceResults.push(text);
|
||||
}
|
||||
|
@ -1479,6 +1489,7 @@ namespace Harness {
|
|||
baseDir = ts.getNormalizedAbsolutePath(baseDir, rootDir);
|
||||
}
|
||||
tsConfig = ts.parseJsonConfigFileContent(configJson.config, parseConfigHost, baseDir);
|
||||
tsConfig.options.configFilePath = data.name;
|
||||
|
||||
// delete entry from the list
|
||||
testUnitData.splice(i, 1);
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Harness.LanguageService {
|
|||
public editRanges: { length: number; textChangeRange: ts.TextChangeRange; }[] = [];
|
||||
private lineMap: number[] = undefined;
|
||||
|
||||
constructor(public fileName: string, public content: string) {
|
||||
constructor(public fileName: string, public content: string, public isRootFile: boolean) {
|
||||
this.setContent(content);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,13 @@ namespace Harness.LanguageService {
|
|||
|
||||
public getFilenames(): string[] {
|
||||
const fileNames: string[] = [];
|
||||
ts.forEachKey(this.fileNameToScript, (fileName) => { fileNames.push(fileName); });
|
||||
ts.forEachValue(this.fileNameToScript, (scriptInfo) => {
|
||||
if (scriptInfo.isRootFile) {
|
||||
// only include root files here
|
||||
// usually it means that we won't include lib.d.ts in the list of root files so it won't mess the computation of compilation root dir.
|
||||
fileNames.push(scriptInfo.fileName);
|
||||
}
|
||||
});
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
|
@ -143,8 +149,8 @@ namespace Harness.LanguageService {
|
|||
return ts.lookUp(this.fileNameToScript, fileName);
|
||||
}
|
||||
|
||||
public addScript(fileName: string, content: string): void {
|
||||
this.fileNameToScript[fileName] = new ScriptInfo(fileName, content);
|
||||
public addScript(fileName: string, content: string, isRootFile: boolean): void {
|
||||
this.fileNameToScript[fileName] = new ScriptInfo(fileName, content, isRootFile);
|
||||
}
|
||||
|
||||
public editScript(fileName: string, start: number, end: number, newText: string) {
|
||||
|
@ -177,7 +183,7 @@ namespace Harness.LanguageService {
|
|||
getCompilationSettings() { return this.settings; }
|
||||
getCancellationToken() { return this.cancellationToken; }
|
||||
getCurrentDirectory(): string { return ""; }
|
||||
getDefaultLibFileName(): string { return ""; }
|
||||
getDefaultLibFileName(): string { return Harness.Compiler.defaultLibFileName; }
|
||||
getScriptFileNames(): string[] { return this.getFilenames(); }
|
||||
getScriptSnapshot(fileName: string): ts.IScriptSnapshot {
|
||||
const script = this.getScriptInfo(fileName);
|
||||
|
@ -210,6 +216,7 @@ namespace Harness.LanguageService {
|
|||
private nativeHost: NativeLanguageServiceHost;
|
||||
|
||||
public getModuleResolutionsForFile: (fileName: string) => string;
|
||||
public getTypeReferenceDirectiveResolutionsForFile: (fileName: string) => string;
|
||||
|
||||
constructor(preprocessToResolve: boolean, cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) {
|
||||
super(cancellationToken, options);
|
||||
|
@ -236,12 +243,25 @@ namespace Harness.LanguageService {
|
|||
}
|
||||
return JSON.stringify(imports);
|
||||
};
|
||||
this.getTypeReferenceDirectiveResolutionsForFile = (fileName) => {
|
||||
const scriptInfo = this.getScriptInfo(fileName);
|
||||
const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ false);
|
||||
const resolutions: ts.Map<ts.ResolvedTypeReferenceDirective> = {};
|
||||
const settings = this.nativeHost.getCompilationSettings();
|
||||
for (const typeReferenceDirective of preprocessInfo.typeReferenceDirectives) {
|
||||
const resolutionInfo = ts.resolveTypeReferenceDirective(typeReferenceDirective.fileName, fileName, settings, moduleResolutionHost);
|
||||
if (resolutionInfo.resolvedTypeReferenceDirective.resolvedFileName) {
|
||||
resolutions[typeReferenceDirective.fileName] = resolutionInfo.resolvedTypeReferenceDirective;
|
||||
}
|
||||
}
|
||||
return JSON.stringify(resolutions);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
getFilenames(): string[] { return this.nativeHost.getFilenames(); }
|
||||
getScriptInfo(fileName: string): ScriptInfo { return this.nativeHost.getScriptInfo(fileName); }
|
||||
addScript(fileName: string, content: string): void { this.nativeHost.addScript(fileName, content); }
|
||||
addScript(fileName: string, content: string, isRootFile: boolean): void { this.nativeHost.addScript(fileName, content, isRootFile); }
|
||||
editScript(fileName: string, start: number, end: number, newText: string): void { this.nativeHost.editScript(fileName, start, end, newText); }
|
||||
positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToLineAndCharacter(fileName, position); }
|
||||
|
||||
|
@ -442,6 +462,7 @@ namespace Harness.LanguageService {
|
|||
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo {
|
||||
let shimResult: {
|
||||
referencedFiles: ts.IFileReference[];
|
||||
typeReferenceDirectives: ts.IFileReference[];
|
||||
importedFiles: ts.IFileReference[];
|
||||
isLibFile: boolean;
|
||||
};
|
||||
|
@ -453,7 +474,8 @@ namespace Harness.LanguageService {
|
|||
referencedFiles: [],
|
||||
importedFiles: [],
|
||||
ambientExternalModules: [],
|
||||
isLibFile: shimResult.isLibFile
|
||||
isLibFile: shimResult.isLibFile,
|
||||
typeReferenceDirectives: []
|
||||
};
|
||||
|
||||
ts.forEach(shimResult.referencedFiles, refFile => {
|
||||
|
@ -472,6 +494,13 @@ namespace Harness.LanguageService {
|
|||
});
|
||||
});
|
||||
|
||||
ts.forEach(shimResult.typeReferenceDirectives, typeRefDirective => {
|
||||
convertResult.importedFiles.push({
|
||||
fileName: typeRefDirective.path,
|
||||
pos: typeRefDirective.position,
|
||||
end: typeRefDirective.position + typeRefDirective.length
|
||||
});
|
||||
});
|
||||
return convertResult;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,8 +81,14 @@ namespace ts.server {
|
|||
}
|
||||
}
|
||||
|
||||
interface TimestampedResolvedModule extends ResolvedModuleWithFailedLookupLocations {
|
||||
lastCheckTime: number;
|
||||
interface Timestamped {
|
||||
lastCheckTime?: number;
|
||||
}
|
||||
|
||||
interface TimestampedResolvedModule extends ResolvedModuleWithFailedLookupLocations, Timestamped {
|
||||
}
|
||||
|
||||
interface TimestampedResolvedTypeReferenceDirective extends ResolvedTypeReferenceDirectiveWithFailedLookupLocations, Timestamped {
|
||||
}
|
||||
|
||||
export class LSHost implements ts.LanguageServiceHost {
|
||||
|
@ -90,13 +96,16 @@ namespace ts.server {
|
|||
compilationSettings: ts.CompilerOptions;
|
||||
filenameToScript: ts.FileMap<ScriptInfo>;
|
||||
roots: ScriptInfo[] = [];
|
||||
|
||||
private resolvedModuleNames: ts.FileMap<Map<TimestampedResolvedModule>>;
|
||||
private resolvedTypeReferenceDirectives: ts.FileMap<Map<TimestampedResolvedTypeReferenceDirective>>;
|
||||
private moduleResolutionHost: ts.ModuleResolutionHost;
|
||||
private getCanonicalFileName: (fileName: string) => string;
|
||||
|
||||
constructor(public host: ServerHost, public project: Project) {
|
||||
this.getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
|
||||
this.resolvedModuleNames = createFileMap<Map<TimestampedResolvedModule>>();
|
||||
this.resolvedTypeReferenceDirectives = createFileMap<Map<TimestampedResolvedTypeReferenceDirective>>();
|
||||
this.filenameToScript = createFileMap<ScriptInfo>();
|
||||
this.moduleResolutionHost = {
|
||||
fileExists: fileName => this.fileExists(fileName),
|
||||
|
@ -105,46 +114,51 @@ namespace ts.server {
|
|||
};
|
||||
}
|
||||
|
||||
resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[] {
|
||||
private resolveNamesWithLocalCache<T extends Timestamped & { failedLookupLocations: string[] }, R>(
|
||||
names: string[],
|
||||
containingFile: string,
|
||||
cache: ts.FileMap<Map<T>>,
|
||||
loader: (name: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => T,
|
||||
getResult: (s: T) => R): R[] {
|
||||
|
||||
const path = toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName);
|
||||
const currentResolutionsInFile = this.resolvedModuleNames.get(path);
|
||||
|
||||
const newResolutions: Map<TimestampedResolvedModule> = {};
|
||||
const resolvedModules: ResolvedModule[] = [];
|
||||
const currentResolutionsInFile = cache.get(path);
|
||||
|
||||
const newResolutions: Map<T> = {};
|
||||
const resolvedModules: R[] = [];
|
||||
const compilerOptions = this.getCompilationSettings();
|
||||
|
||||
for (const moduleName of moduleNames) {
|
||||
for (const name of names) {
|
||||
// check if this is a duplicate entry in the list
|
||||
let resolution = lookUp(newResolutions, moduleName);
|
||||
let resolution = lookUp(newResolutions, name);
|
||||
if (!resolution) {
|
||||
const existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName);
|
||||
const existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, name);
|
||||
if (moduleResolutionIsValid(existingResolution)) {
|
||||
// ok, it is safe to use existing module resolution results
|
||||
// ok, it is safe to use existing name resolution results
|
||||
resolution = existingResolution;
|
||||
}
|
||||
else {
|
||||
resolution = <TimestampedResolvedModule>resolveModuleName(moduleName, containingFile, compilerOptions, this.moduleResolutionHost);
|
||||
resolution = loader(name, containingFile, compilerOptions, this.moduleResolutionHost);
|
||||
resolution.lastCheckTime = Date.now();
|
||||
newResolutions[moduleName] = resolution;
|
||||
newResolutions[name] = resolution;
|
||||
}
|
||||
}
|
||||
|
||||
ts.Debug.assert(resolution !== undefined);
|
||||
|
||||
resolvedModules.push(resolution.resolvedModule);
|
||||
resolvedModules.push(getResult(resolution));
|
||||
}
|
||||
|
||||
// replace old results with a new one
|
||||
this.resolvedModuleNames.set(path, newResolutions);
|
||||
cache.set(path, newResolutions);
|
||||
return resolvedModules;
|
||||
|
||||
function moduleResolutionIsValid(resolution: TimestampedResolvedModule): boolean {
|
||||
function moduleResolutionIsValid(resolution: T): boolean {
|
||||
if (!resolution) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (resolution.resolvedModule) {
|
||||
if (getResult(resolution)) {
|
||||
// TODO: consider checking failedLookupLocations
|
||||
// TODO: use lastCheckTime to track expiration for module name resolution
|
||||
return true;
|
||||
|
@ -156,6 +170,14 @@ namespace ts.server {
|
|||
}
|
||||
}
|
||||
|
||||
resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[] {
|
||||
return this.resolveNamesWithLocalCache(typeDirectiveNames, containingFile, this.resolvedTypeReferenceDirectives, resolveTypeReferenceDirective, m => m.resolvedTypeReferenceDirective);
|
||||
}
|
||||
|
||||
resolveModuleNames(moduleNames: string[], containingFile: string): ResolvedModule[] {
|
||||
return this.resolveNamesWithLocalCache(moduleNames, containingFile, this.resolvedModuleNames, resolveModuleName, m => m.resolvedModule);
|
||||
}
|
||||
|
||||
getDefaultLibFileName() {
|
||||
const nodeModuleBinDir = ts.getDirectoryPath(ts.normalizePath(this.host.getExecutingFilePath()));
|
||||
return ts.combinePaths(nodeModuleBinDir, ts.getDefaultLibFileName(this.compilationSettings));
|
||||
|
@ -172,6 +194,7 @@ namespace ts.server {
|
|||
this.compilationSettings = opt;
|
||||
// conservatively assume that changing compiler options might affect module resolution strategy
|
||||
this.resolvedModuleNames.clear();
|
||||
this.resolvedTypeReferenceDirectives.clear();
|
||||
}
|
||||
|
||||
lineAffectsRefs(filename: string, line: number) {
|
||||
|
@ -212,6 +235,7 @@ namespace ts.server {
|
|||
if (!info.isOpen) {
|
||||
this.filenameToScript.remove(info.path);
|
||||
this.resolvedModuleNames.remove(info.path);
|
||||
this.resolvedTypeReferenceDirectives.remove(info.path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,6 +263,7 @@ namespace ts.server {
|
|||
this.filenameToScript.remove(info.path);
|
||||
this.roots = copyListRemovingItem(info, this.roots);
|
||||
this.resolvedModuleNames.remove(info.path);
|
||||
this.resolvedTypeReferenceDirectives.remove(info.path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,6 +125,7 @@ namespace ts {
|
|||
}
|
||||
export interface PreProcessedFileInfo {
|
||||
referencedFiles: FileReference[];
|
||||
typeReferenceDirectives: FileReference[];
|
||||
importedFiles: FileReference[];
|
||||
ambientExternalModules: string[];
|
||||
isLibFile: boolean;
|
||||
|
@ -793,6 +794,7 @@ namespace ts {
|
|||
public amdDependencies: { name: string; path: string }[];
|
||||
public moduleName: string;
|
||||
public referencedFiles: FileReference[];
|
||||
public typeReferenceDirectives: FileReference[];
|
||||
|
||||
public syntacticDiagnostics: Diagnostic[];
|
||||
public referenceDiagnostics: Diagnostic[];
|
||||
|
@ -814,6 +816,7 @@ namespace ts {
|
|||
public identifiers: Map<string>;
|
||||
public nameTable: Map<number>;
|
||||
public resolvedModules: Map<ResolvedModule>;
|
||||
public resolvedTypeReferenceDirectiveNames: Map<ResolvedTypeReferenceDirective>;
|
||||
public imports: LiteralExpression[];
|
||||
public moduleAugmentations: LiteralExpression[];
|
||||
private namedDeclarations: Map<Declaration[]>;
|
||||
|
@ -1040,6 +1043,7 @@ namespace ts {
|
|||
* host specific questions using 'getScriptSnapshot'.
|
||||
*/
|
||||
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
|
||||
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
}
|
||||
|
||||
|
@ -2147,6 +2151,7 @@ namespace ts {
|
|||
|
||||
export function preProcessFile(sourceText: string, readImportFiles = true, detectJavaScriptImports = false): PreProcessedFileInfo {
|
||||
const referencedFiles: FileReference[] = [];
|
||||
const typeReferenceDirectives: FileReference[] = [];
|
||||
const importedFiles: FileReference[] = [];
|
||||
let ambientExternalModules: { ref: FileReference, depth: number }[];
|
||||
let isNoDefaultLib = false;
|
||||
|
@ -2175,7 +2180,11 @@ namespace ts {
|
|||
isNoDefaultLib = referencePathMatchResult.isNoDefaultLib;
|
||||
const fileReference = referencePathMatchResult.fileReference;
|
||||
if (fileReference) {
|
||||
referencedFiles.push(fileReference);
|
||||
const collection = referencePathMatchResult.isTypeReferenceDirective
|
||||
? typeReferenceDirectives
|
||||
: referencedFiles;
|
||||
|
||||
collection.push(fileReference);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -2476,7 +2485,7 @@ namespace ts {
|
|||
importedFiles.push(decl.ref);
|
||||
}
|
||||
}
|
||||
return { referencedFiles, importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: undefined };
|
||||
return { referencedFiles, typeReferenceDirectives, importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: undefined };
|
||||
}
|
||||
else {
|
||||
// for global scripts ambient modules still can have augmentations - look for ambient modules with depth > 0
|
||||
|
@ -2494,7 +2503,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
}
|
||||
return { referencedFiles, importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientModuleNames };
|
||||
return { referencedFiles, typeReferenceDirectives, importedFiles, isLibFile: isNoDefaultLib, ambientExternalModules: ambientModuleNames };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2831,7 +2840,7 @@ namespace ts {
|
|||
getCurrentDirectory: () => currentDirectory,
|
||||
fileExists: (fileName): boolean => {
|
||||
// stub missing host functionality
|
||||
Debug.assert(!host.resolveModuleNames);
|
||||
Debug.assert(!host.resolveModuleNames || !host.resolveTypeReferenceDirectives);
|
||||
return hostCache.getOrCreateEntry(fileName) !== undefined;
|
||||
},
|
||||
readFile: (fileName): string => {
|
||||
|
@ -2840,7 +2849,7 @@ namespace ts {
|
|||
return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength());
|
||||
},
|
||||
directoryExists: directoryName => {
|
||||
Debug.assert(!host.resolveModuleNames);
|
||||
Debug.assert(!host.resolveModuleNames || !host.resolveTypeReferenceDirectives);
|
||||
return directoryProbablyExists(directoryName, host);
|
||||
}
|
||||
};
|
||||
|
@ -2851,6 +2860,11 @@ namespace ts {
|
|||
if (host.resolveModuleNames) {
|
||||
compilerHost.resolveModuleNames = (moduleNames, containingFile) => host.resolveModuleNames(moduleNames, containingFile);
|
||||
}
|
||||
if (host.resolveTypeReferenceDirectives) {
|
||||
compilerHost.resolveTypeReferenceDirectives = (typeReferenceDirectiveNames, containingFile) => {
|
||||
return host.resolveTypeReferenceDirectives(typeReferenceDirectiveNames, containingFile);
|
||||
};
|
||||
}
|
||||
|
||||
const newProgram = createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program);
|
||||
|
||||
|
@ -4683,6 +4697,26 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function findReferenceInPosition(refs: FileReference[], pos: number): FileReference {
|
||||
for (const ref of refs) {
|
||||
if (ref.pos <= pos && pos < ref.end) {
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getDefinitionInfoForFileReference(name: string, targetFileName: string): DefinitionInfo {
|
||||
return {
|
||||
fileName: targetFileName,
|
||||
textSpan: createTextSpanFromBounds(0, 0),
|
||||
kind: ScriptElementKind.scriptElement,
|
||||
name: name,
|
||||
containerName: undefined,
|
||||
containerKind: undefined
|
||||
};
|
||||
}
|
||||
|
||||
/// Goto definition
|
||||
function getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] {
|
||||
synchronizeHostData();
|
||||
|
@ -4702,18 +4736,20 @@ namespace ts {
|
|||
}
|
||||
|
||||
/// Triple slash reference comments
|
||||
const comment = forEach(sourceFile.referencedFiles, r => (r.pos <= position && position < r.end) ? r : undefined);
|
||||
const comment = findReferenceInPosition(sourceFile.referencedFiles, position);
|
||||
if (comment) {
|
||||
const referenceFile = tryResolveScriptReference(program, sourceFile, comment);
|
||||
if (referenceFile) {
|
||||
return [{
|
||||
fileName: referenceFile.fileName,
|
||||
textSpan: createTextSpanFromBounds(0, 0),
|
||||
kind: ScriptElementKind.scriptElement,
|
||||
name: comment.fileName,
|
||||
containerName: undefined,
|
||||
containerKind: undefined
|
||||
}];
|
||||
return [getDefinitionInfoForFileReference(comment.fileName, referenceFile.fileName)];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
// Type reference directives
|
||||
const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position);
|
||||
if (typeReferenceDirective) {
|
||||
const referenceFile = lookUp(program.resolvedTypeReferenceDirectives, typeReferenceDirective.fileName);
|
||||
if (referenceFile && referenceFile.resolvedFileName) {
|
||||
return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ namespace ts {
|
|||
useCaseSensitiveFileNames?(): boolean;
|
||||
|
||||
getModuleResolutionsForFile?(fileName: string): string;
|
||||
getTypeReferenceDirectiveResolutionsForFile?(fileName: string): string;
|
||||
directoryExists(directoryName: string): boolean;
|
||||
}
|
||||
|
||||
|
@ -281,6 +282,7 @@ namespace ts {
|
|||
private tracingEnabled = false;
|
||||
|
||||
public resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModule[];
|
||||
public resolveTypeReferenceDirectives: (typeDirectiveNames: string[], containingFile: string) => ResolvedTypeReferenceDirective[];
|
||||
public directoryExists: (directoryName: string) => boolean;
|
||||
|
||||
constructor(private shimHost: LanguageServiceShimHost) {
|
||||
|
@ -298,6 +300,12 @@ namespace ts {
|
|||
if ("directoryExists" in this.shimHost) {
|
||||
this.directoryExists = directoryName => this.shimHost.directoryExists(directoryName);
|
||||
}
|
||||
if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) {
|
||||
this.resolveTypeReferenceDirectives = (typeDirectiveNames: string[], containingFile: string) => {
|
||||
const typeDirectivesForFile = <Map<ResolvedTypeReferenceDirective>>JSON.parse(this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile));
|
||||
return map(typeDirectiveNames, name => lookUp(typeDirectivesForFile, name));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public log(s: string): void {
|
||||
|
@ -919,38 +927,49 @@ namespace ts {
|
|||
});
|
||||
}
|
||||
|
||||
public resolveTypeReferenceDirective(fileName: string, typeReferenceDirective: string, compilerOptionsJson: string): string {
|
||||
return this.forwardJSONCall(`resolveTypeReferenceDirective(${fileName})`, () => {
|
||||
const compilerOptions = <CompilerOptions>JSON.parse(compilerOptionsJson);
|
||||
const result = resolveTypeReferenceDirective(typeReferenceDirective, normalizeSlashes(fileName), compilerOptions, this.host);
|
||||
return {
|
||||
resolvedFileName: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.resolvedFileName : undefined,
|
||||
primary: result.resolvedTypeReferenceDirective ? result.resolvedTypeReferenceDirective.primary : true,
|
||||
failedLookupLocations: result.failedLookupLocations
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public getPreProcessedFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string {
|
||||
return this.forwardJSONCall(
|
||||
"getPreProcessedFileInfo('" + fileName + "')",
|
||||
() => {
|
||||
// for now treat files as JavaScript
|
||||
const result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true);
|
||||
const convertResult = {
|
||||
referencedFiles: <IFileReference[]>[],
|
||||
importedFiles: <IFileReference[]>[],
|
||||
return {
|
||||
referencedFiles: this.convertFileReferences(result.referencedFiles),
|
||||
importedFiles: this.convertFileReferences(result.importedFiles),
|
||||
ambientExternalModules: result.ambientExternalModules,
|
||||
isLibFile: result.isLibFile
|
||||
isLibFile: result.isLibFile,
|
||||
typeReferenceDirectives: this.convertFileReferences(result.typeReferenceDirectives)
|
||||
};
|
||||
|
||||
forEach(result.referencedFiles, refFile => {
|
||||
convertResult.referencedFiles.push({
|
||||
path: normalizePath(refFile.fileName),
|
||||
position: refFile.pos,
|
||||
length: refFile.end - refFile.pos
|
||||
});
|
||||
});
|
||||
|
||||
forEach(result.importedFiles, importedFile => {
|
||||
convertResult.importedFiles.push({
|
||||
path: normalizeSlashes(importedFile.fileName),
|
||||
position: importedFile.pos,
|
||||
length: importedFile.end - importedFile.pos
|
||||
});
|
||||
});
|
||||
return convertResult;
|
||||
});
|
||||
}
|
||||
|
||||
private convertFileReferences(refs: FileReference[]): IFileReference[] {
|
||||
if (!refs) {
|
||||
return undefined;
|
||||
}
|
||||
const result: IFileReference[] = [];
|
||||
for (const ref of refs) {
|
||||
result.push({
|
||||
path: normalizeSlashes(ref.fileName),
|
||||
position: ref.pos,
|
||||
length: ref.end - ref.pos
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public getTSConfigFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string {
|
||||
return this.forwardJSONCall(
|
||||
`getTSConfigFileInfo('${fileName}')`,
|
||||
|
|
17
tests/baselines/reference/library-reference-1.js
Normal file
17
tests/baselines/reference/library-reference-1.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
//// [tests/cases/conformance/references/library-reference-1.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
// We can find typings in the ./types folder
|
||||
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
//// [consumer.ts]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
|
||||
|
||||
//// [consumer.js]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
16
tests/baselines/reference/library-reference-1.symbols
Normal file
16
tests/baselines/reference/library-reference-1.symbols
Normal file
|
@ -0,0 +1,16 @@
|
|||
=== /consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo : Symbol(foo, Decl(index.d.ts, 3, 16))
|
||||
>$ : Symbol($, Decl(index.d.ts, 3, 11))
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 3, 16))
|
||||
|
||||
=== /types/jquery/index.d.ts ===
|
||||
|
||||
// We can find typings in the ./types folder
|
||||
|
||||
declare var $: { foo(): void };
|
||||
>$ : Symbol($, Decl(index.d.ts, 3, 11))
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 3, 16))
|
||||
|
||||
|
7
tests/baselines/reference/library-reference-1.trace.json
Normal file
7
tests/baselines/reference/library-reference-1.trace.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/'. ========",
|
||||
"Resolving with primary search path '/types/'",
|
||||
"File '/types/jquery/package.json' does not exist.",
|
||||
"File '/types/jquery/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/index.d.ts', primary: true. ========"
|
||||
]
|
17
tests/baselines/reference/library-reference-1.types
Normal file
17
tests/baselines/reference/library-reference-1.types
Normal file
|
@ -0,0 +1,17 @@
|
|||
=== /consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo() : void
|
||||
>$.foo : () => void
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
=== /types/jquery/index.d.ts ===
|
||||
|
||||
// We can find typings in the ./types folder
|
||||
|
||||
declare var $: { foo(): void };
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
|
22
tests/baselines/reference/library-reference-10.js
Normal file
22
tests/baselines/reference/library-reference-10.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
//// [tests/cases/conformance/references/library-reference-10.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
|
||||
// package.json in a primary reference can refer to another file
|
||||
|
||||
{
|
||||
"typings": "jquery.d.ts"
|
||||
}
|
||||
|
||||
//// [jquery.d.ts]
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
//// [consumer.ts]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
|
||||
|
||||
//// [consumer.js]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
13
tests/baselines/reference/library-reference-10.symbols
Normal file
13
tests/baselines/reference/library-reference-10.symbols
Normal file
|
@ -0,0 +1,13 @@
|
|||
=== /consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
|
||||
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
|
||||
=== /types/jquery/jquery.d.ts ===
|
||||
declare var $: { foo(): void };
|
||||
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
|
||||
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/'. ========",
|
||||
"Resolving with primary search path '/types/'",
|
||||
"Found 'package.json' at '/types/jquery/package.json'.",
|
||||
"'package.json' has 'typings' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
|
||||
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========"
|
||||
]
|
14
tests/baselines/reference/library-reference-10.types
Normal file
14
tests/baselines/reference/library-reference-10.types
Normal file
|
@ -0,0 +1,14 @@
|
|||
=== /consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo() : void
|
||||
>$.foo : () => void
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
=== /types/jquery/jquery.d.ts ===
|
||||
declare var $: { foo(): void };
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
|
22
tests/baselines/reference/library-reference-11.js
Normal file
22
tests/baselines/reference/library-reference-11.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
//// [tests/cases/conformance/references/library-reference-11.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
|
||||
// package.json in a secondary reference can refer to another file
|
||||
|
||||
{
|
||||
"typings": "jquery.d.ts"
|
||||
}
|
||||
|
||||
//// [jquery.d.ts]
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
//// [consumer.ts]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
|
||||
|
||||
//// [consumer.js]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
13
tests/baselines/reference/library-reference-11.symbols
Normal file
13
tests/baselines/reference/library-reference-11.symbols
Normal file
|
@ -0,0 +1,13 @@
|
|||
=== /a/b/consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
|
||||
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
|
||||
=== /a/node_modules/jquery/jquery.d.ts ===
|
||||
declare var $: { foo(): void };
|
||||
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
|
||||
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
|
||||
|
21
tests/baselines/reference/library-reference-11.trace.json
Normal file
21
tests/baselines/reference/library-reference-11.trace.json
Normal file
|
@ -0,0 +1,21 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========",
|
||||
"Root directory cannot be determined, skipping primary search paths.",
|
||||
"Looking up in 'node_modules' folder, initial location '/a/b'",
|
||||
"File '/a/b/node_modules/jquery.ts' does not exist.",
|
||||
"File '/a/b/node_modules/jquery.d.ts' does not exist.",
|
||||
"File '/a/b/node_modules/jquery/package.json' does not exist.",
|
||||
"File '/a/b/node_modules/jquery/index.ts' does not exist.",
|
||||
"File '/a/b/node_modules/jquery/index.d.ts' does not exist.",
|
||||
"File '/a/b/node_modules/@types/jquery.ts' does not exist.",
|
||||
"File '/a/b/node_modules/@types/jquery.d.ts' does not exist.",
|
||||
"File '/a/b/node_modules/@types/jquery/package.json' does not exist.",
|
||||
"File '/a/b/node_modules/@types/jquery/index.ts' does not exist.",
|
||||
"File '/a/b/node_modules/@types/jquery/index.d.ts' does not exist.",
|
||||
"File '/a/node_modules/jquery.ts' does not exist.",
|
||||
"File '/a/node_modules/jquery.d.ts' does not exist.",
|
||||
"Found 'package.json' at '/a/node_modules/jquery/package.json'.",
|
||||
"'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.",
|
||||
"======== Type reference directive 'jquery' was successfully resolved to '/a/node_modules/jquery/jquery.d.ts', primary: false. ========"
|
||||
]
|
14
tests/baselines/reference/library-reference-11.types
Normal file
14
tests/baselines/reference/library-reference-11.types
Normal file
|
@ -0,0 +1,14 @@
|
|||
=== /a/b/consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo() : void
|
||||
>$.foo : () => void
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
=== /a/node_modules/jquery/jquery.d.ts ===
|
||||
declare var $: { foo(): void };
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
|
22
tests/baselines/reference/library-reference-12.js
Normal file
22
tests/baselines/reference/library-reference-12.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
//// [tests/cases/conformance/references/library-reference-12.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
|
||||
// package.json in a secondary reference can refer to another file
|
||||
|
||||
{
|
||||
"types": "dist/jquery.d.ts"
|
||||
}
|
||||
|
||||
//// [jquery.d.ts]
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
//// [consumer.ts]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
|
||||
|
||||
//// [consumer.js]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
13
tests/baselines/reference/library-reference-12.symbols
Normal file
13
tests/baselines/reference/library-reference-12.symbols
Normal file
|
@ -0,0 +1,13 @@
|
|||
=== /a/b/consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
|
||||
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
|
||||
=== /a/node_modules/jquery/dist/jquery.d.ts ===
|
||||
declare var $: { foo(): void };
|
||||
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
|
||||
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
|
||||
|
21
tests/baselines/reference/library-reference-12.trace.json
Normal file
21
tests/baselines/reference/library-reference-12.trace.json
Normal file
|
@ -0,0 +1,21 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========",
|
||||
"Root directory cannot be determined, skipping primary search paths.",
|
||||
"Looking up in 'node_modules' folder, initial location '/a/b'",
|
||||
"File '/a/b/node_modules/jquery.ts' does not exist.",
|
||||
"File '/a/b/node_modules/jquery.d.ts' does not exist.",
|
||||
"File '/a/b/node_modules/jquery/package.json' does not exist.",
|
||||
"File '/a/b/node_modules/jquery/index.ts' does not exist.",
|
||||
"File '/a/b/node_modules/jquery/index.d.ts' does not exist.",
|
||||
"File '/a/b/node_modules/@types/jquery.ts' does not exist.",
|
||||
"File '/a/b/node_modules/@types/jquery.d.ts' does not exist.",
|
||||
"File '/a/b/node_modules/@types/jquery/package.json' does not exist.",
|
||||
"File '/a/b/node_modules/@types/jquery/index.ts' does not exist.",
|
||||
"File '/a/b/node_modules/@types/jquery/index.d.ts' does not exist.",
|
||||
"File '/a/node_modules/jquery.ts' does not exist.",
|
||||
"File '/a/node_modules/jquery.d.ts' does not exist.",
|
||||
"Found 'package.json' at '/a/node_modules/jquery/package.json'.",
|
||||
"'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.",
|
||||
"======== Type reference directive 'jquery' was successfully resolved to '/a/node_modules/jquery/dist/jquery.d.ts', primary: false. ========"
|
||||
]
|
14
tests/baselines/reference/library-reference-12.types
Normal file
14
tests/baselines/reference/library-reference-12.types
Normal file
|
@ -0,0 +1,14 @@
|
|||
=== /a/b/consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo() : void
|
||||
>$.foo : () => void
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
=== /a/node_modules/jquery/dist/jquery.d.ts ===
|
||||
declare var $: { foo(): void };
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
|
12
tests/baselines/reference/library-reference-13.js
Normal file
12
tests/baselines/reference/library-reference-13.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
//// [tests/cases/conformance/references/library-reference-13.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
//// [consumer.ts]
|
||||
$.foo();
|
||||
|
||||
|
||||
//// [consumer.js]
|
||||
$.foo();
|
12
tests/baselines/reference/library-reference-13.symbols
Normal file
12
tests/baselines/reference/library-reference-13.symbols
Normal file
|
@ -0,0 +1,12 @@
|
|||
=== /a/b/consumer.ts ===
|
||||
$.foo();
|
||||
>$.foo : Symbol(foo, Decl(index.d.ts, 0, 16))
|
||||
>$ : Symbol($, Decl(index.d.ts, 0, 11))
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 0, 16))
|
||||
|
||||
=== /a/types/jquery/index.d.ts ===
|
||||
declare var $: { foo(): void };
|
||||
>$ : Symbol($, Decl(index.d.ts, 0, 11))
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 0, 16))
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file not set, root directory '/a'. ========",
|
||||
"Resolving with primary search path '/a/types/'",
|
||||
"File '/a/types/jquery/package.json' does not exist.",
|
||||
"File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'jquery' was successfully resolved to '/a/types/jquery/index.d.ts', primary: true. ========"
|
||||
]
|
13
tests/baselines/reference/library-reference-13.types
Normal file
13
tests/baselines/reference/library-reference-13.types
Normal file
|
@ -0,0 +1,13 @@
|
|||
=== /a/b/consumer.ts ===
|
||||
$.foo();
|
||||
>$.foo() : void
|
||||
>$.foo : () => void
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
=== /a/types/jquery/index.d.ts ===
|
||||
declare var $: { foo(): void };
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
|
13
tests/baselines/reference/library-reference-14.js
Normal file
13
tests/baselines/reference/library-reference-14.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
//// [tests/cases/conformance/references/library-reference-14.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
//// [consumer.ts]
|
||||
$.foo();
|
||||
|
||||
|
||||
//// [consumer.js]
|
||||
$.foo();
|
13
tests/baselines/reference/library-reference-14.symbols
Normal file
13
tests/baselines/reference/library-reference-14.symbols
Normal file
|
@ -0,0 +1,13 @@
|
|||
=== /a/b/consumer.ts ===
|
||||
$.foo();
|
||||
>$.foo : Symbol(foo, Decl(index.d.ts, 1, 16))
|
||||
>$ : Symbol($, Decl(index.d.ts, 1, 11))
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 1, 16))
|
||||
|
||||
=== /a/types/jquery/index.d.ts ===
|
||||
|
||||
declare var $: { foo(): void };
|
||||
>$ : Symbol($, Decl(index.d.ts, 1, 11))
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 1, 16))
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file not set, root directory '/a'. ========",
|
||||
"Resolving with primary search path '/a/types/'",
|
||||
"File '/a/types/jquery/package.json' does not exist.",
|
||||
"File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'jquery' was successfully resolved to '/a/types/jquery/index.d.ts', primary: true. ========"
|
||||
]
|
14
tests/baselines/reference/library-reference-14.types
Normal file
14
tests/baselines/reference/library-reference-14.types
Normal file
|
@ -0,0 +1,14 @@
|
|||
=== /a/b/consumer.ts ===
|
||||
$.foo();
|
||||
>$.foo() : void
|
||||
>$.foo : () => void
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
=== /a/types/jquery/index.d.ts ===
|
||||
|
||||
declare var $: { foo(): void };
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
|
15
tests/baselines/reference/library-reference-15.errors.txt
Normal file
15
tests/baselines/reference/library-reference-15.errors.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
error TS2304: Cannot find name 'jquery'.
|
||||
/a/b/consumer.ts(1,1): error TS2304: Cannot find name '$'.
|
||||
|
||||
|
||||
!!! error TS2304: Cannot find name 'jquery'.
|
||||
==== /a/b/consumer.ts (1 errors) ====
|
||||
$.foo();
|
||||
~
|
||||
!!! error TS2304: Cannot find name '$'.
|
||||
|
||||
==== /a/types/jquery/index.d.ts (0 errors) ====
|
||||
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
13
tests/baselines/reference/library-reference-15.js
Normal file
13
tests/baselines/reference/library-reference-15.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
//// [tests/cases/conformance/references/library-reference-15.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
//// [consumer.ts]
|
||||
$.foo();
|
||||
|
||||
|
||||
//// [consumer.js]
|
||||
$.foo();
|
|
@ -0,0 +1,5 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file not set, root directory not set. ========",
|
||||
"Root directory cannot be determined, skipping primary search paths.",
|
||||
"Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder."
|
||||
]
|
22
tests/baselines/reference/library-reference-2.js
Normal file
22
tests/baselines/reference/library-reference-2.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
//// [tests/cases/conformance/references/library-reference-2.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
|
||||
// package.json in a primary reference can refer to another file
|
||||
|
||||
{
|
||||
"types": "jquery.d.ts"
|
||||
}
|
||||
|
||||
//// [jquery.d.ts]
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
//// [consumer.ts]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
|
||||
|
||||
//// [consumer.js]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
13
tests/baselines/reference/library-reference-2.symbols
Normal file
13
tests/baselines/reference/library-reference-2.symbols
Normal file
|
@ -0,0 +1,13 @@
|
|||
=== /consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
|
||||
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
|
||||
=== /types/jquery/jquery.d.ts ===
|
||||
declare var $: { foo(): void };
|
||||
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
|
||||
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
|
||||
|
||||
|
8
tests/baselines/reference/library-reference-2.trace.json
Normal file
8
tests/baselines/reference/library-reference-2.trace.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/'. ========",
|
||||
"Resolving with primary search path '/types/'",
|
||||
"Found 'package.json' at '/types/jquery/package.json'.",
|
||||
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
|
||||
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========"
|
||||
]
|
14
tests/baselines/reference/library-reference-2.types
Normal file
14
tests/baselines/reference/library-reference-2.types
Normal file
|
@ -0,0 +1,14 @@
|
|||
=== /consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo() : void
|
||||
>$.foo : () => void
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
=== /types/jquery/jquery.d.ts ===
|
||||
declare var $: { foo(): void };
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
|
16
tests/baselines/reference/library-reference-3.js
Normal file
16
tests/baselines/reference/library-reference-3.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
//// [tests/cases/conformance/references/library-reference-3.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
// Secondary references are possible
|
||||
|
||||
declare var $: { foo(): void };
|
||||
|
||||
//// [consumer.ts]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
|
||||
|
||||
//// [consumer.js]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
15
tests/baselines/reference/library-reference-3.symbols
Normal file
15
tests/baselines/reference/library-reference-3.symbols
Normal file
|
@ -0,0 +1,15 @@
|
|||
=== /src/consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo : Symbol(foo, Decl(index.d.ts, 3, 16))
|
||||
>$ : Symbol($, Decl(index.d.ts, 3, 11))
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 3, 16))
|
||||
|
||||
=== /src/node_modules/jquery/index.d.ts ===
|
||||
|
||||
// Secondary references are possible
|
||||
|
||||
declare var $: { foo(): void };
|
||||
>$ : Symbol($, Decl(index.d.ts, 3, 11))
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 3, 16))
|
||||
|
10
tests/baselines/reference/library-reference-3.trace.json
Normal file
10
tests/baselines/reference/library-reference-3.trace.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/src'. ========",
|
||||
"Resolving with primary search path '/src/types/'",
|
||||
"File '/src/types/jquery/package.json' does not exist.",
|
||||
"File '/src/types/jquery/index.d.ts' does not exist.",
|
||||
"Resolving with primary search path '/src/node_modules/'",
|
||||
"File '/src/node_modules/jquery/package.json' does not exist.",
|
||||
"File '/src/node_modules/jquery/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: true. ========"
|
||||
]
|
16
tests/baselines/reference/library-reference-3.types
Normal file
16
tests/baselines/reference/library-reference-3.types
Normal file
|
@ -0,0 +1,16 @@
|
|||
=== /src/consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo() : void
|
||||
>$.foo : () => void
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
=== /src/node_modules/jquery/index.d.ts ===
|
||||
|
||||
// Secondary references are possible
|
||||
|
||||
declare var $: { foo(): void };
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
27
tests/baselines/reference/library-reference-4.js
Normal file
27
tests/baselines/reference/library-reference-4.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
//// [tests/cases/conformance/references/library-reference-4.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
// Secondary references may be duplicated if they agree in content
|
||||
|
||||
/// <reference types="alpha" />
|
||||
declare var foo: any;
|
||||
|
||||
//// [index.d.ts]
|
||||
declare var alpha: any;
|
||||
|
||||
//// [index.d.ts]
|
||||
/// <reference types="alpha" />
|
||||
declare var bar: any;
|
||||
|
||||
//// [index.d.ts]
|
||||
declare var alpha: any;
|
||||
|
||||
//// [root.ts]
|
||||
/// <reference types="foo" />
|
||||
/// <reference types="bar" />
|
||||
|
||||
|
||||
//// [root.js]
|
||||
/// <reference types="foo" />
|
||||
/// <reference types="bar" />
|
21
tests/baselines/reference/library-reference-4.symbols
Normal file
21
tests/baselines/reference/library-reference-4.symbols
Normal file
|
@ -0,0 +1,21 @@
|
|||
=== /src/root.ts ===
|
||||
/// <reference types="foo" />
|
||||
No type information for this code./// <reference types="bar" />
|
||||
No type information for this code.
|
||||
No type information for this code.=== /node_modules/foo/index.d.ts ===
|
||||
|
||||
// Secondary references may be duplicated if they agree in content
|
||||
|
||||
/// <reference types="alpha" />
|
||||
declare var foo: any;
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 4, 11))
|
||||
|
||||
=== /node_modules/foo/node_modules/alpha/index.d.ts ===
|
||||
declare var alpha: any;
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 0, 11))
|
||||
|
||||
=== /node_modules/bar/index.d.ts ===
|
||||
/// <reference types="alpha" />
|
||||
declare var bar: any;
|
||||
>bar : Symbol(bar, Decl(index.d.ts, 1, 11))
|
||||
|
90
tests/baselines/reference/library-reference-4.trace.json
Normal file
90
tests/baselines/reference/library-reference-4.trace.json
Normal file
|
@ -0,0 +1,90 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory '/src'. ========",
|
||||
"Resolving with primary search path '/src/types/'",
|
||||
"File '/src/types/foo/package.json' does not exist.",
|
||||
"File '/src/types/foo/index.d.ts' does not exist.",
|
||||
"Resolving with primary search path '/src/node_modules/'",
|
||||
"File '/src/node_modules/foo/package.json' does not exist.",
|
||||
"File '/src/node_modules/foo/index.d.ts' does not exist.",
|
||||
"Resolving with primary search path '/src/node_modules/@types/'",
|
||||
"File '/src/node_modules/@types/foo/package.json' does not exist.",
|
||||
"File '/src/node_modules/@types/foo/index.d.ts' does not exist.",
|
||||
"Looking up in 'node_modules' folder, initial location '/src'",
|
||||
"File '/src/node_modules/foo.ts' does not exist.",
|
||||
"File '/src/node_modules/foo.d.ts' does not exist.",
|
||||
"File '/src/node_modules/foo/package.json' does not exist.",
|
||||
"File '/src/node_modules/foo/index.ts' does not exist.",
|
||||
"File '/src/node_modules/foo/index.d.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/foo.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/foo.d.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/foo/package.json' does not exist.",
|
||||
"File '/src/node_modules/@types/foo/index.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/foo/index.d.ts' does not exist.",
|
||||
"File '/node_modules/foo.ts' does not exist.",
|
||||
"File '/node_modules/foo.d.ts' does not exist.",
|
||||
"File '/node_modules/foo/package.json' does not exist.",
|
||||
"File '/node_modules/foo/index.ts' does not exist.",
|
||||
"File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========",
|
||||
"======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory '/src'. ========",
|
||||
"Resolving with primary search path '/src/types/'",
|
||||
"File '/src/types/bar/package.json' does not exist.",
|
||||
"File '/src/types/bar/index.d.ts' does not exist.",
|
||||
"Resolving with primary search path '/src/node_modules/'",
|
||||
"File '/src/node_modules/bar/package.json' does not exist.",
|
||||
"File '/src/node_modules/bar/index.d.ts' does not exist.",
|
||||
"Resolving with primary search path '/src/node_modules/@types/'",
|
||||
"File '/src/node_modules/@types/bar/package.json' does not exist.",
|
||||
"File '/src/node_modules/@types/bar/index.d.ts' does not exist.",
|
||||
"Looking up in 'node_modules' folder, initial location '/src'",
|
||||
"File '/src/node_modules/bar.ts' does not exist.",
|
||||
"File '/src/node_modules/bar.d.ts' does not exist.",
|
||||
"File '/src/node_modules/bar/package.json' does not exist.",
|
||||
"File '/src/node_modules/bar/index.ts' does not exist.",
|
||||
"File '/src/node_modules/bar/index.d.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/bar.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/bar.d.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/bar/package.json' does not exist.",
|
||||
"File '/src/node_modules/@types/bar/index.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/bar/index.d.ts' does not exist.",
|
||||
"File '/node_modules/bar.ts' does not exist.",
|
||||
"File '/node_modules/bar.d.ts' does not exist.",
|
||||
"File '/node_modules/bar/package.json' does not exist.",
|
||||
"File '/node_modules/bar/index.ts' does not exist.",
|
||||
"File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== 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/types/'",
|
||||
"File '/src/types/alpha/package.json' does not exist.",
|
||||
"File '/src/types/alpha/index.d.ts' does not exist.",
|
||||
"Resolving with primary search path '/src/node_modules/'",
|
||||
"File '/src/node_modules/alpha/package.json' does not exist.",
|
||||
"File '/src/node_modules/alpha/index.d.ts' does not exist.",
|
||||
"Resolving with primary search path '/src/node_modules/@types/'",
|
||||
"File '/src/node_modules/@types/alpha/package.json' does not exist.",
|
||||
"File '/src/node_modules/@types/alpha/index.d.ts' does not exist.",
|
||||
"Looking up in 'node_modules' folder, initial location '/node_modules/foo'",
|
||||
"File '/node_modules/foo/node_modules/alpha.ts' does not exist.",
|
||||
"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/index.ts' does not exist.",
|
||||
"File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== 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/types/'",
|
||||
"File '/src/types/alpha/package.json' does not exist.",
|
||||
"File '/src/types/alpha/index.d.ts' does not exist.",
|
||||
"Resolving with primary search path '/src/node_modules/'",
|
||||
"File '/src/node_modules/alpha/package.json' does not exist.",
|
||||
"File '/src/node_modules/alpha/index.d.ts' does not exist.",
|
||||
"Resolving with primary search path '/src/node_modules/@types/'",
|
||||
"File '/src/node_modules/@types/alpha/package.json' does not exist.",
|
||||
"File '/src/node_modules/@types/alpha/index.d.ts' does not exist.",
|
||||
"Looking up in 'node_modules' folder, initial location '/node_modules/bar'",
|
||||
"File '/node_modules/bar/node_modules/alpha.ts' does not exist.",
|
||||
"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/index.ts' does not exist.",
|
||||
"File '/node_modules/bar/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========"
|
||||
]
|
21
tests/baselines/reference/library-reference-4.types
Normal file
21
tests/baselines/reference/library-reference-4.types
Normal file
|
@ -0,0 +1,21 @@
|
|||
=== /src/root.ts ===
|
||||
/// <reference types="foo" />
|
||||
No type information for this code./// <reference types="bar" />
|
||||
No type information for this code.
|
||||
No type information for this code.=== /node_modules/foo/index.d.ts ===
|
||||
|
||||
// Secondary references may be duplicated if they agree in content
|
||||
|
||||
/// <reference types="alpha" />
|
||||
declare var foo: any;
|
||||
>foo : any
|
||||
|
||||
=== /node_modules/foo/node_modules/alpha/index.d.ts ===
|
||||
declare var alpha: any;
|
||||
>alpha : any
|
||||
|
||||
=== /node_modules/bar/index.d.ts ===
|
||||
/// <reference types="alpha" />
|
||||
declare var bar: any;
|
||||
>bar : any
|
||||
|
26
tests/baselines/reference/library-reference-5.errors.txt
Normal file
26
tests/baselines/reference/library-reference-5.errors.txt
Normal file
|
@ -0,0 +1,26 @@
|
|||
/node_modules/bar/index.d.ts(1,1): message TS4090: Conflicting library definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Copy the correct file to the 'typings' folder to resolve this conflict.
|
||||
|
||||
|
||||
==== /src/root.ts (0 errors) ====
|
||||
/// <reference types="foo" />
|
||||
/// <reference types="bar" />
|
||||
|
||||
==== /node_modules/foo/index.d.ts (0 errors) ====
|
||||
|
||||
// Secondary references may not be duplicated if they disagree in content
|
||||
|
||||
/// <reference types="alpha" />
|
||||
declare var foo: any;
|
||||
|
||||
==== /node_modules/foo/node_modules/alpha/index.d.ts (0 errors) ====
|
||||
declare var alpha: any;
|
||||
|
||||
==== /node_modules/bar/index.d.ts (1 errors) ====
|
||||
/// <reference types="alpha" />
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! message TS4090: Conflicting library definitions for 'alpha' found at 'index.d.ts' and 'index.d.ts'. Copy the correct file to the 'typings' folder to resolve this conflict.
|
||||
declare var bar: any;
|
||||
|
||||
==== /node_modules/bar/node_modules/alpha/index.d.ts (0 errors) ====
|
||||
declare var alpha: {};
|
||||
|
27
tests/baselines/reference/library-reference-5.js
Normal file
27
tests/baselines/reference/library-reference-5.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
//// [tests/cases/conformance/references/library-reference-5.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
// Secondary references may not be duplicated if they disagree in content
|
||||
|
||||
/// <reference types="alpha" />
|
||||
declare var foo: any;
|
||||
|
||||
//// [index.d.ts]
|
||||
declare var alpha: any;
|
||||
|
||||
//// [index.d.ts]
|
||||
/// <reference types="alpha" />
|
||||
declare var bar: any;
|
||||
|
||||
//// [index.d.ts]
|
||||
declare var alpha: {};
|
||||
|
||||
//// [root.ts]
|
||||
/// <reference types="foo" />
|
||||
/// <reference types="bar" />
|
||||
|
||||
|
||||
//// [root.js]
|
||||
/// <reference types="foo" />
|
||||
/// <reference types="bar" />
|
58
tests/baselines/reference/library-reference-5.trace.json
Normal file
58
tests/baselines/reference/library-reference-5.trace.json
Normal file
|
@ -0,0 +1,58 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'foo', containing file '/src/root.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/foo.ts' does not exist.",
|
||||
"File '/src/node_modules/foo.d.ts' does not exist.",
|
||||
"File '/src/node_modules/foo/package.json' does not exist.",
|
||||
"File '/src/node_modules/foo/index.ts' does not exist.",
|
||||
"File '/src/node_modules/foo/index.d.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/foo.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/foo.d.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/foo/package.json' does not exist.",
|
||||
"File '/src/node_modules/@types/foo/index.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/foo/index.d.ts' does not exist.",
|
||||
"File '/node_modules/foo.ts' does not exist.",
|
||||
"File '/node_modules/foo.d.ts' does not exist.",
|
||||
"File '/node_modules/foo/package.json' does not exist.",
|
||||
"File '/node_modules/foo/index.ts' does not exist.",
|
||||
"File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========",
|
||||
"======== Resolving type reference directive 'bar', containing file '/src/root.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/bar.ts' does not exist.",
|
||||
"File '/src/node_modules/bar.d.ts' does not exist.",
|
||||
"File '/src/node_modules/bar/package.json' does not exist.",
|
||||
"File '/src/node_modules/bar/index.ts' does not exist.",
|
||||
"File '/src/node_modules/bar/index.d.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/bar.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/bar.d.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/bar/package.json' does not exist.",
|
||||
"File '/src/node_modules/@types/bar/index.ts' does not exist.",
|
||||
"File '/src/node_modules/@types/bar/index.d.ts' does not exist.",
|
||||
"File '/node_modules/bar.ts' does not exist.",
|
||||
"File '/node_modules/bar.d.ts' does not exist.",
|
||||
"File '/node_modules/bar/package.json' does not exist.",
|
||||
"File '/node_modules/bar/index.ts' does not exist.",
|
||||
"File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== 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 not set. ========",
|
||||
"Root directory cannot be determined, skipping primary search paths.",
|
||||
"Looking up in 'node_modules' folder, initial location '/node_modules/foo'",
|
||||
"File '/node_modules/foo/node_modules/alpha.ts' does not exist.",
|
||||
"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/index.ts' does not exist.",
|
||||
"File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== 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 not set. ========",
|
||||
"Root directory cannot be determined, skipping primary search paths.",
|
||||
"Looking up in 'node_modules' folder, initial location '/node_modules/bar'",
|
||||
"File '/node_modules/bar/node_modules/alpha.ts' does not exist.",
|
||||
"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/index.ts' does not exist.",
|
||||
"File '/node_modules/bar/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========"
|
||||
]
|
16
tests/baselines/reference/library-reference-6.js
Normal file
16
tests/baselines/reference/library-reference-6.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
//// [tests/cases/conformance/references/library-reference-6.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
// The primary lookup folder is relative to tsconfig.json, if present
|
||||
|
||||
declare var alpha: { a: string };
|
||||
|
||||
//// [foo.ts]
|
||||
/// <reference types="alpha" />
|
||||
var x: string = alpha.a;
|
||||
|
||||
|
||||
//// [foo.js]
|
||||
/// <reference types="alpha" />
|
||||
var x = alpha.a;
|
16
tests/baselines/reference/library-reference-6.symbols
Normal file
16
tests/baselines/reference/library-reference-6.symbols
Normal file
|
@ -0,0 +1,16 @@
|
|||
=== /src/foo.ts ===
|
||||
/// <reference types="alpha" />
|
||||
var x: string = alpha.a;
|
||||
>x : Symbol(x, Decl(foo.ts, 1, 3))
|
||||
>alpha.a : Symbol(a, Decl(index.d.ts, 3, 20))
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 3, 11))
|
||||
>a : Symbol(a, Decl(index.d.ts, 3, 20))
|
||||
|
||||
=== /types/alpha/index.d.ts ===
|
||||
|
||||
// The primary lookup folder is relative to tsconfig.json, if present
|
||||
|
||||
declare var alpha: { a: string };
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 3, 11))
|
||||
>a : Symbol(a, Decl(index.d.ts, 3, 20))
|
||||
|
7
tests/baselines/reference/library-reference-6.trace.json
Normal file
7
tests/baselines/reference/library-reference-6.trace.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'alpha', containing file '/src/foo.ts', root directory '/'. ========",
|
||||
"Resolving with primary search path '/types/'",
|
||||
"File '/types/alpha/package.json' does not exist.",
|
||||
"File '/types/alpha/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'alpha' was successfully resolved to '/types/alpha/index.d.ts', primary: true. ========"
|
||||
]
|
16
tests/baselines/reference/library-reference-6.types
Normal file
16
tests/baselines/reference/library-reference-6.types
Normal file
|
@ -0,0 +1,16 @@
|
|||
=== /src/foo.ts ===
|
||||
/// <reference types="alpha" />
|
||||
var x: string = alpha.a;
|
||||
>x : string
|
||||
>alpha.a : string
|
||||
>alpha : { a: string; }
|
||||
>a : string
|
||||
|
||||
=== /types/alpha/index.d.ts ===
|
||||
|
||||
// The primary lookup folder is relative to tsconfig.json, if present
|
||||
|
||||
declare var alpha: { a: string };
|
||||
>alpha : { a: string; }
|
||||
>a : string
|
||||
|
16
tests/baselines/reference/library-reference-7.js
Normal file
16
tests/baselines/reference/library-reference-7.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
//// [tests/cases/conformance/references/library-reference-7.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
// Secondary references are possible
|
||||
|
||||
declare var $: { foo(): void };
|
||||
|
||||
//// [consumer.ts]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
|
||||
|
||||
//// [consumer.js]
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
15
tests/baselines/reference/library-reference-7.symbols
Normal file
15
tests/baselines/reference/library-reference-7.symbols
Normal file
|
@ -0,0 +1,15 @@
|
|||
=== /src/consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo : Symbol(foo, Decl(index.d.ts, 3, 16))
|
||||
>$ : Symbol($, Decl(index.d.ts, 3, 11))
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 3, 16))
|
||||
|
||||
=== /src/node_modules/jquery/index.d.ts ===
|
||||
|
||||
// Secondary references are possible
|
||||
|
||||
declare var $: { foo(): void };
|
||||
>$ : Symbol($, Decl(index.d.ts, 3, 11))
|
||||
>foo : Symbol(foo, Decl(index.d.ts, 3, 16))
|
||||
|
11
tests/baselines/reference/library-reference-7.trace.json
Normal file
11
tests/baselines/reference/library-reference-7.trace.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
[
|
||||
"======== 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.ts' does not exist.",
|
||||
"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/index.ts' does not exist.",
|
||||
"File '/src/node_modules/jquery/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: false. ========"
|
||||
]
|
16
tests/baselines/reference/library-reference-7.types
Normal file
16
tests/baselines/reference/library-reference-7.types
Normal file
|
@ -0,0 +1,16 @@
|
|||
=== /src/consumer.ts ===
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
||||
>$.foo() : void
|
||||
>$.foo : () => void
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
||||
=== /src/node_modules/jquery/index.d.ts ===
|
||||
|
||||
// Secondary references are possible
|
||||
|
||||
declare var $: { foo(): void };
|
||||
>$ : { foo(): void; }
|
||||
>foo : () => void
|
||||
|
24
tests/baselines/reference/library-reference-8.js
Normal file
24
tests/baselines/reference/library-reference-8.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
//// [tests/cases/conformance/references/library-reference-8.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
// Don't crash in circular library reference situations
|
||||
|
||||
/// <reference types="beta" />
|
||||
declare var alpha: { a: string };
|
||||
|
||||
//// [index.d.ts]
|
||||
/// <reference types="alpha" />
|
||||
declare var beta: { b: string };
|
||||
|
||||
//// [foo.ts]
|
||||
/// <reference types="alpha" />
|
||||
/// <reference types="beta" />
|
||||
var x: string = alpha.a + beta.b;
|
||||
|
||||
|
||||
|
||||
//// [foo.js]
|
||||
/// <reference types="alpha" />
|
||||
/// <reference types="beta" />
|
||||
var x = alpha.a + beta.b;
|
28
tests/baselines/reference/library-reference-8.symbols
Normal file
28
tests/baselines/reference/library-reference-8.symbols
Normal file
|
@ -0,0 +1,28 @@
|
|||
=== /foo.ts ===
|
||||
/// <reference types="alpha" />
|
||||
/// <reference types="beta" />
|
||||
var x: string = alpha.a + beta.b;
|
||||
>x : Symbol(x, Decl(foo.ts, 2, 3))
|
||||
>alpha.a : Symbol(a, Decl(index.d.ts, 4, 20))
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 4, 11))
|
||||
>a : Symbol(a, Decl(index.d.ts, 4, 20))
|
||||
>beta.b : Symbol(b, Decl(index.d.ts, 1, 19))
|
||||
>beta : Symbol(beta, Decl(index.d.ts, 1, 11))
|
||||
>b : Symbol(b, Decl(index.d.ts, 1, 19))
|
||||
|
||||
|
||||
=== /types/alpha/index.d.ts ===
|
||||
|
||||
// Don't crash in circular library reference situations
|
||||
|
||||
/// <reference types="beta" />
|
||||
declare var alpha: { a: string };
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 4, 11))
|
||||
>a : Symbol(a, Decl(index.d.ts, 4, 20))
|
||||
|
||||
=== /types/beta/index.d.ts ===
|
||||
/// <reference types="alpha" />
|
||||
declare var beta: { b: string };
|
||||
>beta : Symbol(beta, Decl(index.d.ts, 1, 11))
|
||||
>b : Symbol(b, Decl(index.d.ts, 1, 19))
|
||||
|
22
tests/baselines/reference/library-reference-8.trace.json
Normal file
22
tests/baselines/reference/library-reference-8.trace.json
Normal file
|
@ -0,0 +1,22 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'alpha', containing file '/foo.ts', root directory '/'. ========",
|
||||
"Resolving with primary search path '/types/'",
|
||||
"File '/types/alpha/package.json' does not exist.",
|
||||
"File '/types/alpha/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'alpha' was successfully resolved to '/types/alpha/index.d.ts', primary: true. ========",
|
||||
"======== Resolving type reference directive 'beta', containing file '/foo.ts', root directory '/'. ========",
|
||||
"Resolving with primary search path '/types/'",
|
||||
"File '/types/beta/package.json' does not exist.",
|
||||
"File '/types/beta/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'beta' was successfully resolved to '/types/beta/index.d.ts', primary: true. ========",
|
||||
"======== Resolving type reference directive 'beta', containing file '/types/alpha/index.d.ts', root directory '/'. ========",
|
||||
"Resolving with primary search path '/types/'",
|
||||
"File '/types/beta/package.json' does not exist.",
|
||||
"File '/types/beta/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'beta' was successfully resolved to '/types/beta/index.d.ts', primary: true. ========",
|
||||
"======== Resolving type reference directive 'alpha', containing file '/types/beta/index.d.ts', root directory '/'. ========",
|
||||
"Resolving with primary search path '/types/'",
|
||||
"File '/types/alpha/package.json' does not exist.",
|
||||
"File '/types/alpha/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'alpha' was successfully resolved to '/types/alpha/index.d.ts', primary: true. ========"
|
||||
]
|
29
tests/baselines/reference/library-reference-8.types
Normal file
29
tests/baselines/reference/library-reference-8.types
Normal file
|
@ -0,0 +1,29 @@
|
|||
=== /foo.ts ===
|
||||
/// <reference types="alpha" />
|
||||
/// <reference types="beta" />
|
||||
var x: string = alpha.a + beta.b;
|
||||
>x : string
|
||||
>alpha.a + beta.b : string
|
||||
>alpha.a : string
|
||||
>alpha : { a: string; }
|
||||
>a : string
|
||||
>beta.b : string
|
||||
>beta : { b: string; }
|
||||
>b : string
|
||||
|
||||
|
||||
=== /types/alpha/index.d.ts ===
|
||||
|
||||
// Don't crash in circular library reference situations
|
||||
|
||||
/// <reference types="beta" />
|
||||
declare var alpha: { a: string };
|
||||
>alpha : { a: string; }
|
||||
>a : string
|
||||
|
||||
=== /types/beta/index.d.ts ===
|
||||
/// <reference types="alpha" />
|
||||
declare var beta: { b: string };
|
||||
>beta : { b: string; }
|
||||
>b : string
|
||||
|
16
tests/baselines/reference/library-reference-9.js
Normal file
16
tests/baselines/reference/library-reference-9.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
//// [tests/cases/conformance/references/library-reference-9.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
|
||||
// Use types search path
|
||||
|
||||
declare var alpha: { a: string };
|
||||
|
||||
//// [foo.ts]
|
||||
/// <reference types="alpha" />
|
||||
var x: string = alpha.a;
|
||||
|
||||
|
||||
//// [foo.js]
|
||||
/// <reference types="alpha" />
|
||||
var x = alpha.a;
|
16
tests/baselines/reference/library-reference-9.symbols
Normal file
16
tests/baselines/reference/library-reference-9.symbols
Normal file
|
@ -0,0 +1,16 @@
|
|||
=== /base/src/foo.ts ===
|
||||
/// <reference types="alpha" />
|
||||
var x: string = alpha.a;
|
||||
>x : Symbol(x, Decl(foo.ts, 1, 3))
|
||||
>alpha.a : Symbol(a, Decl(index.d.ts, 3, 20))
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 3, 11))
|
||||
>a : Symbol(a, Decl(index.d.ts, 3, 20))
|
||||
|
||||
=== /share/typelib/alpha/index.d.ts ===
|
||||
|
||||
// Use types search path
|
||||
|
||||
declare var alpha: { a: string };
|
||||
>alpha : Symbol(alpha, Decl(index.d.ts, 3, 11))
|
||||
>a : Symbol(a, Decl(index.d.ts, 3, 20))
|
||||
|
7
tests/baselines/reference/library-reference-9.trace.json
Normal file
7
tests/baselines/reference/library-reference-9.trace.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
[
|
||||
"======== Resolving type reference directive 'alpha', containing file '/base/src/foo.ts', root directory '/'. ========",
|
||||
"Resolving with primary search path '/share/typelib'",
|
||||
"File '/share/typelib/alpha/package.json' does not exist.",
|
||||
"File '/share/typelib/alpha/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Type reference directive 'alpha' was successfully resolved to '/share/typelib/alpha/index.d.ts', primary: true. ========"
|
||||
]
|
16
tests/baselines/reference/library-reference-9.types
Normal file
16
tests/baselines/reference/library-reference-9.types
Normal file
|
@ -0,0 +1,16 @@
|
|||
=== /base/src/foo.ts ===
|
||||
/// <reference types="alpha" />
|
||||
var x: string = alpha.a;
|
||||
>x : string
|
||||
>alpha.a : string
|
||||
>alpha : { a: string; }
|
||||
>a : string
|
||||
|
||||
=== /share/typelib/alpha/index.d.ts ===
|
||||
|
||||
// Use types search path
|
||||
|
||||
declare var alpha: { a: string };
|
||||
>alpha : { a: string; }
|
||||
>a : string
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'folder2/file2'",
|
||||
"Resolving module name 'folder2/file2' relative to base url 'c:/root' - 'c:/root/folder2/file2'.",
|
||||
"File 'c:/root/folder2/file2.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/folder2/file2.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'folder2/file2' was successfully resolved to 'c:/root/folder2/file2.ts'. ========",
|
||||
"======== Resolving module './file3' from 'c:/root/folder2/file2.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"File 'c:/root/folder2/file3.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/folder2/file3.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './file3' was successfully resolved to 'c:/root/folder2/file3.ts'. ========",
|
||||
"======== Resolving module 'file4' from 'c:/root/folder2/file2.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
|
@ -19,6 +19,6 @@
|
|||
"File 'c:/root/folder2/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"File 'c:/file4.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/file4.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/file4.ts'. ========"
|
||||
]
|
|
@ -4,12 +4,12 @@
|
|||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'folder2/file2'",
|
||||
"Resolving module name 'folder2/file2' relative to base url 'c:/root' - 'c:/root/folder2/file2'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/folder2/file2'.",
|
||||
"File 'c:/root/folder2/file2.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/folder2/file2.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'folder2/file2' was successfully resolved to 'c:/root/folder2/file2.ts'. ========",
|
||||
"======== Resolving module './file3' from 'c:/root/folder2/file2.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'NodeJs'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/folder2/file3'.",
|
||||
"File 'c:/root/folder2/file3.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/folder2/file3.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './file3' was successfully resolved to 'c:/root/folder2/file3.ts'. ========",
|
||||
"======== Resolving module 'file4' from 'c:/root/folder2/file2.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'NodeJs'.",
|
||||
|
@ -31,6 +31,13 @@
|
|||
"File 'c:/root/folder2/node_modules/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/file4/index.d.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4.tsx' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4/package.json' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4/index.d.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/file4.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/file4.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/file4.d.ts' does not exist.",
|
||||
|
@ -38,12 +45,19 @@
|
|||
"File 'c:/root/node_modules/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/file4/index.d.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/package.json' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/index.d.ts' 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 module resolution result.",
|
||||
"File 'c:/node_modules/file4/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/node_modules/file4/index.d.ts'. ========"
|
||||
]
|
|
@ -3,11 +3,11 @@
|
|||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'folder2/file2'",
|
||||
"Resolving module name 'folder2/file2' relative to base url 'c:/root' - 'c:/root/folder2/file2'.",
|
||||
"File 'c:/root/folder2/file2.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/folder2/file2.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'folder2/file2' was successfully resolved to 'c:/root/folder2/file2.ts'. ========",
|
||||
"======== Resolving module './file3' from 'c:/root/folder2/file2.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
"File 'c:/root/folder2/file3.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/folder2/file3.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './file3' was successfully resolved to 'c:/root/folder2/file3.ts'. ========",
|
||||
"======== Resolving module 'file4' from 'c:/root/folder2/file2.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'Classic'.",
|
||||
|
@ -19,6 +19,6 @@
|
|||
"File 'c:/root/folder2/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"File 'c:/file4.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/file4.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/file4.ts'. ========"
|
||||
]
|
|
@ -4,12 +4,12 @@
|
|||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'folder2/file2'",
|
||||
"Resolving module name 'folder2/file2' relative to base url 'c:/root' - 'c:/root/folder2/file2'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/folder2/file2'.",
|
||||
"File 'c:/root/folder2/file2.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/folder2/file2.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'folder2/file2' was successfully resolved to 'c:/root/folder2/file2.ts'. ========",
|
||||
"======== Resolving module './file3' from 'c:/root/folder2/file2.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'NodeJs'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/folder2/file3'.",
|
||||
"File 'c:/root/folder2/file3.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/folder2/file3.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './file3' was successfully resolved to 'c:/root/folder2/file3.ts'. ========",
|
||||
"======== Resolving module 'file4' from 'c:/root/folder2/file2.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'NodeJs'.",
|
||||
|
@ -31,6 +31,13 @@
|
|||
"File 'c:/root/folder2/node_modules/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/file4/index.d.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4.tsx' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4/package.json' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/@types/file4/index.d.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/file4.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/file4.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/file4.d.ts' does not exist.",
|
||||
|
@ -38,12 +45,19 @@
|
|||
"File 'c:/root/node_modules/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/file4/index.d.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/package.json' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/index.d.ts' 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 module resolution result.",
|
||||
"File 'c:/node_modules/file4/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/node_modules/file4/index.d.ts'. ========"
|
||||
]
|
|
@ -5,7 +5,7 @@
|
|||
"'paths' option is specified, looking for a pattern to match module name 'folder2/file1'.",
|
||||
"Module name 'folder2/file1', matched pattern '*'.",
|
||||
"Trying substitution '*', candidate module location: 'folder2/file1'.",
|
||||
"File 'c:/root/folder2/file1.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/folder2/file1.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'folder2/file1' was successfully resolved to 'c:/root/folder2/file1.ts'. ========",
|
||||
"======== Resolving module 'folder3/file2' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Classic'.",
|
||||
|
@ -16,7 +16,7 @@
|
|||
"File 'c:/root/folder3/file2.ts' does not exist.",
|
||||
"File 'c:/root/folder3/file2.d.ts' does not exist.",
|
||||
"Trying substitution 'generated/*', candidate module location: 'generated/folder3/file2'.",
|
||||
"File 'c:/root/generated/folder3/file2.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/generated/folder3/file2.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'folder3/file2' was successfully resolved to 'c:/root/generated/folder3/file2.ts'. ========",
|
||||
"======== Resolving module 'components/file3' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Classic'.",
|
||||
|
@ -24,7 +24,7 @@
|
|||
"'paths' option is specified, looking for a pattern to match module name 'components/file3'.",
|
||||
"Module name 'components/file3', matched pattern 'components/*'.",
|
||||
"Trying substitution 'shared/components/*', candidate module location: 'shared/components/file3'.",
|
||||
"File 'c:/root/shared/components/file3.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/shared/components/file3.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'components/file3' was successfully resolved to 'c:/root/shared/components/file3.ts'. ========",
|
||||
"======== Resolving module 'file4' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Classic'.",
|
||||
|
@ -41,6 +41,6 @@
|
|||
"File 'c:/root/folder1/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"File 'c:/file4.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/file4.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/file4.ts'. ========"
|
||||
]
|
|
@ -6,7 +6,7 @@
|
|||
"Module name 'folder2/file1', matched pattern '*'.",
|
||||
"Trying substitution '*', candidate module location: 'folder2/file1'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/folder2/file1'.",
|
||||
"File 'c:/root/folder2/file1.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/folder2/file1.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'folder2/file1' was successfully resolved to 'c:/root/folder2/file1.ts'. ========",
|
||||
"======== Resolving module 'folder3/file2' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
|
@ -24,7 +24,7 @@
|
|||
"File 'c:/root/folder3/file2/index.d.ts' does not exist.",
|
||||
"Trying substitution 'generated/*', candidate module location: 'generated/folder3/file2'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/generated/folder3/file2'.",
|
||||
"File 'c:/root/generated/folder3/file2.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/generated/folder3/file2.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'folder3/file2' was successfully resolved to 'c:/root/generated/folder3/file2.ts'. ========",
|
||||
"======== Resolving module 'components/file3' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
|
@ -39,7 +39,7 @@
|
|||
"File 'c:/root/shared/components/file3/package.json' does not exist.",
|
||||
"File 'c:/root/shared/components/file3/index.ts' does not exist.",
|
||||
"File 'c:/root/shared/components/file3/index.tsx' does not exist.",
|
||||
"File 'c:/root/shared/components/file3/index.d.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/shared/components/file3/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'components/file3' was successfully resolved to 'c:/root/shared/components/file3/index.d.ts'. ========",
|
||||
"======== Resolving module 'file4' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
|
@ -72,6 +72,13 @@
|
|||
"File 'c:/root/folder1/node_modules/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/file4/index.d.ts' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/@types/file4.ts' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/@types/file4.tsx' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/@types/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/@types/file4/package.json' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/@types/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/@types/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/@types/file4/index.d.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/file4.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/file4.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/file4.d.ts' does not exist.",
|
||||
|
@ -79,6 +86,13 @@
|
|||
"File 'c:/root/node_modules/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/file4/index.d.ts' does not exist.",
|
||||
"File 'c:/node_modules/file4.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/node_modules/@types/file4.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/package.json' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/file4/index.d.ts' does not exist.",
|
||||
"File 'c:/node_modules/file4.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/node_modules/file4.ts'. ========"
|
||||
]
|
|
@ -10,7 +10,7 @@
|
|||
"File 'c:/root/src/project/file3.d.ts' does not exist.",
|
||||
"Trying other entries in 'rootDirs'",
|
||||
"Loading 'project/file3' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file3'",
|
||||
"File 'c:/root/generated/src/project/file3.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/generated/src/project/file3.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './project/file3' was successfully resolved to 'c:/root/generated/src/project/file3.ts'. ========",
|
||||
"======== Resolving module '../file2' from 'c:/root/generated/src/project/file3.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Classic'.",
|
||||
|
@ -24,6 +24,6 @@
|
|||
"Trying other entries in 'rootDirs'",
|
||||
"Loading 'file2' from the root dir 'c:/root/src', candidate location 'c:/root/src/file2'",
|
||||
"File 'c:/root/src/file2.ts' does not exist.",
|
||||
"File 'c:/root/src/file2.d.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/src/file2.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name '../file2' was successfully resolved to 'c:/root/src/file2.d.ts'. ========"
|
||||
]
|
|
@ -17,7 +17,7 @@
|
|||
"Trying other entries in 'rootDirs'",
|
||||
"Loading 'project/file3' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file3'",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/generated/src/project/file3'.",
|
||||
"File 'c:/root/generated/src/project/file3.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/generated/src/project/file3.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './project/file3' was successfully resolved to 'c:/root/generated/src/project/file3.ts'. ========",
|
||||
"======== Resolving module '../file2' from 'c:/root/generated/src/project/file3.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
|
@ -43,6 +43,6 @@
|
|||
"File 'c:/root/src/file2/package.json' does not exist.",
|
||||
"File 'c:/root/src/file2/index.ts' does not exist.",
|
||||
"File 'c:/root/src/file2/index.tsx' does not exist.",
|
||||
"File 'c:/root/src/file2/index.d.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/src/file2/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name '../file2' was successfully resolved to 'c:/root/src/file2/index.d.ts'. ========"
|
||||
]
|
|
@ -10,7 +10,7 @@
|
|||
"File 'c:/root/src/project/file2.d.ts' does not exist.",
|
||||
"Trying other entries in 'rootDirs'",
|
||||
"Loading 'project/file2' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file2'",
|
||||
"File 'c:/root/generated/src/project/file2.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/generated/src/project/file2.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './project/file2' was successfully resolved to 'c:/root/generated/src/project/file2.ts'. ========",
|
||||
"======== Resolving module 'module3' from 'c:/root/src/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Classic'.",
|
||||
|
@ -28,7 +28,7 @@
|
|||
"File 'c:/root/module3.ts' does not exist.",
|
||||
"File 'c:/root/module3.d.ts' does not exist.",
|
||||
"File 'c:/module3.ts' does not exist.",
|
||||
"File 'c:/module3.d.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/module3.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'module3' was successfully resolved to 'c:/module3.d.ts'. ========",
|
||||
"======== Resolving module 'module1' from 'c:/root/generated/src/project/file2.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Classic'.",
|
||||
|
@ -40,7 +40,7 @@
|
|||
"File 'c:/root/module1.d.ts' does not exist.",
|
||||
"Trying substitution 'c:/shared/*', candidate module location: 'c:/shared/module1'.",
|
||||
"File 'c:/shared/module1.ts' does not exist.",
|
||||
"File 'c:/shared/module1.d.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/shared/module1.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'module1' was successfully resolved to 'c:/shared/module1.d.ts'. ========",
|
||||
"======== Resolving module 'templates/module2' from 'c:/root/generated/src/project/file2.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Classic'.",
|
||||
|
@ -48,7 +48,7 @@
|
|||
"'paths' option is specified, looking for a pattern to match module name 'templates/module2'.",
|
||||
"Module name 'templates/module2', matched pattern 'templates/*'.",
|
||||
"Trying substitution 'generated/src/templates/*', candidate module location: 'generated/src/templates/module2'.",
|
||||
"File 'c:/root/generated/src/templates/module2.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/generated/src/templates/module2.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'templates/module2' was successfully resolved to 'c:/root/generated/src/templates/module2.ts'. ========",
|
||||
"======== Resolving module '../file3' from 'c:/root/generated/src/project/file2.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Classic'.",
|
||||
|
@ -62,6 +62,6 @@
|
|||
"Trying other entries in 'rootDirs'",
|
||||
"Loading 'file3' from the root dir 'c:/root/src', candidate location 'c:/root/src/file3'",
|
||||
"File 'c:/root/src/file3.ts' does not exist.",
|
||||
"File 'c:/root/src/file3.d.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/src/file3.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name '../file3' was successfully resolved to 'c:/root/src/file3.d.ts'. ========"
|
||||
]
|
|
@ -17,7 +17,7 @@
|
|||
"Trying other entries in 'rootDirs'",
|
||||
"Loading 'project/file2' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file2'",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/generated/src/project/file2'.",
|
||||
"File 'c:/root/generated/src/project/file2.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/generated/src/project/file2.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name './project/file2' was successfully resolved to 'c:/root/generated/src/project/file2.ts'. ========",
|
||||
"======== Resolving module 'module3' from 'c:/root/src/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
|
@ -50,6 +50,13 @@
|
|||
"File 'c:/root/src/node_modules/module3/index.ts' does not exist.",
|
||||
"File 'c:/root/src/node_modules/module3/index.tsx' does not exist.",
|
||||
"File 'c:/root/src/node_modules/module3/index.d.ts' does not exist.",
|
||||
"File 'c:/root/src/node_modules/@types/module3.ts' does not exist.",
|
||||
"File 'c:/root/src/node_modules/@types/module3.tsx' does not exist.",
|
||||
"File 'c:/root/src/node_modules/@types/module3.d.ts' does not exist.",
|
||||
"File 'c:/root/src/node_modules/@types/module3/package.json' does not exist.",
|
||||
"File 'c:/root/src/node_modules/@types/module3/index.ts' does not exist.",
|
||||
"File 'c:/root/src/node_modules/@types/module3/index.tsx' does not exist.",
|
||||
"File 'c:/root/src/node_modules/@types/module3/index.d.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/module3.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/module3.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/module3.d.ts' does not exist.",
|
||||
|
@ -57,9 +64,16 @@
|
|||
"File 'c:/root/node_modules/module3/index.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/module3/index.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/module3/index.d.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/module3.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/module3.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/module3.d.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/module3/package.json' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/module3/index.ts' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/module3/index.tsx' does not exist.",
|
||||
"File 'c:/root/node_modules/@types/module3/index.d.ts' does not exist.",
|
||||
"File 'c:/node_modules/module3.ts' does not exist.",
|
||||
"File 'c:/node_modules/module3.tsx' does not exist.",
|
||||
"File 'c:/node_modules/module3.d.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/node_modules/module3.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'module3' was successfully resolved to 'c:/node_modules/module3.d.ts'. ========",
|
||||
"======== Resolving module 'module1' from 'c:/root/generated/src/project/file2.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
|
@ -83,7 +97,7 @@
|
|||
"File 'c:/shared/module1/package.json' does not exist.",
|
||||
"File 'c:/shared/module1/index.ts' does not exist.",
|
||||
"File 'c:/shared/module1/index.tsx' does not exist.",
|
||||
"File 'c:/shared/module1/index.d.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/shared/module1/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'module1' was successfully resolved to 'c:/shared/module1/index.d.ts'. ========",
|
||||
"======== Resolving module 'templates/module2' from 'c:/root/generated/src/project/file2.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
|
@ -92,7 +106,7 @@
|
|||
"Module name 'templates/module2', matched pattern 'templates/*'.",
|
||||
"Trying substitution 'generated/src/templates/*', candidate module location: 'generated/src/templates/module2'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/generated/src/templates/module2'.",
|
||||
"File 'c:/root/generated/src/templates/module2.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/generated/src/templates/module2.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name 'templates/module2' was successfully resolved to 'c:/root/generated/src/templates/module2.ts'. ========",
|
||||
"======== Resolving module '../file3' from 'c:/root/generated/src/project/file2.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
|
@ -118,6 +132,6 @@
|
|||
"File 'c:/root/src/file3/package.json' does not exist.",
|
||||
"File 'c:/root/src/file3/index.ts' does not exist.",
|
||||
"File 'c:/root/src/file3/index.tsx' does not exist.",
|
||||
"File 'c:/root/src/file3/index.d.ts' exist - use it as a module resolution result.",
|
||||
"File 'c:/root/src/file3/index.d.ts' exist - use it as a name resolution result.",
|
||||
"======== Module name '../file3' was successfully resolved to 'c:/root/src/file3/index.d.ts'. ========"
|
||||
]
|
|
@ -1,5 +1,5 @@
|
|||
// @module: amd
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// paths should error in the absence of baseurl
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @module: commonjs
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// paths should error in the absence of baseurl
|
||||
// @filename: c:/root/tsconfig.json
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @module: amd
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// baseurl is defined in tsconfig.json
|
||||
// paths has errors
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @module: commonjs
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// baseurl is defined in tsconfig.json
|
||||
// paths has errors
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @moduleResolution: classic
|
||||
// @module: amd
|
||||
// @baseUrl: c:/root
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// baseUrl set via command line
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @moduleResolution: node
|
||||
// @module: commonjs
|
||||
// @baseUrl: c:/root
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// baseUrl set via command line
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// @moduleResolution: classic
|
||||
// @module: amd
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// baseUrl set via command line
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// @moduleResolution: node
|
||||
// @module: commonjs
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// baseUrl set via command line
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @module: amd
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// paths is defined in tsconfig.json
|
||||
// @filename: c:/root/tsconfig.json
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @module: commonjs
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// paths is defined in tsconfig.json
|
||||
// @filename: c:/root/tsconfig.json
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @module: amd
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: c:/root/src/tsconfig.json
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @module: commonjs
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: c:/root/src/tsconfig.json
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @module: amd
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: c:/root/src/tsconfig.json
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// @module: commonjs
|
||||
// @traceModuleResolution: true
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: c:/root/src/tsconfig.json
|
||||
{
|
||||
|
|
13
tests/cases/conformance/references/library-reference-1.ts
Normal file
13
tests/cases/conformance/references/library-reference-1.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
// @noImplicitReferences: true
|
||||
// @traceResolution: true
|
||||
// @typesRoot: /
|
||||
|
||||
// We can find typings in the ./types folder
|
||||
|
||||
// @filename: /types/jquery/index.d.ts
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
// @filename: /consumer.ts
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
18
tests/cases/conformance/references/library-reference-10.ts
Normal file
18
tests/cases/conformance/references/library-reference-10.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
// @noImplicitReferences: true
|
||||
// @traceResolution: true
|
||||
// @typesRoot: /
|
||||
|
||||
// package.json in a primary reference can refer to another file
|
||||
|
||||
// @filename: /types/jquery/package.json
|
||||
{
|
||||
"typings": "jquery.d.ts"
|
||||
}
|
||||
|
||||
// @filename: /types/jquery/jquery.d.ts
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
// @filename: /consumer.ts
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
17
tests/cases/conformance/references/library-reference-11.ts
Normal file
17
tests/cases/conformance/references/library-reference-11.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
// @noImplicitReferences: true
|
||||
// @traceResolution: true
|
||||
|
||||
// package.json in a secondary reference can refer to another file
|
||||
|
||||
// @filename: /a/node_modules/jquery/package.json
|
||||
{
|
||||
"typings": "jquery.d.ts"
|
||||
}
|
||||
|
||||
// @filename: /a/node_modules/jquery/jquery.d.ts
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
// @filename: /a/b/consumer.ts
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
17
tests/cases/conformance/references/library-reference-12.ts
Normal file
17
tests/cases/conformance/references/library-reference-12.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
// @noImplicitReferences: true
|
||||
// @traceResolution: true
|
||||
|
||||
// package.json in a secondary reference can refer to another file
|
||||
|
||||
// @filename: /a/node_modules/jquery/package.json
|
||||
{
|
||||
"types": "dist/jquery.d.ts"
|
||||
}
|
||||
|
||||
// @filename: /a/node_modules/jquery/dist/jquery.d.ts
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
// @filename: /a/b/consumer.ts
|
||||
/// <reference types="jquery" />
|
||||
$.foo();
|
18
tests/cases/conformance/references/library-reference-13.ts
Normal file
18
tests/cases/conformance/references/library-reference-13.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
// @noImplicitReferences: true
|
||||
// @traceResolution: true
|
||||
|
||||
// load type declarations from types section of tsconfig
|
||||
|
||||
// @filename: /a/tsconfig.json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"types": [ "jquery" ]
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: /a/types/jquery/index.d.ts
|
||||
declare var $: { foo(): void };
|
||||
|
||||
|
||||
// @filename: /a/b/consumer.ts
|
||||
$.foo();
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue