update implementation based on the results of design meeting
This commit is contained in:
parent
2b2b150dc7
commit
8a8ed0a871
|
@ -256,8 +256,6 @@ namespace ts {
|
|||
type: {
|
||||
"node": ModuleResolutionKind.NodeJs,
|
||||
"classic": ModuleResolutionKind.Classic,
|
||||
// name is lowercased so we can still use hasProperty(userValue.toLower()) to check if user has entered the right value
|
||||
"baseurl": ModuleResolutionKind.BaseUrl,
|
||||
},
|
||||
description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
|
||||
error: Diagnostics.Argument_for_moduleResolution_option_must_be_node_classic_or_baseUrl,
|
||||
|
@ -529,8 +527,6 @@ namespace ts {
|
|||
const { options: optionsFromJsonConfigFile, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath, configFileName);
|
||||
|
||||
const options = extend(existingOptions, optionsFromJsonConfigFile);
|
||||
// set basePath as inferredBaseUrl so baseUrl module resolution strategy can still work even if user have not specified baseUrl explicity
|
||||
options.inferredBaseUrl = basePath;
|
||||
|
||||
return {
|
||||
options,
|
||||
|
|
|
@ -2159,7 +2159,7 @@
|
|||
"category": "Error",
|
||||
"code": 5059
|
||||
},
|
||||
"Option '{0}' can only be used when option 'moduleResolution' is 'baseUrl'.": {
|
||||
"Option 'paths' cannot be used without specifying '--baseUrl' option.": {
|
||||
"category": "Error",
|
||||
"code": 5060
|
||||
},
|
||||
|
@ -2171,14 +2171,6 @@
|
|||
"category": "Error",
|
||||
"code": 5062
|
||||
},
|
||||
"'moduleResolution' kind 'baseUrl' cannot be used without specifying '--baseUrl' option.": {
|
||||
"category": "Error",
|
||||
"code": 5063
|
||||
},
|
||||
"Module resolution kind cannot be determined automatically. Please specify module resolution explicitly via 'moduleResolution' option.": {
|
||||
"category": "Error",
|
||||
"code": 5064
|
||||
},
|
||||
"Concatenate and emit output to single file.": {
|
||||
"category": "Message",
|
||||
"code": 6001
|
||||
|
@ -2479,101 +2471,93 @@
|
|||
"category": "Message",
|
||||
"code": 6090
|
||||
},
|
||||
"Resolving rooted module name '{0}' - use it as a candidate location.": {
|
||||
"'paths' option is specified, looking for a pattern to match module name '{0}'.": {
|
||||
"category": "Message",
|
||||
"code": 6091
|
||||
},
|
||||
"Resolving relative module name '{0}'.": {
|
||||
"Module name '{0}', matched pattern '{1}'.": {
|
||||
"category": "Message",
|
||||
"code": 6092
|
||||
},
|
||||
"Resolving non-relative module name '{0}'.": {
|
||||
"Trying substitution '{0}', candidate module location: '{1}'.": {
|
||||
"category": "Message",
|
||||
"code": 6093
|
||||
},
|
||||
"Converting relative module name '{0}' to absolute using '{1}' as a base directory => '{2}'.": {
|
||||
"Resolving module name '{0}' relative to base url '{1}' - '{2}'.": {
|
||||
"category": "Message",
|
||||
"code": 6094
|
||||
},
|
||||
"'rootDirs' option is specified, searching for a longest matching prefix...": {
|
||||
"Loading module as file / folder, candidate module location '{0}'.": {
|
||||
"category": "Message",
|
||||
"code": 6095
|
||||
},
|
||||
"Found longest matching rootDir '{0}', 'converted relative path '{1}', to non-relative path '{2}'": {
|
||||
"File '{0}' does not exist.": {
|
||||
"category": "Message",
|
||||
"code": 6096
|
||||
},
|
||||
"'rootDirs' option is not specified, using '{0}' as candidate location.": {
|
||||
"File '{0}' exist - use it as a module resolution result.": {
|
||||
"category": "Message",
|
||||
"code": 6097
|
||||
},
|
||||
"'paths' option is specified, looking for a pattern to match module name '{0}'.": {
|
||||
"Loading module '{0}' from 'node_modules' folder.": {
|
||||
"category": "Message",
|
||||
"code": 6098
|
||||
},
|
||||
"Module name '{0}', matched pattern '{1}'.": {
|
||||
"Found 'package.json' at '{0}'.": {
|
||||
"category": "Message",
|
||||
"code": 6099
|
||||
},
|
||||
"Trying substitution '{0}', candidate module location: '{1}'.": {
|
||||
"'package.json' does not have 'typings' field.": {
|
||||
"category": "Message",
|
||||
"code": 6100
|
||||
},
|
||||
"Resolving module name '{0}' relative to base url '{1}' - '{2}'.": {
|
||||
"'package.json' has 'typings' field '{0}' that references '{1}'.": {
|
||||
"category": "Message",
|
||||
"code": 6101
|
||||
},
|
||||
"Loading module '{0}' as file / folder, candidate module location '{1}'.": {
|
||||
"Module name '{0}' contains '!' character.": {
|
||||
"category": "Message",
|
||||
"code": 6102
|
||||
},
|
||||
"File '{0}' does not exist.": {
|
||||
"Allow javascript files to be compiled.": {
|
||||
"category": "Message",
|
||||
"code": 6103
|
||||
},
|
||||
"File '{0}' exist - use it as a module resolution result.": {
|
||||
"category": "Message",
|
||||
"code": 6104
|
||||
},
|
||||
"Loading module '{0}' from 'node_modules' folder.": {
|
||||
"category": "Message",
|
||||
"code": 6105
|
||||
},
|
||||
"Found 'package.json' at '{0}'.": {
|
||||
"category": "Message",
|
||||
"code": 6106
|
||||
},
|
||||
"'package.json' does not have 'typings' field.": {
|
||||
"category": "Message",
|
||||
"code": 6107
|
||||
},
|
||||
"'package.json' has 'typings' field '{0}' that references '{1}'.": {
|
||||
"category": "Message",
|
||||
"code": 6108
|
||||
},
|
||||
"Module name '{0}' contains '!' character.": {
|
||||
"category": "Message",
|
||||
"code": 6109
|
||||
},
|
||||
"Allow javascript files to be compiled.": {
|
||||
"category": "Message",
|
||||
"code": 6110
|
||||
},
|
||||
"Base url: '{0}'.": {
|
||||
"category": "Message",
|
||||
"code": 6111
|
||||
},
|
||||
"Option '{0}' should have array of strings as a value.": {
|
||||
"category": "Error",
|
||||
"code": 6112
|
||||
"code": 6104
|
||||
},
|
||||
"Checking if '{0}' is the longest matching prefix for '{1}' - '{2}'.": {
|
||||
"category": "Message",
|
||||
"code": 6113
|
||||
"code": 6105
|
||||
},
|
||||
"Expected type of 'typings' field in 'package.json' to be 'string', got '{0}'.": {
|
||||
"category": "Message",
|
||||
"code": 6114
|
||||
"code": 6106
|
||||
},
|
||||
"'baseUrl' option is set to '{0}', using this value to resolve non-relative module name '{1}'": {
|
||||
"category": "Message",
|
||||
"code": 6107
|
||||
},
|
||||
"'rootDirs' option is set, using it to resolve relative module name '{0}'": {
|
||||
"category": "Message",
|
||||
"code": 6108
|
||||
},
|
||||
"Longest matching prefix for '{0}' is '{1}'": {
|
||||
"category": "Message",
|
||||
"code": 6109
|
||||
},
|
||||
"Loading '{0}' from the root dir '{1}', candidate location '{2}'": {
|
||||
"category": "Message",
|
||||
"code": 6110
|
||||
},
|
||||
"Trying other entries in 'rootDirs'": {
|
||||
"category": "Message",
|
||||
"code": 6111
|
||||
},
|
||||
"Module resolution using 'rootDirs' has failed": {
|
||||
"category": "Message",
|
||||
"code": 6112
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
|
|
|
@ -45,6 +45,51 @@ namespace ts {
|
|||
return compilerOptions.traceModuleResolution && host.trace !== undefined;
|
||||
}
|
||||
|
||||
function startsWith(str: string, prefix: string): boolean {
|
||||
return str.lastIndexOf(prefix, 0) === 0;
|
||||
}
|
||||
|
||||
function endsWith(str: string, suffix: string): boolean {
|
||||
const expectedPos = str.length - suffix.length;
|
||||
return str.indexOf(suffix, expectedPos) === expectedPos;
|
||||
}
|
||||
|
||||
function hasZeroOrOneAsteriskCharacter(str: string): boolean {
|
||||
let seenAsterisk = false;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
if (str.charCodeAt(i) === CharacterCodes.asterisk) {
|
||||
if (!seenAsterisk) {
|
||||
seenAsterisk = true;
|
||||
}
|
||||
else {
|
||||
// have already seen asterisk
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function createResolvedModule(resolvedFileName: string, isExternalLibraryImport: boolean, failedLookupLocations: string[]): ResolvedModuleWithFailedLookupLocations {
|
||||
return { resolvedModule: resolvedFileName ? { resolvedFileName, isExternalLibraryImport } : undefined, failedLookupLocations };
|
||||
}
|
||||
|
||||
function moduleHasNonRelativeName(moduleName: string): boolean {
|
||||
if (isRootedDiskPath(moduleName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const i = moduleName.lastIndexOf("./", 1);
|
||||
const startsWithDotSlashOrDotDotSlash = i === 0 || (i === 1 && moduleName.charCodeAt(0) === CharacterCodes.dot);
|
||||
return !startsWithDotSlashOrDotDotSlash;
|
||||
}
|
||||
|
||||
interface ModuleResolutionState {
|
||||
host: ModuleResolutionHost;
|
||||
compilerOptions: CompilerOptions;
|
||||
traceEnabled: boolean;
|
||||
}
|
||||
|
||||
export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
||||
if (traceEnabled) {
|
||||
|
@ -53,16 +98,7 @@ namespace ts {
|
|||
|
||||
let moduleResolution = compilerOptions.moduleResolution;
|
||||
if (moduleResolution === undefined) {
|
||||
if (compilerOptions.module === ModuleKind.CommonJS) {
|
||||
moduleResolution = ModuleResolutionKind.NodeJs;
|
||||
}
|
||||
else if (compilerOptions.baseUrl !== undefined || compilerOptions.paths || compilerOptions.rootDirs) {
|
||||
moduleResolution = ModuleResolutionKind.BaseUrl;
|
||||
}
|
||||
else {
|
||||
moduleResolution = ModuleResolutionKind.Classic;
|
||||
}
|
||||
|
||||
moduleResolution = compilerOptions.module === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic;
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Module_resolution_kind_is_not_specified_using_0, ModuleResolutionKind[moduleResolution]);
|
||||
}
|
||||
|
@ -81,9 +117,6 @@ namespace ts {
|
|||
case ModuleResolutionKind.Classic:
|
||||
result = classicNameResolver(moduleName, containingFile, compilerOptions, host);
|
||||
break;
|
||||
case ModuleResolutionKind.BaseUrl:
|
||||
result = baseUrlModuleNameResolver(moduleName, containingFile, compilerOptions, host);
|
||||
break;
|
||||
}
|
||||
|
||||
if (traceEnabled) {
|
||||
|
@ -98,192 +131,184 @@ namespace ts {
|
|||
return result;
|
||||
}
|
||||
|
||||
// Path mapping based module resolution strategy uses base url to resolve non-absolute file names. This resolution strategy can be enabled
|
||||
// by setting 'moduleResolution' option to 'baseUrl' and as it implied by the name it uses base url to resolve module names.
|
||||
// Base url can be specified:
|
||||
// - explicitly via command line option 'baseUrl'. If this value is relative it will be computed relative to current directory.
|
||||
// - explicitly in 'tsconfig.json' via 'baseUrl' compiler option. If this value is relative it will be computed relative to the location
|
||||
// of 'tsconfig.json'.
|
||||
// - if value is not provided explicitly but project uses tsconfig.json then 'baseUrl' will be set of folder that contains 'tsconfig.json'
|
||||
// If baseUrl is the only provided option then non-relative module names will be resolved relative to baseUrl. Relative module names
|
||||
// will still be resolved relative to the folder that contains file with import.
|
||||
// User can specify additional options in tsconfig.json to tweak module resolution.
|
||||
// - 'paths' option allows to tune how non-relative module names will be resolved based on the content of the module name.
|
||||
// Structure of 'paths' compiler options
|
||||
// 'paths': {
|
||||
// pattern-1: list of substitutions 1,
|
||||
// pattern-2: list of substitutions 2,
|
||||
// ...
|
||||
// pattern-n: list of substitutions-n
|
||||
// }
|
||||
// Pattern here is a string that can contain zero or one '*' character. During module resolution module name will be matched against
|
||||
// all patterns in the list. Matching for patterns that don't contain '*' means that module name must be equal to pattern respecting the case.
|
||||
// If pattern contains '*' then to match pattern "<prefix>*<suffix>" module name must start with the <prefix> and end with <suffix>.
|
||||
// <MatchedStar> denotes part of the module name between <prefix> and <suffix>.
|
||||
// If module name can be matches with multiple patterns then pattern with the longest prefix will be picked.
|
||||
// After selecting pattern we'll use list of substitutions to get candidate locations of the module and the try to load module from the candidate location.
|
||||
// Substitiution is a string that can contain zero or one '*'. To get candidate location from substitution we'll pick every substitution in the list
|
||||
// and replace '*' with <MatchedStar> string. If candidate location is not rooted it will be converted to absolute using baseUrl.
|
||||
// For example:
|
||||
// baseUrl: /a/b/c
|
||||
// "paths": {
|
||||
// // match all module names
|
||||
// "*": [
|
||||
// "*", // use matched name as is,
|
||||
// // <matched name> will be looked as /a/b/c/<matched name>
|
||||
//
|
||||
// "folder1/*" // substitution will convert matched name to 'folder1/<matched name>',
|
||||
// // since it is not rooted then final candidate location will be /a/b/c/folder1/<matched name>
|
||||
// ],
|
||||
// // match module names that start with 'components/'
|
||||
// "components/*": [ "/root/components/*" ] // substitution will convert /components/folder1/<matched name> to '/root/components/folder1/<matched name>',
|
||||
// // it is rooted so it will be final candidate location
|
||||
// }
|
||||
// 'paths' allows to remap locations of non-relative module names. Relative module names usually are resolved relative to the folder
|
||||
// that contains import. However sometimes it might be useful to apply mappings to relative module names as well.
|
||||
// Since the there might be different relative file names that refer to the same file we need to convert relative module name to non-relative
|
||||
// so we can just apply path mapping to it. This conversion can be performed using 'rootDirs' compiler option - this options stores list of root directories
|
||||
// for the project (if root directory is not absolute it will be converted to absolute using baseUrl as a base path).
|
||||
// First - we convert relative module name to absolute using location of file that contains import.
|
||||
// Then we try to find what element is rootDirs is the longest prefix for this absolute file name (respecting case):
|
||||
// <absoluteFileName> = <longestRootDir><suffix>
|
||||
// Once it is done - value of <suffix> is a be non-relative name for initially relative module name.
|
||||
// Note that if element in rootDirs should always end with '/' so it will be appended automatically if value in configuration does not have it.
|
||||
// For example:
|
||||
// baseUrl: /a/b/c
|
||||
// "paths": {
|
||||
// "*": [ "*", "generated/*" ] // try to resolve module name as '/a/b/c/<name>' then look it in '/a/b/c/generated/<name>'
|
||||
// }
|
||||
// "rootDirs": [
|
||||
// "./src", // root dir is project baseUrl/src
|
||||
// "./generated" // root dir is baseUrl/generated
|
||||
// "/e/f" // root dir is /e/f
|
||||
// ]
|
||||
// @file: /a/b/c/src/form1.ts
|
||||
// import {x} from "./form.content.ts"
|
||||
// @file: /a/b/c/generated/form.content.ts
|
||||
// export var x = ...
|
||||
// first './form.content.ts' needs to be converted to non-relative name.
|
||||
// 1. convert it to absolute name '/a/b/c/src/form.content.ts' ->
|
||||
// find longest prefix in rootDirs that match this path, it will be './src' (after expansion '/a/b/c/src/') ->
|
||||
// suffix is form.content.ts
|
||||
// 2. apply path mappings to 'form1.content.ts' ->
|
||||
// '*' pattern will be matched ->
|
||||
// '*' substitution yields '/a/b/c/form1.content.ts' - file does not exists
|
||||
// 'generated/*' substitution yields '/a/b/c/generated/form1.content' - file exists - OK
|
||||
export function baseUrlModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
const baseUrl = compilerOptions.baseUrl !== undefined ? compilerOptions.baseUrl : compilerOptions.inferredBaseUrl;
|
||||
Debug.assert(baseUrl !== undefined);
|
||||
/*
|
||||
* Every module resolution kind can has its specific understanding how to load module from a specific path on disk
|
||||
* I.e. for path '/a/b/c':
|
||||
* - Node loader will first to try to check if '/a/b/c' points to a file with some supported extension and if this fails
|
||||
* it will try to load module from directory: directory '/a/b/c' should exist and it should have either 'package.json' with
|
||||
* 'typings' entry or file 'index' with some supported extension
|
||||
* - Classic loader will only try to interpret '/a/b/c' as file.
|
||||
*/
|
||||
type ResolutionKindSpecificLoader = (candidate: string, extensions: string[], failedLookupLocations: string[], onlyRecordFalures: boolean, state: ModuleResolutionState) => string;
|
||||
|
||||
const supportedExtensions = getSupportedExtensions(compilerOptions);
|
||||
// NOTE: traceEnabled check is delibirately no inside the 'trace' at evert callside to avoid runtime impact of calling vararg function
|
||||
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
||||
/**
|
||||
* Any module resolution kind can be augmented with optional settings: 'baseUrl', 'paths' and 'rootDirs' - they are used to
|
||||
* mitigate differences between design time structure of the project and its runtime counterpart so the same import name
|
||||
* can be resolved successfully by TypeScript compiler and runtime module loader.
|
||||
* If these settings are set then loading procedure will try to use them to resolve module name and it can of failure it will
|
||||
* fallback to standard resolution routine.
|
||||
*
|
||||
* - baseUrl - this setting controls how non-relative module names are resolved. If this setting is specified then non-relative
|
||||
* names will be resolved relative to baseUrl: i.e. if baseUrl is '/a/b' then canditate location to resolve module name 'c/d' will
|
||||
* be '/a/b/c/d'
|
||||
* - paths - this setting can only be used when baseUrl is specified. allows to tune how non-relative module names
|
||||
* will be resolved based on the content of the module name.
|
||||
* Structure of 'paths' compiler options
|
||||
* 'paths': {
|
||||
* pattern-1: [...substitutions],
|
||||
* pattern-2: [...substitutions],
|
||||
* ...
|
||||
* pattern-n: [...substitutions]
|
||||
* }
|
||||
* Pattern here is a string that can contain zero or one '*' character. During module resolution module name will be matched against
|
||||
* all patterns in the list. Matching for patterns that don't contain '*' means that module name must be equal to pattern respecting the case.
|
||||
* If pattern contains '*' then to match pattern "<prefix>*<suffix>" module name must start with the <prefix> and end with <suffix>.
|
||||
* <MatchedStar> denotes part of the module name between <prefix> and <suffix>.
|
||||
* If module name can be matches with multiple patterns then pattern with the longest prefix will be picked.
|
||||
* After selecting pattern we'll use list of substitutions to get candidate locations of the module and the try to load module
|
||||
* from the candidate location.
|
||||
* Substitiution is a string that can contain zero or one '*'. To get candidate location from substitution we'll pick every
|
||||
* substitution in the list and replace '*' with <MatchedStar> string. If candidate location is not rooted it
|
||||
* will be converted to absolute using baseUrl.
|
||||
* For example:
|
||||
* baseUrl: /a/b/c
|
||||
* "paths": {
|
||||
* // match all module names
|
||||
* "*": [
|
||||
* "*", // use matched name as is,
|
||||
* // <matched name> will be looked as /a/b/c/<matched name>
|
||||
*
|
||||
* "folder1/*" // substitution will convert matched name to 'folder1/<matched name>',
|
||||
* // since it is not rooted then final candidate location will be /a/b/c/folder1/<matched name>
|
||||
* ],
|
||||
* // match module names that start with 'components/'
|
||||
* "components/*": [ "/root/components/*" ] // substitution will convert /components/folder1/<matched name> to '/root/components/folder1/<matched name>',
|
||||
* // it is rooted so it will be final candidate location
|
||||
* }
|
||||
*
|
||||
* 'rootDirs' allows the project to be spreaded across multiple locations and resolve modules with relative names as if
|
||||
* they were in the same location. For example lets say there are two files
|
||||
* '/local/src/content/file1.ts'
|
||||
* '/shared/components/contracts/src/content/protocols/file2.ts'
|
||||
* After bundling content of '/shared/components/contracts/src' will be merged with '/local/src' so
|
||||
* if file1 has the following import 'import {x} from "./protocols/file2"' it will be resolved successfully in runtime.
|
||||
* 'rootDirs' provides the way to tell compiler that in order to get the whole project it should behave as if content of all
|
||||
* root dirs were merged together.
|
||||
* I.e. for the example above 'rootDirs' will have two entries: [ '/local/src', '/shared/components/contracts/src' ].
|
||||
* Compiler wil first convert './protocols/file2' into absolute path relative to the location of containing file:
|
||||
* '/local/src/content/protocols/file2' and try to load it - failure.
|
||||
* Then it will search 'rootDirs' looking for a longest matching prefix of this absolute path and if such prefix is found - absolute path will
|
||||
* be converted to a path relative to found rootDir entry './content/protocols/file2' (*). As a last step compiler will check all remainining
|
||||
* entries in 'rootDirs', use them to build absolute path out of (*) and try to resolve module from this location.
|
||||
*/
|
||||
function tryLoadModuleUsingOptionalResolutionSettings(moduleName: string, containingDirectory: string, loader: ResolutionKindSpecificLoader,
|
||||
failedLookupLocations: string[], supportedExtensions: string[], state: ModuleResolutionState): string {
|
||||
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Base_url_Colon_0, baseUrl);
|
||||
}
|
||||
|
||||
if (isRootedDiskPath(moduleName)) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Resolving_rooted_module_name_0_use_it_as_a_candidate_location, moduleName);
|
||||
}
|
||||
|
||||
const failedLookupLocations: string[] = [];
|
||||
const resolvedFileName = loadModuleFromFile(supportedExtensions, moduleName, failedLookupLocations, !directoryProbablyExists(getDirectoryPath(moduleName), host), host, traceEnabled);
|
||||
return {
|
||||
resolvedModule: resolvedFileName ? { resolvedFileName } : undefined,
|
||||
failedLookupLocations
|
||||
};
|
||||
}
|
||||
|
||||
if (nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
|
||||
// relative name
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Resolving_relative_module_name_0, moduleName);
|
||||
}
|
||||
return baseUrlResolveRelativeModuleName(moduleName, containingFile, baseUrl, supportedExtensions, compilerOptions, host, traceEnabled);
|
||||
if (moduleHasNonRelativeName(moduleName)) {
|
||||
return tryLoadModuleUsingBaseUrl(moduleName, loader, failedLookupLocations, supportedExtensions, state);
|
||||
}
|
||||
else {
|
||||
// non-relative name
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Resolving_non_relative_module_name_0, moduleName);
|
||||
}
|
||||
return baseUrlResolveNonRelativeModuleName(moduleName, baseUrl, supportedExtensions, compilerOptions, host, traceEnabled);
|
||||
return tryLoadModuleUsingRootDirs(moduleName, containingDirectory, loader, failedLookupLocations, supportedExtensions, state);
|
||||
}
|
||||
}
|
||||
|
||||
function baseUrlResolveRelativeModuleName(moduleName: string, containingFile: string, baseUrl: string, supportedExtensions: string[], compilerOptions: CompilerOptions, host: ModuleResolutionHost, traceEnabled: boolean): ResolvedModuleWithFailedLookupLocations {
|
||||
const failedLookupLocations: string[] = [];
|
||||
function tryLoadModuleUsingRootDirs(moduleName: string, containingDirectory: string, loader: ResolutionKindSpecificLoader,
|
||||
failedLookupLocations: string[], supportedExtensions: string[], state: ModuleResolutionState): string {
|
||||
|
||||
if (!state.compilerOptions.rootDirs) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName);
|
||||
}
|
||||
|
||||
// we always pass absolute path to containing file so candidate location is also absolute
|
||||
const containingDirectory = getDirectoryPath(containingFile);
|
||||
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Converting_relative_module_name_0_to_absolute_using_1_as_a_base_directory_2, moduleName, containingDirectory, candidate);
|
||||
}
|
||||
|
||||
if (compilerOptions.rootDirs) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.rootDirs_option_is_specified_searching_for_a_longest_matching_prefix);
|
||||
}
|
||||
|
||||
let matchedPrefix: string;
|
||||
for (const rootDir of compilerOptions.rootDirs) {
|
||||
let matchedRootDir: string;
|
||||
let matchedNormalizedPrefix: string;
|
||||
for (const rootDir of state.compilerOptions.rootDirs) {
|
||||
// rootDirs are expected to be absolute
|
||||
// in case of tsconfig.json this will happen automatically - compiler will expand relative names
|
||||
// using locaton of tsconfig.json as base location
|
||||
let normalizedRoot = normalizePath(rootDir);
|
||||
if (!endsWith(normalizedRoot, directorySeparator)) {
|
||||
normalizedRoot += directorySeparator;
|
||||
}
|
||||
const isLongestMatchingPrefix =
|
||||
startsWith(candidate, normalizedRoot) &&
|
||||
(matchedPrefix === undefined || matchedPrefix.length < normalizedRoot.length);
|
||||
(matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length);
|
||||
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix);
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix);
|
||||
}
|
||||
|
||||
if (isLongestMatchingPrefix) {
|
||||
matchedPrefix = normalizedRoot;
|
||||
matchedNormalizedPrefix = normalizedRoot;
|
||||
matchedRootDir = rootDir;
|
||||
}
|
||||
}
|
||||
if (matchedNormalizedPrefix) {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix);
|
||||
}
|
||||
const suffix = candidate.substr(matchedNormalizedPrefix.length);
|
||||
|
||||
// first - try to load from a initial location
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate);
|
||||
}
|
||||
const resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(containingDirectory, state.host), state);
|
||||
if (resolvedFileName) {
|
||||
return resolvedFileName;
|
||||
}
|
||||
|
||||
if (matchedPrefix) {
|
||||
const suffix = candidate.substr(matchedPrefix.length);
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Found_longest_matching_rootDir_0_converted_relative_path_1_to_non_relative_path_2, matchedPrefix, moduleName, suffix);
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Trying_other_entries_in_rootDirs);
|
||||
}
|
||||
// then try to resolve using remaining entries in rootDirs
|
||||
for (const rootDir of state.compilerOptions.rootDirs) {
|
||||
if (rootDir === matchedRootDir) {
|
||||
// skip the initially matched entry
|
||||
continue;
|
||||
}
|
||||
const candidate = combinePaths(normalizePath(rootDir), suffix);
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate);
|
||||
}
|
||||
const baseDirectory = getDirectoryPath(candidate);
|
||||
const resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(baseDirectory, state.host), state);
|
||||
if (resolvedFileName) {
|
||||
return resolvedFileName;
|
||||
}
|
||||
}
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Module_resolution_using_rootDirs_has_failed);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return baseUrlResolveNonRelativeModuleName(suffix, baseUrl, supportedExtensions, compilerOptions, host, traceEnabled);
|
||||
function tryLoadModuleUsingBaseUrl(moduleName: string, loader: ResolutionKindSpecificLoader, failedLookupLocations: string[],
|
||||
supportedExtensions: string[], state: ModuleResolutionState): string {
|
||||
|
||||
if (!state.compilerOptions.baseUrl) {
|
||||
return undefined;
|
||||
}
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, state.compilerOptions.baseUrl, moduleName);
|
||||
}
|
||||
|
||||
// rootDirs does not contain prefix for candidate - fallthrough to load file from candidate location.
|
||||
}
|
||||
else {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.rootDirs_option_is_not_specified_using_0_as_candidate_location, candidate);
|
||||
}
|
||||
}
|
||||
|
||||
const resolvedFileName = loadModuleFromFile(supportedExtensions, candidate, failedLookupLocations, !directoryProbablyExists(getDirectoryPath(candidate), host), host, traceEnabled);
|
||||
return {
|
||||
resolvedModule: resolvedFileName ? { resolvedFileName } : undefined,
|
||||
failedLookupLocations
|
||||
};
|
||||
}
|
||||
|
||||
function baseUrlResolveNonRelativeModuleName(moduleName: string, baseUrl: string, supportedExtensions: string[], compilerOptions: CompilerOptions, host: ModuleResolutionHost, traceEnabled: boolean): ResolvedModuleWithFailedLookupLocations {
|
||||
let longestMatchPrefixLength = -1;
|
||||
let matchedPattern: string;
|
||||
let matchedStar: string;
|
||||
|
||||
const failedLookupLocations: string[] = [];
|
||||
if (compilerOptions.paths) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName);
|
||||
if (state.compilerOptions.paths) {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName);
|
||||
}
|
||||
|
||||
for (const key in compilerOptions.paths) {
|
||||
for (const key in state.compilerOptions.paths) {
|
||||
const pattern: string = key;
|
||||
const indexOfStar = pattern.indexOf("*");
|
||||
if (indexOfStar !== -1) {
|
||||
|
@ -311,79 +336,72 @@ namespace ts {
|
|||
}
|
||||
|
||||
if (matchedPattern) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPattern);
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPattern);
|
||||
}
|
||||
|
||||
for (const subst of compilerOptions.paths[matchedPattern]) {
|
||||
for (const subst of state.compilerOptions.paths[matchedPattern]) {
|
||||
const path = matchedStar ? subst.replace("\*", matchedStar) : subst;
|
||||
const candidate = normalizePath(combinePaths(baseUrl, path));
|
||||
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
|
||||
const candidate = normalizePath(combinePaths(state.compilerOptions.baseUrl, path));
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
|
||||
}
|
||||
|
||||
const resolvedFileName = loadModuleFromFile(supportedExtensions, candidate, failedLookupLocations, !directoryProbablyExists(getDirectoryPath(candidate), host), host, traceEnabled);
|
||||
const resolvedFileName = loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(getDirectoryPath(candidate), state.host), state);
|
||||
if (resolvedFileName) {
|
||||
return { resolvedModule: { resolvedFileName }, failedLookupLocations };
|
||||
return resolvedFileName;
|
||||
}
|
||||
}
|
||||
|
||||
return { resolvedModule: undefined, failedLookupLocations };
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
const candidate = normalizePath(combinePaths(baseUrl, moduleName));
|
||||
const candidate = normalizePath(combinePaths(state.compilerOptions.baseUrl, moduleName));
|
||||
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate);
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, state.compilerOptions.baseUrl, candidate);
|
||||
}
|
||||
|
||||
const resolvedFileName = loadModuleFromFile(supportedExtensions, candidate, failedLookupLocations, !directoryProbablyExists(getDirectoryPath(candidate), host), host, traceEnabled);
|
||||
return {
|
||||
resolvedModule: resolvedFileName ? { resolvedFileName } : undefined,
|
||||
failedLookupLocations
|
||||
};
|
||||
return loader(candidate, supportedExtensions, failedLookupLocations, !directoryProbablyExists(getDirectoryPath(candidate), state.host), state);
|
||||
}
|
||||
}
|
||||
|
||||
function startsWith(str: string, prefix: string): boolean {
|
||||
return str.lastIndexOf(prefix, 0) === 0;
|
||||
}
|
||||
|
||||
function endsWith(str: string, suffix: string): boolean {
|
||||
const expectedPos = str.length - suffix.length;
|
||||
return str.indexOf(suffix, expectedPos) === expectedPos;
|
||||
}
|
||||
|
||||
export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
const containingDirectory = getDirectoryPath(containingFile);
|
||||
const supportedExtensions = getSupportedExtensions(compilerOptions);
|
||||
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
||||
|
||||
if (isRootedDiskPath(moduleName) || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
|
||||
const failedLookupLocations: string[] = [];
|
||||
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Loading_module_0_as_file_Slash_folder_candidate_module_location_1, moduleName, candidate);
|
||||
}
|
||||
const state = {compilerOptions, host, traceEnabled};
|
||||
let resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, nodeLoadModuleByRelativeName,
|
||||
failedLookupLocations, supportedExtensions, state);
|
||||
|
||||
let resolvedFileName = loadModuleFromFile(supportedExtensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, host, traceEnabled);
|
||||
if (resolvedFileName) {
|
||||
return { resolvedModule: { resolvedFileName }, failedLookupLocations };
|
||||
return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/false, failedLookupLocations);
|
||||
}
|
||||
|
||||
resolvedFileName = loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, /*onlyRecordFailures*/ false, host, traceEnabled);
|
||||
return resolvedFileName
|
||||
? { resolvedModule: { resolvedFileName }, failedLookupLocations }
|
||||
: { resolvedModule: undefined, failedLookupLocations };
|
||||
}
|
||||
else {
|
||||
let isExternalLibraryImport = false;
|
||||
if (moduleHasNonRelativeName(moduleName)) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Loading_module_0_from_node_modules_folder, moduleName);
|
||||
}
|
||||
|
||||
return loadModuleFromNodeModules(moduleName, containingDirectory, host, traceEnabled);
|
||||
resolvedFileName = loadModuleFromNodeModules(moduleName, containingDirectory, failedLookupLocations, state);
|
||||
isExternalLibraryImport = resolvedFileName !== undefined;
|
||||
}
|
||||
else {
|
||||
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
resolvedFileName = nodeLoadModuleByRelativeName(candidate, supportedExtensions, failedLookupLocations, /*onlyRecordFailures*/ false, state);
|
||||
}
|
||||
return createResolvedModule(resolvedFileName, isExternalLibraryImport, failedLookupLocations);
|
||||
}
|
||||
|
||||
function nodeLoadModuleByRelativeName(candidate: string, supportedExtensions: string[], failedLookupLocations: string[],
|
||||
onlyRecordFailures: boolean, state: ModuleResolutionState): string {
|
||||
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate);
|
||||
}
|
||||
|
||||
const resolvedFileName = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state);
|
||||
|
||||
return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
@ -396,20 +414,20 @@ namespace ts {
|
|||
* @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary
|
||||
* 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(extensions: string[], candidate: string, failedLookupLocation: string[], onlyRecordFailures: boolean, host: ModuleResolutionHost, traceEnabled: boolean): string {
|
||||
function loadModuleFromFile(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string {
|
||||
return forEach(extensions, tryLoad);
|
||||
|
||||
function tryLoad(ext: string): string {
|
||||
const fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
|
||||
if (!onlyRecordFailures && host.fileExists(fileName)) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.File_0_exist_use_it_as_a_module_resolution_result, fileName);
|
||||
if (!onlyRecordFailures && state.host.fileExists(fileName)) {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.File_0_exist_use_it_as_a_module_resolution_result, fileName);
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
else {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.File_0_does_not_exist, fileName);
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.File_0_does_not_exist, fileName);
|
||||
}
|
||||
failedLookupLocation.push(fileName);
|
||||
return undefined;
|
||||
|
@ -417,18 +435,18 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function loadNodeModuleFromDirectory(extensions: string[], candidate: string, failedLookupLocation: string[], onlyRecordFailures: boolean, host: ModuleResolutionHost, traceEnabled: boolean): string {
|
||||
function loadNodeModuleFromDirectory(extensions: string[], candidate: string, failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string {
|
||||
const packageJsonPath = combinePaths(candidate, "package.json");
|
||||
const directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, host);
|
||||
if (directoryExists && host.fileExists(packageJsonPath)) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath);
|
||||
const directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host);
|
||||
if (directoryExists && state.host.fileExists(packageJsonPath)) {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Found_package_json_at_0, packageJsonPath);
|
||||
}
|
||||
|
||||
let jsonContent: { typings?: string };
|
||||
|
||||
try {
|
||||
const jsonText = host.readFile(packageJsonPath);
|
||||
const jsonText = state.host.readFile(packageJsonPath);
|
||||
jsonContent = jsonText ? <{ typings?: string }>JSON.parse(jsonText) : { typings: undefined };
|
||||
}
|
||||
catch (e) {
|
||||
|
@ -439,52 +457,51 @@ namespace ts {
|
|||
if (jsonContent.typings) {
|
||||
if (typeof jsonContent.typings === "string") {
|
||||
const typingsFile = normalizePath(combinePaths(candidate, jsonContent.typings));
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.package_json_has_typings_field_0_that_references_1, jsonContent.typings, typingsFile);
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.package_json_has_typings_field_0_that_references_1, jsonContent.typings, typingsFile);
|
||||
}
|
||||
const result = loadModuleFromFile(extensions, typingsFile, failedLookupLocation, !directoryProbablyExists(getDirectoryPath(typingsFile), host), host, traceEnabled);
|
||||
const result = loadModuleFromFile(typingsFile, extensions, failedLookupLocation, !directoryProbablyExists(getDirectoryPath(typingsFile), state.host), state);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else if (traceEnabled) {
|
||||
trace(host, Diagnostics.Expected_type_of_typings_field_in_package_json_to_be_string_got_0, typeof jsonContent.typings);
|
||||
else if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Expected_type_of_typings_field_in_package_json_to_be_string_got_0, typeof jsonContent.typings);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.package_json_does_not_have_typings_field);
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.package_json_does_not_have_typings_field);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.File_0_does_not_exist, packageJsonPath);
|
||||
}
|
||||
// record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results
|
||||
failedLookupLocation.push(packageJsonPath);
|
||||
}
|
||||
|
||||
return loadModuleFromFile(extensions, combinePaths(candidate, "index"), failedLookupLocation, !directoryExists, host, traceEnabled);
|
||||
return loadModuleFromFile(combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state);
|
||||
}
|
||||
|
||||
function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost, traceEnabled: boolean): ResolvedModuleWithFailedLookupLocations {
|
||||
const failedLookupLocations: string[] = [];
|
||||
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, host);
|
||||
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(supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, host, traceEnabled);
|
||||
let result = loadModuleFromFile(candidate, supportedTypeScriptExtensions, failedLookupLocations, !nodeModulesFolderExists, state);
|
||||
if (result) {
|
||||
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
|
||||
return result;
|
||||
}
|
||||
result = loadNodeModuleFromDirectory(supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, host, traceEnabled);
|
||||
result = loadNodeModuleFromDirectory(supportedTypeScriptExtensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state);
|
||||
if (result) {
|
||||
return { resolvedModule: { resolvedFileName: result, isExternalLibraryImport: true }, failedLookupLocations };
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -495,34 +512,20 @@ namespace ts {
|
|||
|
||||
directory = parentPath;
|
||||
}
|
||||
|
||||
return { resolvedModule: undefined, failedLookupLocations };
|
||||
}
|
||||
|
||||
function nameStartsWithDotSlashOrDotDotSlash(name: string) {
|
||||
const i = name.lastIndexOf("./", 1);
|
||||
return i === 0 || (i === 1 && name.charCodeAt(0) === CharacterCodes.dot);
|
||||
}
|
||||
|
||||
function hasZeroOrOneAsteriskCharacter(str: string): boolean {
|
||||
let seenAsterisk = false;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
if (str.charCodeAt(i) === CharacterCodes.asterisk) {
|
||||
if (!seenAsterisk) {
|
||||
seenAsterisk = true;
|
||||
}
|
||||
else {
|
||||
// have already seen asterisk
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
|
||||
|
||||
const traceEnabled = isTraceEnabled(compilerOptions, host);
|
||||
const state = { compilerOptions, host, traceEnabled };
|
||||
const failedLookupLocations: string[] = [];
|
||||
const supportedExtensions = getSupportedExtensions(compilerOptions);
|
||||
let containingDirectory = getDirectoryPath(containingFile);
|
||||
|
||||
const resolvedFileName = tryLoadModuleUsingOptionalResolutionSettings(moduleName, containingDirectory, loadModuleFromFile, failedLookupLocations, supportedExtensions, state);
|
||||
if (resolvedFileName) {
|
||||
return createResolvedModule(resolvedFileName, /*isExternalLibraryImport*/false, failedLookupLocations);
|
||||
}
|
||||
|
||||
// module names that contain '!' are used to reference resources and are not resolved to actual files on disk
|
||||
if (moduleName.indexOf("!") != -1) {
|
||||
|
@ -532,46 +535,19 @@ namespace ts {
|
|||
return { resolvedModule: undefined, failedLookupLocations: [] };
|
||||
}
|
||||
|
||||
let searchPath = getDirectoryPath(containingFile);
|
||||
let searchName: string;
|
||||
|
||||
const failedLookupLocations: string[] = [];
|
||||
|
||||
let referencedSourceFile: string;
|
||||
const supportedExtensions = getSupportedExtensions(compilerOptions);
|
||||
while (true) {
|
||||
searchName = normalizePath(combinePaths(searchPath, moduleName));
|
||||
referencedSourceFile = forEach(supportedExtensions, extension => {
|
||||
if (extension === ".tsx" && !compilerOptions.jsx) {
|
||||
// resolve .tsx files only if jsx support is enabled
|
||||
// 'logical not' handles both undefined and None cases
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const candidate = searchName + extension;
|
||||
if (host.fileExists(candidate)) {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.File_0_exist_use_it_as_a_module_resolution_result, candidate);
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
else {
|
||||
if (traceEnabled) {
|
||||
trace(host, Diagnostics.File_0_does_not_exist, candidate);
|
||||
}
|
||||
failedLookupLocations.push(candidate);
|
||||
}
|
||||
});
|
||||
|
||||
const searchName = normalizePath(combinePaths(containingDirectory, moduleName));
|
||||
const directoryName = getDirectoryPath(searchName);
|
||||
referencedSourceFile = loadModuleFromFile(searchName, supportedExtensions, failedLookupLocations, !directoryProbablyExists(directoryName, host), state);
|
||||
if (referencedSourceFile) {
|
||||
break;
|
||||
}
|
||||
|
||||
const parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
const parentPath = getDirectoryPath(containingDirectory);
|
||||
if (parentPath === containingDirectory) {
|
||||
break;
|
||||
}
|
||||
searchPath = parentPath;
|
||||
containingDirectory = parentPath;
|
||||
}
|
||||
|
||||
return referencedSourceFile
|
||||
|
@ -1628,29 +1604,8 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
if (options.moduleResolution === ModuleResolutionKind.BaseUrl) {
|
||||
if (options.baseUrl === undefined && options.inferredBaseUrl === undefined) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.moduleResolution_kind_baseUrl_cannot_be_used_without_specifying_baseUrl_option));
|
||||
}
|
||||
}
|
||||
else if (options.moduleResolution === undefined) {
|
||||
// if module resolution kind is not specified it is an error to have baseUrl\paths\rootDirs and module === CommonJs
|
||||
// since the former one implies moduleResolutionKind to be BaseUrl and the latter one - Node
|
||||
if (options.module === ModuleKind.CommonJS && (options.baseUrl || options.paths || options.rootDirs)) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Module_resolution_kind_cannot_be_determined_automatically_Please_specify_module_resolution_explicitly_via_moduleResolution_option));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// here it is known that moduleResolution is not baseurl and is not undefined
|
||||
if (options.baseUrl !== undefined) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_used_when_option_moduleResolution_is_baseUrl, "baseUrl"));
|
||||
}
|
||||
if (options.paths) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_used_when_option_moduleResolution_is_baseUrl, "paths"));
|
||||
}
|
||||
if (options.rootDirs) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_can_only_be_used_when_option_moduleResolution_is_baseUrl, "rootDirs"));
|
||||
}
|
||||
if (options.paths && options.baseUrl === undefined) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_paths_cannot_be_used_without_specifying_baseUrl_option));
|
||||
}
|
||||
|
||||
if (options.paths) {
|
||||
|
|
|
@ -2376,8 +2376,7 @@ namespace ts {
|
|||
|
||||
export enum ModuleResolutionKind {
|
||||
Classic = 1,
|
||||
NodeJs = 2,
|
||||
BaseUrl = 3
|
||||
NodeJs = 2
|
||||
}
|
||||
|
||||
export type RootPaths = string[];
|
||||
|
@ -2442,8 +2441,6 @@ namespace ts {
|
|||
|
||||
// Skip checking lib.d.ts to help speed up tests.
|
||||
/* @internal */ skipDefaultLibCheck?: boolean;
|
||||
// inferred baseUrl - currently this will be set in 'parseJsonConfigFileContent' to 'baseDir'
|
||||
/* @internal */ inferredBaseUrl?: string;
|
||||
|
||||
[option: string]: string | number | boolean | TsConfigOnlyOptions;
|
||||
}
|
||||
|
|
|
@ -139,6 +139,14 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
}
|
||||
});
|
||||
|
||||
it (`Correct module resolution tracing for ${fileName}`, () => {
|
||||
if (options.traceModuleResolution) {
|
||||
Harness.Baseline.runBaseline("Correct sourcemap content for " + fileName, justName.replace(/\.tsx?$/, ".trace.json"), () => {
|
||||
return JSON.stringify(result.traceResults || [], undefined, 4);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Source maps?
|
||||
it("Correct sourcemap content for " + fileName, () => {
|
||||
if (options.sourceMap || options.inlineSourceMap) {
|
||||
|
|
|
@ -985,9 +985,6 @@ namespace Harness {
|
|||
if (harnessSettings) {
|
||||
setCompilerOptionsFromHarnessSetting(harnessSettings, options);
|
||||
}
|
||||
if (options.inferredBaseUrl) {
|
||||
options.inferredBaseUrl = ts.getNormalizedAbsolutePath(options.inferredBaseUrl, currentDirectory);
|
||||
}
|
||||
if (options.rootDirs) {
|
||||
options.rootDirs = ts.map(options.rootDirs, d => ts.getNormalizedAbsolutePath(d, currentDirectory));
|
||||
}
|
||||
|
@ -1025,13 +1022,19 @@ namespace Harness {
|
|||
useCaseSensitiveFileNames,
|
||||
currentDirectory,
|
||||
options.newLine);
|
||||
|
||||
let traceResults: string[];
|
||||
if (options.traceModuleResolution) {
|
||||
traceResults = [];
|
||||
compilerHost.trace = text => traceResults.push(text);
|
||||
}
|
||||
const program = ts.createProgram(programFileNames, options, compilerHost);
|
||||
|
||||
const emitResult = program.emit();
|
||||
|
||||
const errors = ts.getPreEmitDiagnostics(program);
|
||||
|
||||
const result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
const result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps, traceResults);
|
||||
return { result, options };
|
||||
}
|
||||
|
||||
|
@ -1312,7 +1315,7 @@ namespace Harness {
|
|||
|
||||
/** @param fileResults an array of strings for the fileName and an ITextWriter with its code */
|
||||
constructor(fileResults: GeneratedFile[], errors: ts.Diagnostic[], public program: ts.Program,
|
||||
public currentDirectoryForProgram: string, private sourceMapData: ts.SourceMapData[]) {
|
||||
public currentDirectoryForProgram: string, private sourceMapData: ts.SourceMapData[], public traceResults: string[]) {
|
||||
|
||||
for (const emittedFile of fileResults) {
|
||||
if (isDTS(emittedFile.fileName)) {
|
||||
|
|
|
@ -547,7 +547,8 @@ namespace Harness.LanguageService {
|
|||
}
|
||||
|
||||
directoryExists(path: string): boolean {
|
||||
return false;
|
||||
// for tests assume that directory exists
|
||||
return true;
|
||||
}
|
||||
|
||||
getExecutingFilePath(): string {
|
||||
|
|
|
@ -2777,6 +2777,9 @@ namespace ts {
|
|||
return directoryProbablyExists(directoryName, host);
|
||||
}
|
||||
};
|
||||
if (host.trace) {
|
||||
compilerHost.trace = message => host.trace(message);
|
||||
}
|
||||
|
||||
if (host.resolveModuleNames) {
|
||||
compilerHost.resolveModuleNames = (moduleNames, containingFile) => host.resolveModuleNames(moduleNames, containingFile);
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution1.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
// user defined base url
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
|
||||
declare function use(a: any): void;
|
||||
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
export {x} from "./file3"
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
//// [file2.js]
|
||||
"use strict";
|
||||
var file3_1 = require("./file3");
|
||||
exports.x = file3_1.x;
|
||||
//// [file1.js]
|
||||
// user defined base url
|
||||
"use strict";
|
||||
var file2_1 = require("folder2/file2");
|
||||
use(file2_1.x.toExponential());
|
|
@ -1,25 +0,0 @@
|
|||
=== tests/cases/compiler/root/folder1/file1.ts ===
|
||||
|
||||
// user defined base url
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
>x : Symbol(x, Decl(file1.ts, 3, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 3, 31))
|
||||
>a : Symbol(a, Decl(file1.ts, 5, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 3, 31))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 3, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== tests/cases/compiler/root/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 8))
|
||||
|
||||
=== tests/cases/compiler/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
=== tests/cases/compiler/root/folder1/file1.ts ===
|
||||
|
||||
// user defined base url
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
>x : number
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : (a: any) => void
|
||||
>a : any
|
||||
|
||||
use(x.toExponential());
|
||||
>use(x.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== tests/cases/compiler/root/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : number
|
||||
|
||||
=== tests/cases/compiler/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution10.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2.ts'
|
||||
|
||||
export var z = x.toExponential();
|
||||
|
||||
//// [file2.ts]
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.ts]
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
let z = y.toLowerCase();
|
||||
|
||||
|
||||
//// [file3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "folder1/file3"], function (require, exports, file3_1) {
|
||||
"use strict";
|
||||
exports.x = file3_1.x; // should be resolved to 'folder1/file3.ts'
|
||||
});
|
||||
//// [file1.js]
|
||||
define(["require", "exports", "./file2"], function (require, exports, file2_1) {
|
||||
"use strict";
|
||||
exports.z = file2_1.x.toExponential();
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "../folder1/file1"], function (require, exports, file1_1) {
|
||||
"use strict";
|
||||
var z = file1_1.z.toLowerCase();
|
||||
});
|
|
@ -1,29 +0,0 @@
|
|||
=== tests/cases/compiler/root/folder1/file1.ts ===
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2.ts'
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
export var z = x.toExponential();
|
||||
>z : Symbol(z, Decl(file1.ts, 2, 10))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== tests/cases/compiler/root/generated/folder1/file2.ts ===
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 8))
|
||||
|
||||
=== tests/cases/compiler/root/folder1/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
||||
=== tests/cases/compiler/root/generated/folder2/file3.ts ===
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
>z : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
>y : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
|
||||
let z = y.toLowerCase();
|
||||
>z : Symbol(z, Decl(file3.ts, 1, 3))
|
||||
>y.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
=== tests/cases/compiler/root/folder1/file1.ts ===
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2.ts'
|
||||
>x : number
|
||||
|
||||
export var z = x.toExponential();
|
||||
>z : string
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== tests/cases/compiler/root/generated/folder1/file2.ts ===
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
>x : number
|
||||
|
||||
=== tests/cases/compiler/root/folder1/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== tests/cases/compiler/root/generated/folder2/file3.ts ===
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
>z : string
|
||||
>y : string
|
||||
|
||||
let z = y.toLowerCase();
|
||||
>z : string
|
||||
>y.toLowerCase() : string
|
||||
>y.toLowerCase : () => string
|
||||
>y : string
|
||||
>toLowerCase : () => string
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution10_1.ts] ////
|
||||
|
||||
//// [file2.ts]
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.ts]
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
let z = y.toLowerCase();
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2.ts'
|
||||
|
||||
export var z = x.toExponential();
|
||||
|
||||
|
||||
//// [file3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "folder1/file3"], function (require, exports, file3_1) {
|
||||
"use strict";
|
||||
exports.x = file3_1.x; // should be resolved to 'folder1/file3.ts'
|
||||
});
|
||||
//// [file1.js]
|
||||
define(["require", "exports", "./file2"], function (require, exports, file2_1) {
|
||||
"use strict";
|
||||
exports.z = file2_1.x.toExponential();
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "../folder1/file1"], function (require, exports, file1_1) {
|
||||
"use strict";
|
||||
var z = file1_1.z.toLowerCase();
|
||||
});
|
|
@ -1,29 +0,0 @@
|
|||
=== c:/root/generated/folder1/file2.ts ===
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 8))
|
||||
|
||||
=== c:/root/folder1/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
||||
=== c:/root/generated/folder2/file3.ts ===
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
>z : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
>y : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
|
||||
let z = y.toLowerCase();
|
||||
>z : Symbol(z, Decl(file3.ts, 1, 3))
|
||||
>y.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/folder1/file1.ts ===
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2.ts'
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
export var z = x.toExponential();
|
||||
>z : Symbol(z, Decl(file1.ts, 2, 10))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
=== c:/root/generated/folder1/file2.ts ===
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
>x : number
|
||||
|
||||
=== c:/root/folder1/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== c:/root/generated/folder2/file3.ts ===
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
>z : string
|
||||
>y : string
|
||||
|
||||
let z = y.toLowerCase();
|
||||
>z : string
|
||||
>y.toLowerCase() : string
|
||||
>y.toLowerCase : () => string
|
||||
>y : string
|
||||
>toLowerCase : () => string
|
||||
|
||||
=== c:/root/folder1/file1.ts ===
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2.ts'
|
||||
>x : number
|
||||
|
||||
export var z = x.toExponential();
|
||||
>z : string
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution10_2.ts] ////
|
||||
|
||||
//// [file2.ts]
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.ts]
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
let z = y.toLowerCase();
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2.ts'
|
||||
|
||||
export var z = x.toExponential();
|
||||
|
||||
|
||||
//// [file3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "folder1/file3"], function (require, exports, file3_1) {
|
||||
"use strict";
|
||||
exports.x = file3_1.x; // should be resolved to 'folder1/file3.ts'
|
||||
});
|
||||
//// [file1.js]
|
||||
define(["require", "exports", "./file2"], function (require, exports, file2_1) {
|
||||
"use strict";
|
||||
exports.z = file2_1.x.toExponential();
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "../folder1/file1"], function (require, exports, file1_1) {
|
||||
"use strict";
|
||||
var z = file1_1.z.toLowerCase();
|
||||
});
|
|
@ -1,29 +0,0 @@
|
|||
=== c:/root/src/generated/folder1/file2.ts ===
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 8))
|
||||
|
||||
=== c:/root/src/folder1/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
||||
=== c:/root/src/generated/folder2/file3.ts ===
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
>z : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
>y : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
|
||||
let z = y.toLowerCase();
|
||||
>z : Symbol(z, Decl(file3.ts, 1, 3))
|
||||
>y.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/src/folder1/file1.ts ===
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2.ts'
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
export var z = x.toExponential();
|
||||
>z : Symbol(z, Decl(file1.ts, 2, 10))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
=== c:/root/src/generated/folder1/file2.ts ===
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
>x : number
|
||||
|
||||
=== c:/root/src/folder1/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== c:/root/src/generated/folder2/file3.ts ===
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
>z : string
|
||||
>y : string
|
||||
|
||||
let z = y.toLowerCase();
|
||||
>z : string
|
||||
>y.toLowerCase() : string
|
||||
>y.toLowerCase : () => string
|
||||
>y : string
|
||||
>toLowerCase : () => string
|
||||
|
||||
=== c:/root/src/folder1/file1.ts ===
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2.ts'
|
||||
>x : number
|
||||
|
||||
export var z = x.toExponential();
|
||||
>z : string
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution11.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2/file.ts'
|
||||
|
||||
export var z = x.toExponential();
|
||||
|
||||
//// [file.ts]
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.ts]
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
let z = y.toLowerCase();
|
||||
|
||||
|
||||
//// [file3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
});
|
||||
//// [file.js]
|
||||
define(["require", "exports", "folder1/file3"], function (require, exports, file3_1) {
|
||||
"use strict";
|
||||
exports.x = file3_1.x; // should be resolved to 'folder1/file3.ts'
|
||||
});
|
||||
//// [file1.js]
|
||||
define(["require", "exports", "./file2"], function (require, exports, file2_1) {
|
||||
"use strict";
|
||||
exports.z = file2_1.x.toExponential();
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "../folder1/file1"], function (require, exports, file1_1) {
|
||||
"use strict";
|
||||
var z = file1_1.z.toLowerCase();
|
||||
});
|
|
@ -1,29 +0,0 @@
|
|||
=== tests/cases/compiler/root/folder1/file1.ts ===
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2/file.ts'
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
export var z = x.toExponential();
|
||||
>z : Symbol(z, Decl(file1.ts, 2, 10))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== tests/cases/compiler/root/generated/folder1/file2/file.ts ===
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
>x : Symbol(x, Decl(file.ts, 0, 8))
|
||||
|
||||
=== tests/cases/compiler/root/folder1/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
||||
=== tests/cases/compiler/root/generated/folder2/file3.ts ===
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
>z : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
>y : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
|
||||
let z = y.toLowerCase();
|
||||
>z : Symbol(z, Decl(file3.ts, 1, 3))
|
||||
>y.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(file3.ts, 0, 8))
|
||||
>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --))
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
=== tests/cases/compiler/root/folder1/file1.ts ===
|
||||
import {x} from "./file2" // should be resolved to 'generated/folder1/file2/file.ts'
|
||||
>x : number
|
||||
|
||||
export var z = x.toExponential();
|
||||
>z : string
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== tests/cases/compiler/root/generated/folder1/file2/file.ts ===
|
||||
export {x} from "folder1/file3" // should be resolved to 'folder1/file3.ts'
|
||||
>x : number
|
||||
|
||||
=== tests/cases/compiler/root/folder1/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== tests/cases/compiler/root/generated/folder2/file3.ts ===
|
||||
import {z as y} from "../folder1/file1" // should be resolved to 'folder1/file1.ts'
|
||||
>z : string
|
||||
>y : string
|
||||
|
||||
let z = y.toLowerCase();
|
||||
>z : string
|
||||
>y.toLowerCase() : string
|
||||
>y.toLowerCase : () => string
|
||||
>y : string
|
||||
>toLowerCase : () => string
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution1_1.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
// user defined base url
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
|
||||
declare function use(a: any): void;
|
||||
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
export {x} from "./file3"
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
//// [file2.js]
|
||||
"use strict";
|
||||
var file3_1 = require("./file3");
|
||||
exports.x = file3_1.x;
|
||||
//// [file1.js]
|
||||
// user defined base url
|
||||
"use strict";
|
||||
var file2_1 = require("folder2/file2");
|
||||
use(file2_1.x.toExponential());
|
|
@ -1,25 +0,0 @@
|
|||
=== c:/root/folder1/file1.ts ===
|
||||
|
||||
// user defined base url
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
>x : Symbol(x, Decl(file1.ts, 3, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 3, 31))
|
||||
>a : Symbol(a, Decl(file1.ts, 5, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 3, 31))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 3, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 8))
|
||||
|
||||
=== c:/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
error TS5060: Option 'paths' cannot be used without specifying '--baseUrl' option.
|
||||
|
||||
|
||||
!!! error TS5060: Option 'paths' cannot be used without specifying '--baseUrl' option.
|
||||
==== c:/root/f1.ts (0 errors) ====
|
||||
export var x = 1;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
//// [f1.ts]
|
||||
export var x = 1;
|
||||
|
||||
|
||||
//// [f1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1,7 @@
|
|||
error TS5060: Option 'paths' cannot be used without specifying '--baseUrl' option.
|
||||
|
||||
|
||||
!!! error TS5060: Option 'paths' cannot be used without specifying '--baseUrl' option.
|
||||
==== c:/root/f1.ts (0 errors) ====
|
||||
export var x = 1;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
//// [f1.ts]
|
||||
export var x = 1;
|
||||
|
||||
|
||||
//// [f1.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -1,26 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution2.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file2"
|
||||
|
||||
declare function use(a: any): void;
|
||||
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
export {x} from "./file3"
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
//// [file2.js]
|
||||
"use strict";
|
||||
var file3_1 = require("./file3");
|
||||
exports.x = file3_1.x;
|
||||
//// [file1.js]
|
||||
"use strict";
|
||||
var file2_1 = require("folder2/file2");
|
||||
use(file2_1.x.toExponential());
|
|
@ -1,22 +0,0 @@
|
|||
=== tests/cases/compiler/root/folder1/file1.ts ===
|
||||
import {x} from "folder2/file2"
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>a : Symbol(a, Decl(file1.ts, 2, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== tests/cases/compiler/root/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 8))
|
||||
|
||||
=== tests/cases/compiler/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
=== tests/cases/compiler/root/folder1/file1.ts ===
|
||||
import {x} from "folder2/file2"
|
||||
>x : number
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : (a: any) => void
|
||||
>a : any
|
||||
|
||||
use(x.toExponential());
|
||||
>use(x.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== tests/cases/compiler/root/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : number
|
||||
|
||||
=== tests/cases/compiler/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution2_1.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file2"
|
||||
|
||||
declare function use(a: any): void;
|
||||
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
export {x} from "./file3"
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
//// [file2.js]
|
||||
"use strict";
|
||||
var file3_1 = require("./file3");
|
||||
exports.x = file3_1.x;
|
||||
//// [file1.js]
|
||||
"use strict";
|
||||
var file2_1 = require("folder2/file2");
|
||||
use(file2_1.x.toExponential());
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1,8 @@
|
|||
error TS5061: Pattern '*1*' can have at most one '*' character
|
||||
error TS5062: Substitution '*2*' in pattern '*1*' in can have at most one '*' character
|
||||
|
||||
|
||||
!!! error TS5061: Pattern '*1*' can have at most one '*' character
|
||||
!!! error TS5062: Substitution '*2*' in pattern '*1*' in can have at most one '*' character
|
||||
==== tests/cases/compiler/root/src/folder1/file1.ts (0 errors) ====
|
||||
export var x = 1;
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -1,26 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution3.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file2"
|
||||
|
||||
declare function use(a: any): void;
|
||||
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
export {x} from "./file3"
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
//// [file2.js]
|
||||
"use strict";
|
||||
var file3_1 = require("./file3");
|
||||
exports.x = file3_1.x;
|
||||
//// [file1.js]
|
||||
"use strict";
|
||||
var file2_1 = require("folder2/file2");
|
||||
use(file2_1.x.toExponential());
|
|
@ -1,22 +0,0 @@
|
|||
=== tests/cases/compiler/root/src/folder1/file1.ts ===
|
||||
import {x} from "folder2/file2"
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>a : Symbol(a, Decl(file1.ts, 2, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== tests/cases/compiler/root/src/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 8))
|
||||
|
||||
=== tests/cases/compiler/root/src/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
=== tests/cases/compiler/root/src/folder1/file1.ts ===
|
||||
import {x} from "folder2/file2"
|
||||
>x : number
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : (a: any) => void
|
||||
>a : any
|
||||
|
||||
use(x.toExponential());
|
||||
>use(x.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== tests/cases/compiler/root/src/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : number
|
||||
|
||||
=== tests/cases/compiler/root/src/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution3_1.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file2"
|
||||
|
||||
declare function use(a: any): void;
|
||||
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
export {x} from "./file3"
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
//// [file2.js]
|
||||
"use strict";
|
||||
var file3_1 = require("./file3");
|
||||
exports.x = file3_1.x;
|
||||
//// [file1.js]
|
||||
"use strict";
|
||||
var file2_1 = require("folder2/file2");
|
||||
use(file2_1.x.toExponential());
|
|
@ -1,22 +0,0 @@
|
|||
=== c:/root/src/folder1/file1.ts ===
|
||||
import {x} from "folder2/file2"
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>a : Symbol(a, Decl(file1.ts, 2, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/src/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 8))
|
||||
|
||||
=== c:/root/src/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
=== c:/root/src/folder1/file1.ts ===
|
||||
import {x} from "folder2/file2"
|
||||
>x : number
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : (a: any) => void
|
||||
>a : any
|
||||
|
||||
use(x.toExponential());
|
||||
>use(x.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/src/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : number
|
||||
|
||||
=== c:/root/src/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution3_classic.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
// baseUrl set via command line
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
declare function use(a: any): void;
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
import {y as b} from "file4" // found with fallback
|
||||
export var x = a + b;
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file4.ts]
|
||||
export var y = 100;
|
||||
|
||||
//// [file3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
});
|
||||
//// [file4.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.y = 100;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "./file3", "file4"], function (require, exports, file3_1, file4_1) {
|
||||
"use strict";
|
||||
exports.x = file3_1.x + file4_1.y;
|
||||
});
|
||||
//// [file1.js]
|
||||
// baseUrl set via command line
|
||||
define(["require", "exports", "folder2/file2"], function (require, exports, file2_1) {
|
||||
"use strict";
|
||||
use(file2_1.x.toExponential());
|
||||
});
|
|
@ -0,0 +1,39 @@
|
|||
=== c:/root/folder1/file1.ts ===
|
||||
|
||||
// baseUrl set via command line
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
>x : Symbol(x, Decl(file1.ts, 3, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 3, 31))
|
||||
>a : Symbol(a, Decl(file1.ts, 4, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 3, 31))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 3, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/folder2/file2.ts ===
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
>x : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
|
||||
import {y as b} from "file4" // found with fallback
|
||||
>y : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
|
||||
export var x = a + b;
|
||||
>x : Symbol(x, Decl(file2.ts, 2, 10))
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
|
||||
=== c:/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
||||
=== c:/file4.ts ===
|
||||
export var y = 100;
|
||||
>y : Symbol(y, Decl(file4.ts, 0, 10))
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
[
|
||||
"======== Resolving module 'folder2/file2' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"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.",
|
||||
"======== 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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'file4'",
|
||||
"Resolving module name 'file4' relative to base url 'c:/root' - 'c:/root/file4'.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.tsx' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/folder2/file4.ts' does not exist.",
|
||||
"File 'c:/root/folder2/file4.tsx' does not exist.",
|
||||
"File 'c:/root/folder2/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.tsx' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"File 'c:/file4.ts' exist - use it as a module resolution result.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/file4.ts'. ========"
|
||||
]
|
|
@ -0,0 +1,44 @@
|
|||
=== c:/root/folder1/file1.ts ===
|
||||
|
||||
// baseUrl set via command line
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
>x : number
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : (a: any) => void
|
||||
>a : any
|
||||
|
||||
use(x.toExponential());
|
||||
>use(x.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/folder2/file2.ts ===
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
>x : number
|
||||
>a : number
|
||||
|
||||
import {y as b} from "file4" // found with fallback
|
||||
>y : number
|
||||
>b : number
|
||||
|
||||
export var x = a + b;
|
||||
>x : number
|
||||
>a + b : number
|
||||
>a : number
|
||||
>b : number
|
||||
|
||||
=== c:/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== c:/file4.ts ===
|
||||
export var y = 100;
|
||||
>y : number
|
||||
>100 : number
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution3_node.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
// baseUrl set via command line
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
declare function use(a: any): void;
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
import {y as b} from "file4" // found with fallback
|
||||
export var x = a + b;
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [index.d.ts]
|
||||
export var y: number;
|
||||
|
||||
//// [file3.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
//// [file2.js]
|
||||
"use strict";
|
||||
var file3_1 = require("./file3"); // found with baseurl
|
||||
var file4_1 = require("file4"); // found with fallback
|
||||
exports.x = file3_1.x + file4_1.y;
|
||||
//// [file1.js]
|
||||
// baseUrl set via command line
|
||||
"use strict";
|
||||
var file2_1 = require("folder2/file2");
|
||||
use(file2_1.x.toExponential());
|
|
@ -0,0 +1,39 @@
|
|||
=== c:/root/folder1/file1.ts ===
|
||||
|
||||
// baseUrl set via command line
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
>x : Symbol(x, Decl(file1.ts, 3, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 3, 31))
|
||||
>a : Symbol(a, Decl(file1.ts, 4, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 3, 31))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 3, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/folder2/file2.ts ===
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
>x : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
|
||||
import {y as b} from "file4" // found with fallback
|
||||
>y : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
|
||||
export var x = a + b;
|
||||
>x : Symbol(x, Decl(file2.ts, 2, 10))
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
|
||||
=== c:/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
||||
=== c:/node_modules/file4/index.d.ts ===
|
||||
export var y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 0, 10))
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
[
|
||||
"======== Resolving module 'folder2/file2' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'NodeJs'.",
|
||||
"'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.",
|
||||
"======== 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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'file4'",
|
||||
"Resolving module name 'file4' relative to base url 'c:/root' - 'c:/root/file4'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/file4'.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.tsx' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/file4/package.json' does not exist.",
|
||||
"File 'c:/root/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/file4/index.d.ts' does not exist.",
|
||||
"Loading module 'file4' from 'node_modules' folder.",
|
||||
"File 'c:/root/folder2/node_modules/file4.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/file4.tsx' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/file4/package.json' does not exist.",
|
||||
"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/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.",
|
||||
"File 'c:/root/node_modules/file4/package.json' does not exist.",
|
||||
"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' 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.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/node_modules/file4/index.d.ts'. ========"
|
||||
]
|
|
@ -0,0 +1,43 @@
|
|||
=== c:/root/folder1/file1.ts ===
|
||||
|
||||
// baseUrl set via command line
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
>x : number
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : (a: any) => void
|
||||
>a : any
|
||||
|
||||
use(x.toExponential());
|
||||
>use(x.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/folder2/file2.ts ===
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
>x : number
|
||||
>a : number
|
||||
|
||||
import {y as b} from "file4" // found with fallback
|
||||
>y : number
|
||||
>b : number
|
||||
|
||||
export var x = a + b;
|
||||
>x : number
|
||||
>a + b : number
|
||||
>a : number
|
||||
>b : number
|
||||
|
||||
=== c:/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== c:/node_modules/file4/index.d.ts ===
|
||||
export var y: number;
|
||||
>y : number
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution4.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file2"
|
||||
|
||||
declare function use(a: any): void;
|
||||
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
export {x} from "./file3"
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "./file3"], function (require, exports, file3_1) {
|
||||
"use strict";
|
||||
exports.x = file3_1.x;
|
||||
});
|
||||
//// [file1.js]
|
||||
define(["require", "exports", "folder2/file2"], function (require, exports, file2_1) {
|
||||
"use strict";
|
||||
use(file2_1.x.toExponential());
|
||||
});
|
|
@ -1,22 +0,0 @@
|
|||
=== tests/cases/compiler/root/src/folder1/file1.ts ===
|
||||
import {x} from "folder2/file2"
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>a : Symbol(a, Decl(file1.ts, 2, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== tests/cases/compiler/root/src/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 8))
|
||||
|
||||
=== tests/cases/compiler/root/src/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
=== tests/cases/compiler/root/src/folder1/file1.ts ===
|
||||
import {x} from "folder2/file2"
|
||||
>x : number
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : (a: any) => void
|
||||
>a : any
|
||||
|
||||
use(x.toExponential());
|
||||
>use(x.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== tests/cases/compiler/root/src/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : number
|
||||
|
||||
=== tests/cases/compiler/root/src/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution4_1.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file2"
|
||||
|
||||
declare function use(a: any): void;
|
||||
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
export {x} from "./file3"
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "./file3"], function (require, exports, file3_1) {
|
||||
"use strict";
|
||||
exports.x = file3_1.x;
|
||||
});
|
||||
//// [file1.js]
|
||||
define(["require", "exports", "folder2/file2"], function (require, exports, file2_1) {
|
||||
"use strict";
|
||||
use(file2_1.x.toExponential());
|
||||
});
|
|
@ -1,22 +0,0 @@
|
|||
=== c:/root/src/folder1/file1.ts ===
|
||||
import {x} from "folder2/file2"
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>a : Symbol(a, Decl(file1.ts, 2, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/src/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 8))
|
||||
|
||||
=== c:/root/src/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
=== c:/root/src/folder1/file1.ts ===
|
||||
import {x} from "folder2/file2"
|
||||
>x : number
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : (a: any) => void
|
||||
>a : any
|
||||
|
||||
use(x.toExponential());
|
||||
>use(x.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/src/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : number
|
||||
|
||||
=== c:/root/src/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution4_classic.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file2"
|
||||
declare function use(a: any): void;
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
import {y as b} from "file4" // found with fallback
|
||||
export var x = a + b;
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file4.ts]
|
||||
export var y = 100;
|
||||
|
||||
//// [file3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
});
|
||||
//// [file4.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.y = 100;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "./file3", "file4"], function (require, exports, file3_1, file4_1) {
|
||||
"use strict";
|
||||
exports.x = file3_1.x + file4_1.y;
|
||||
});
|
||||
//// [file1.js]
|
||||
define(["require", "exports", "folder2/file2"], function (require, exports, file2_1) {
|
||||
"use strict";
|
||||
use(file2_1.x.toExponential());
|
||||
});
|
|
@ -4,7 +4,7 @@ import {x} from "folder2/file2"
|
|||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>a : Symbol(a, Decl(file1.ts, 2, 21))
|
||||
>a : Symbol(a, Decl(file1.ts, 1, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
|
@ -13,10 +13,24 @@ use(x.toExponential());
|
|||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
>x : Symbol(x, Decl(file2.ts, 0, 8))
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
>x : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
|
||||
import {y as b} from "file4" // found with fallback
|
||||
>y : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
|
||||
export var x = a + b;
|
||||
>x : Symbol(x, Decl(file2.ts, 2, 10))
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
|
||||
=== c:/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
||||
=== c:/file4.ts ===
|
||||
export var y = 100;
|
||||
>y : Symbol(y, Decl(file4.ts, 0, 10))
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
[
|
||||
"======== Resolving module 'folder2/file2' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"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.",
|
||||
"======== 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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'file4'",
|
||||
"Resolving module name 'file4' relative to base url 'c:/root' - 'c:/root/file4'.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.tsx' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/folder2/file4.ts' does not exist.",
|
||||
"File 'c:/root/folder2/file4.tsx' does not exist.",
|
||||
"File 'c:/root/folder2/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.tsx' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"File 'c:/file4.ts' exist - use it as a module resolution result.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/file4.ts'. ========"
|
||||
]
|
|
@ -1,7 +1,4 @@
|
|||
=== c:/root/folder1/file1.ts ===
|
||||
|
||||
// user defined base url
|
||||
|
||||
import {x} from "folder2/file2"
|
||||
>x : number
|
||||
|
||||
|
@ -18,11 +15,27 @@ use(x.toExponential());
|
|||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
>x : number
|
||||
>a : number
|
||||
|
||||
import {y as b} from "file4" // found with fallback
|
||||
>y : number
|
||||
>b : number
|
||||
|
||||
export var x = a + b;
|
||||
>x : number
|
||||
>a + b : number
|
||||
>a : number
|
||||
>b : number
|
||||
|
||||
=== c:/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== c:/file4.ts ===
|
||||
export var y = 100;
|
||||
>y : number
|
||||
>100 : number
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution4_node.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file2"
|
||||
declare function use(a: any): void;
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.ts]
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
import {y as b} from "file4" // found with fallback
|
||||
export var x = a + b;
|
||||
|
||||
//// [file3.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [index.d.ts]
|
||||
export var y: number;
|
||||
|
||||
//// [file3.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
//// [file2.js]
|
||||
"use strict";
|
||||
var file3_1 = require("./file3"); // found with baseurl
|
||||
var file4_1 = require("file4"); // found with fallback
|
||||
exports.x = file3_1.x + file4_1.y;
|
||||
//// [file1.js]
|
||||
"use strict";
|
||||
var file2_1 = require("folder2/file2");
|
||||
use(file2_1.x.toExponential());
|
|
@ -0,0 +1,36 @@
|
|||
=== c:/root/folder1/file1.ts ===
|
||||
import {x} from "folder2/file2"
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>a : Symbol(a, Decl(file1.ts, 1, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 31))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/folder2/file2.ts ===
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
>x : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
|
||||
import {y as b} from "file4" // found with fallback
|
||||
>y : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
|
||||
export var x = a + b;
|
||||
>x : Symbol(x, Decl(file2.ts, 2, 10))
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
|
||||
=== c:/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 10))
|
||||
|
||||
=== c:/node_modules/file4/index.d.ts ===
|
||||
export var y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 0, 10))
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
[
|
||||
"======== Resolving module 'folder2/file2' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'NodeJs'.",
|
||||
"'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.",
|
||||
"======== 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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'file4'",
|
||||
"Resolving module name 'file4' relative to base url 'c:/root' - 'c:/root/file4'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/file4'.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.tsx' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/file4/package.json' does not exist.",
|
||||
"File 'c:/root/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/file4/index.d.ts' does not exist.",
|
||||
"Loading module 'file4' from 'node_modules' folder.",
|
||||
"File 'c:/root/folder2/node_modules/file4.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/file4.tsx' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/folder2/node_modules/file4/package.json' does not exist.",
|
||||
"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/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.",
|
||||
"File 'c:/root/node_modules/file4/package.json' does not exist.",
|
||||
"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' 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.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/node_modules/file4/index.d.ts'. ========"
|
||||
]
|
|
@ -15,11 +15,26 @@ use(x.toExponential());
|
|||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/folder2/file2.ts ===
|
||||
export {x} from "./file3"
|
||||
import {x as a} from "./file3" // found with baseurl
|
||||
>x : number
|
||||
>a : number
|
||||
|
||||
import {y as b} from "file4" // found with fallback
|
||||
>y : number
|
||||
>b : number
|
||||
|
||||
export var x = a + b;
|
||||
>x : number
|
||||
>a + b : number
|
||||
>a : number
|
||||
>b : number
|
||||
|
||||
=== c:/root/folder2/file3.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== c:/node_modules/file4/index.d.ts ===
|
||||
export var y: number;
|
||||
>y : number
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
error TS5064: Module resolution kind cannot be determined automatically. Please specify module resolution explicitly via 'moduleResolution' option.
|
||||
|
||||
|
||||
!!! error TS5064: Module resolution kind cannot be determined automatically. Please specify module resolution explicitly via 'moduleResolution' option.
|
||||
==== tests/cases/compiler/root/src/folder1/file1.ts (0 errors) ====
|
||||
export var x = 1;
|
|
@ -1,4 +1,4 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution7_2.ts] ////
|
||||
//// [tests/cases/compiler/pathMappingBasedModuleResolution5_classic.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file1"
|
|
@ -51,7 +51,7 @@ export var y = 1;
|
|||
export var z = 1;
|
||||
>z : Symbol(z, Decl(file3.ts, 0, 10))
|
||||
|
||||
=== c:/sharedrepo/file4.ts ===
|
||||
=== c:/file4.ts ===
|
||||
export var z1 = 1;
|
||||
>z1 : Symbol(z1, Decl(file4.ts, 0, 10))
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
[
|
||||
"======== Resolving module 'folder2/file1' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Classic'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'folder2/file1'",
|
||||
"'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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'folder3/file2'",
|
||||
"'paths' option is specified, looking for a pattern to match module name 'folder3/file2'.",
|
||||
"Module name 'folder3/file2', matched pattern '*'.",
|
||||
"Trying substitution '*', candidate module location: 'folder3/file2'.",
|
||||
"File 'c:/root/folder3/file2.ts' does not exist.",
|
||||
"File 'c:/root/folder3/file2.tsx' 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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'components/file3'",
|
||||
"'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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'file4'",
|
||||
"'paths' option is specified, looking for a pattern to match module name 'file4'.",
|
||||
"Module name 'file4', matched pattern '*'.",
|
||||
"Trying substitution '*', candidate module location: 'file4'.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.tsx' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"Trying substitution 'generated/*', candidate module location: 'generated/file4'.",
|
||||
"File 'c:/root/generated/file4.ts' does not exist.",
|
||||
"File 'c:/root/generated/file4.tsx' does not exist.",
|
||||
"File 'c:/root/generated/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/folder1/file4.ts' does not exist.",
|
||||
"File 'c:/root/folder1/file4.tsx' does not exist.",
|
||||
"File 'c:/root/folder1/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.tsx' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"File 'c:/file4.ts' exist - use it as a module resolution result.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/file4.ts'. ========"
|
||||
]
|
|
@ -62,7 +62,7 @@ export var z = 1;
|
|||
>z : number
|
||||
>1 : number
|
||||
|
||||
=== c:/sharedrepo/file4.ts ===
|
||||
=== c:/file4.ts ===
|
||||
export var z1 = 1;
|
||||
>z1 : number
|
||||
>1 : number
|
|
@ -0,0 +1,46 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution5_node.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file1"
|
||||
import {y} from "folder3/file2"
|
||||
import {z} from "components/file3"
|
||||
import {z1} from "file4"
|
||||
|
||||
declare function use(a: any): void;
|
||||
|
||||
use(x.toExponential());
|
||||
use(y.toExponential());
|
||||
use(z.toExponential());
|
||||
use(z1.toExponential());
|
||||
|
||||
//// [file1.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file2.ts]
|
||||
export var y = 1;
|
||||
|
||||
//// [index.d.ts]
|
||||
export var z: number;
|
||||
|
||||
//// [file4.ts]
|
||||
export var z1 = 1;
|
||||
|
||||
//// [file1.js]
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
//// [file2.js]
|
||||
"use strict";
|
||||
exports.y = 1;
|
||||
//// [file4.js]
|
||||
"use strict";
|
||||
exports.z1 = 1;
|
||||
//// [file1.js]
|
||||
"use strict";
|
||||
var file1_1 = require("folder2/file1");
|
||||
var file2_1 = require("folder3/file2");
|
||||
var file3_1 = require("components/file3");
|
||||
var file4_1 = require("file4");
|
||||
use(file1_1.x.toExponential());
|
||||
use(file2_1.y.toExponential());
|
||||
use(file3_1.z.toExponential());
|
||||
use(file4_1.z1.toExponential());
|
|
@ -39,19 +39,19 @@ use(z1.toExponential());
|
|||
>z1 : Symbol(z1, Decl(file1.ts, 3, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/src/folder2/file1.ts ===
|
||||
=== c:/root/folder2/file1.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 10))
|
||||
|
||||
=== c:/root/src/generated/folder3/file2.ts ===
|
||||
=== c:/root/generated/folder3/file2.ts ===
|
||||
export var y = 1;
|
||||
>y : Symbol(y, Decl(file2.ts, 0, 10))
|
||||
|
||||
=== c:/root/src/shared/components/file3.ts ===
|
||||
export var z = 1;
|
||||
>z : Symbol(z, Decl(file3.ts, 0, 10))
|
||||
=== c:/root/shared/components/file3/index.d.ts ===
|
||||
export var z: number;
|
||||
>z : Symbol(z, Decl(index.d.ts, 0, 10))
|
||||
|
||||
=== c:/sharedrepo/file4.ts ===
|
||||
=== c:/node_modules/file4.ts ===
|
||||
export var z1 = 1;
|
||||
>z1 : Symbol(z1, Decl(file4.ts, 0, 10))
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
[
|
||||
"======== Resolving module 'folder2/file1' from 'c:/root/folder1/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'folder2/file1'",
|
||||
"'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'.",
|
||||
"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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'folder3/file2'",
|
||||
"'paths' option is specified, looking for a pattern to match module name 'folder3/file2'.",
|
||||
"Module name 'folder3/file2', matched pattern '*'.",
|
||||
"Trying substitution '*', candidate module location: 'folder3/file2'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/folder3/file2'.",
|
||||
"File 'c:/root/folder3/file2.ts' does not exist.",
|
||||
"File 'c:/root/folder3/file2.tsx' does not exist.",
|
||||
"File 'c:/root/folder3/file2.d.ts' does not exist.",
|
||||
"File 'c:/root/folder3/file2/package.json' does not exist.",
|
||||
"File 'c:/root/folder3/file2/index.ts' does not exist.",
|
||||
"File 'c:/root/folder3/file2/index.tsx' does not exist.",
|
||||
"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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'components/file3'",
|
||||
"'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'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/shared/components/file3'.",
|
||||
"File 'c:/root/shared/components/file3.ts' does not exist.",
|
||||
"File 'c:/root/shared/components/file3.tsx' does not exist.",
|
||||
"File 'c:/root/shared/components/file3.d.ts' does not exist.",
|
||||
"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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'file4'",
|
||||
"'paths' option is specified, looking for a pattern to match module name 'file4'.",
|
||||
"Module name 'file4', matched pattern '*'.",
|
||||
"Trying substitution '*', candidate module location: 'file4'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/file4'.",
|
||||
"File 'c:/root/file4.ts' does not exist.",
|
||||
"File 'c:/root/file4.tsx' does not exist.",
|
||||
"File 'c:/root/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/file4/package.json' does not exist.",
|
||||
"File 'c:/root/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/file4/index.d.ts' does not exist.",
|
||||
"Trying substitution 'generated/*', candidate module location: 'generated/file4'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/generated/file4'.",
|
||||
"File 'c:/root/generated/file4.ts' does not exist.",
|
||||
"File 'c:/root/generated/file4.tsx' does not exist.",
|
||||
"File 'c:/root/generated/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/generated/file4/package.json' does not exist.",
|
||||
"File 'c:/root/generated/file4/index.ts' does not exist.",
|
||||
"File 'c:/root/generated/file4/index.tsx' does not exist.",
|
||||
"File 'c:/root/generated/file4/index.d.ts' does not exist.",
|
||||
"Loading module 'file4' from 'node_modules' folder.",
|
||||
"File 'c:/root/folder1/node_modules/file4.ts' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/file4.tsx' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/file4.d.ts' does not exist.",
|
||||
"File 'c:/root/folder1/node_modules/file4/package.json' does not exist.",
|
||||
"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/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.",
|
||||
"File 'c:/root/node_modules/file4/package.json' does not exist.",
|
||||
"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.",
|
||||
"======== Module name 'file4' was successfully resolved to 'c:/node_modules/file4.ts'. ========"
|
||||
]
|
|
@ -47,22 +47,21 @@ use(z1.toExponential());
|
|||
>z1 : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/src/folder2/file1.ts ===
|
||||
=== c:/root/folder2/file1.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== c:/root/src/generated/folder3/file2.ts ===
|
||||
=== c:/root/generated/folder3/file2.ts ===
|
||||
export var y = 1;
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
=== c:/root/src/shared/components/file3.ts ===
|
||||
export var z = 1;
|
||||
=== c:/root/shared/components/file3/index.d.ts ===
|
||||
export var z: number;
|
||||
>z : number
|
||||
>1 : number
|
||||
|
||||
=== c:/sharedrepo/file4.ts ===
|
||||
=== c:/node_modules/file4.ts ===
|
||||
export var z1 = 1;
|
||||
>z1 : number
|
||||
>1 : number
|
|
@ -0,0 +1,23 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution6_classic.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "./project/file3";
|
||||
declare function use(x: string);
|
||||
use(x.toExponential());
|
||||
|
||||
//// [file2.d.ts]
|
||||
export let x: number;
|
||||
|
||||
//// [file3.ts]
|
||||
export {x} from "../file2";
|
||||
|
||||
//// [file3.js]
|
||||
define(["require", "exports", "../file2"], function (require, exports, file2_1) {
|
||||
"use strict";
|
||||
exports.x = file2_1.x;
|
||||
});
|
||||
//// [file1.js]
|
||||
define(["require", "exports", "./project/file3"], function (require, exports, file3_1) {
|
||||
"use strict";
|
||||
use(file3_1.x.toExponential());
|
||||
});
|
|
@ -0,0 +1,22 @@
|
|||
=== c:/root/src/file1.ts ===
|
||||
import {x} from "./project/file3";
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
declare function use(x: string);
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 34))
|
||||
>x : Symbol(x, Decl(file1.ts, 1, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 34))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/src/file2.d.ts ===
|
||||
export let x: number;
|
||||
>x : Symbol(x, Decl(file2.d.ts, 0, 10))
|
||||
|
||||
=== c:/root/generated/src/project/file3.ts ===
|
||||
export {x} from "../file2";
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 8))
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
[
|
||||
"======== Resolving module './project/file3' from 'c:/root/src/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Classic'.",
|
||||
"'rootDirs' option is set, using it to resolve relative module name './project/file3'",
|
||||
"Checking if 'c:/root/src/' is the longest matching prefix for 'c:/root/src/project/file3' - 'true'.",
|
||||
"Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/src/project/file3' - 'false'.",
|
||||
"Longest matching prefix for 'c:/root/src/project/file3' is 'c:/root/src/'",
|
||||
"Loading 'project/file3' from the root dir 'c:/root/src/', candidate location 'c:/root/src/project/file3'",
|
||||
"File 'c:/root/src/project/file3.ts' does not exist.",
|
||||
"File 'c:/root/src/project/file3.tsx' does not exist.",
|
||||
"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.",
|
||||
"======== 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'.",
|
||||
"'rootDirs' option is set, using it to resolve relative module name '../file2'",
|
||||
"Checking if 'c:/root/src/' is the longest matching prefix for 'c:/root/generated/src/file2' - 'false'.",
|
||||
"Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/generated/src/file2' - 'true'.",
|
||||
"Longest matching prefix for 'c:/root/generated/src/file2' is 'c:/root/generated/src/'",
|
||||
"Loading 'file2' from the root dir 'c:/root/generated/src/', candidate location 'c:/root/generated/src/file2'",
|
||||
"File 'c:/root/generated/src/file2.ts' does not exist.",
|
||||
"File 'c:/root/generated/src/file2.tsx' does not exist.",
|
||||
"File 'c:/root/generated/src/file2.d.ts' does not exist.",
|
||||
"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.tsx' does not exist.",
|
||||
"File 'c:/root/src/file2.d.ts' exist - use it as a module resolution result.",
|
||||
"======== Module name '../file2' was successfully resolved to 'c:/root/src/file2.d.ts'. ========"
|
||||
]
|
|
@ -0,0 +1,24 @@
|
|||
=== c:/root/src/file1.ts ===
|
||||
import {x} from "./project/file3";
|
||||
>x : number
|
||||
|
||||
declare function use(x: string);
|
||||
>use : (x: string) => any
|
||||
>x : string
|
||||
|
||||
use(x.toExponential());
|
||||
>use(x.toExponential()) : any
|
||||
>use : (x: string) => any
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/src/file2.d.ts ===
|
||||
export let x: number;
|
||||
>x : number
|
||||
|
||||
=== c:/root/generated/src/project/file3.ts ===
|
||||
export {x} from "../file2";
|
||||
>x : number
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution6_node.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "./project/file3";
|
||||
declare function use(x: string);
|
||||
use(x.toFixed());
|
||||
|
||||
//// [index.d.ts]
|
||||
export let x: number;
|
||||
|
||||
//// [file3.ts]
|
||||
export {x} from "../file2";
|
||||
|
||||
//// [file3.js]
|
||||
"use strict";
|
||||
var file2_1 = require("../file2");
|
||||
exports.x = file2_1.x;
|
||||
//// [file1.js]
|
||||
"use strict";
|
||||
var file3_1 = require("./project/file3");
|
||||
use(file3_1.x.toFixed());
|
|
@ -0,0 +1,22 @@
|
|||
=== c:/root/src/file1.ts ===
|
||||
import {x} from "./project/file3";
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
declare function use(x: string);
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 34))
|
||||
>x : Symbol(x, Decl(file1.ts, 1, 21))
|
||||
|
||||
use(x.toFixed());
|
||||
>use : Symbol(use, Decl(file1.ts, 0, 34))
|
||||
>x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/src/file2/index.d.ts ===
|
||||
export let x: number;
|
||||
>x : Symbol(x, Decl(index.d.ts, 0, 10))
|
||||
|
||||
=== c:/root/generated/src/project/file3.ts ===
|
||||
export {x} from "../file2";
|
||||
>x : Symbol(x, Decl(file3.ts, 0, 8))
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
[
|
||||
"======== Resolving module './project/file3' from 'c:/root/src/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
"'rootDirs' option is set, using it to resolve relative module name './project/file3'",
|
||||
"Checking if 'c:/root/src/' is the longest matching prefix for 'c:/root/src/project/file3' - 'true'.",
|
||||
"Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/src/project/file3' - 'false'.",
|
||||
"Longest matching prefix for 'c:/root/src/project/file3' is 'c:/root/src/'",
|
||||
"Loading 'project/file3' from the root dir 'c:/root/src/', candidate location 'c:/root/src/project/file3'",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/src/project/file3'.",
|
||||
"File 'c:/root/src/project/file3.ts' does not exist.",
|
||||
"File 'c:/root/src/project/file3.tsx' does not exist.",
|
||||
"File 'c:/root/src/project/file3.d.ts' does not exist.",
|
||||
"File 'c:/root/src/project/file3/package.json' does not exist.",
|
||||
"File 'c:/root/src/project/file3/index.ts' does not exist.",
|
||||
"File 'c:/root/src/project/file3/index.tsx' does not exist.",
|
||||
"File 'c:/root/src/project/file3/index.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'",
|
||||
"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.",
|
||||
"======== 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'.",
|
||||
"'rootDirs' option is set, using it to resolve relative module name '../file2'",
|
||||
"Checking if 'c:/root/src/' is the longest matching prefix for 'c:/root/generated/src/file2' - 'false'.",
|
||||
"Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/generated/src/file2' - 'true'.",
|
||||
"Longest matching prefix for 'c:/root/generated/src/file2' is 'c:/root/generated/src/'",
|
||||
"Loading 'file2' from the root dir 'c:/root/generated/src/', candidate location 'c:/root/generated/src/file2'",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/generated/src/file2'.",
|
||||
"File 'c:/root/generated/src/file2.ts' does not exist.",
|
||||
"File 'c:/root/generated/src/file2.tsx' does not exist.",
|
||||
"File 'c:/root/generated/src/file2.d.ts' does not exist.",
|
||||
"File 'c:/root/generated/src/file2/package.json' does not exist.",
|
||||
"File 'c:/root/generated/src/file2/index.ts' does not exist.",
|
||||
"File 'c:/root/generated/src/file2/index.tsx' does not exist.",
|
||||
"File 'c:/root/generated/src/file2/index.d.ts' does not exist.",
|
||||
"Trying other entries in 'rootDirs'",
|
||||
"Loading 'file2' from the root dir 'c:/root/src', candidate location 'c:/root/src/file2'",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/src/file2'.",
|
||||
"File 'c:/root/src/file2.ts' does not exist.",
|
||||
"File 'c:/root/src/file2.tsx' does not exist.",
|
||||
"File 'c:/root/src/file2.d.ts' does not exist.",
|
||||
"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.",
|
||||
"======== Module name '../file2' was successfully resolved to 'c:/root/src/file2/index.d.ts'. ========"
|
||||
]
|
|
@ -0,0 +1,24 @@
|
|||
=== c:/root/src/file1.ts ===
|
||||
import {x} from "./project/file3";
|
||||
>x : number
|
||||
|
||||
declare function use(x: string);
|
||||
>use : (x: string) => any
|
||||
>x : string
|
||||
|
||||
use(x.toFixed());
|
||||
>use(x.toFixed()) : any
|
||||
>use : (x: string) => any
|
||||
>x.toFixed() : string
|
||||
>x.toFixed : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/src/file2/index.d.ts ===
|
||||
export let x: number;
|
||||
>x : number
|
||||
|
||||
=== c:/root/generated/src/project/file3.ts ===
|
||||
export {x} from "../file2";
|
||||
>x : number
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution7.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file1"
|
||||
import {y} from "folder3/file2"
|
||||
import {z} from "components/file3"
|
||||
|
||||
declare function use(a: any): void;
|
||||
|
||||
use(x.toExponential());
|
||||
use(y.toExponential());
|
||||
use(z.toExponential());
|
||||
|
||||
//// [file1.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file2.ts]
|
||||
export var y = 1;
|
||||
|
||||
//// [file3.ts]
|
||||
export var z = 1;
|
||||
|
||||
//// [file1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.y = 1;
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.z = 1;
|
||||
});
|
||||
//// [file1.js]
|
||||
define(["require", "exports", "folder2/file1", "folder3/file2", "components/file3"], function (require, exports, file1_1, file2_1, file3_1) {
|
||||
"use strict";
|
||||
use(file1_1.x.toExponential());
|
||||
use(file2_1.y.toExponential());
|
||||
use(file3_1.z.toExponential());
|
||||
});
|
|
@ -1,44 +0,0 @@
|
|||
=== tests/cases/compiler/root/folder1/file1.ts ===
|
||||
import {x} from "folder2/file1"
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
import {y} from "folder3/file2"
|
||||
>y : Symbol(y, Decl(file1.ts, 1, 8))
|
||||
|
||||
import {z} from "components/file3"
|
||||
>z : Symbol(z, Decl(file1.ts, 2, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 2, 34))
|
||||
>a : Symbol(a, Decl(file1.ts, 4, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 2, 34))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
use(y.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 2, 34))
|
||||
>y.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(file1.ts, 1, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
use(z.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 2, 34))
|
||||
>z.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>z : Symbol(z, Decl(file1.ts, 2, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== tests/cases/compiler/root/folder2/file1.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 10))
|
||||
|
||||
=== tests/cases/compiler/root/generated/folder3/file2.ts ===
|
||||
export var y = 1;
|
||||
>y : Symbol(y, Decl(file2.ts, 0, 10))
|
||||
|
||||
=== tests/cases/compiler/root/shared/components/file3.ts ===
|
||||
export var z = 1;
|
||||
>z : Symbol(z, Decl(file3.ts, 0, 10))
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
=== tests/cases/compiler/root/folder1/file1.ts ===
|
||||
import {x} from "folder2/file1"
|
||||
>x : number
|
||||
|
||||
import {y} from "folder3/file2"
|
||||
>y : number
|
||||
|
||||
import {z} from "components/file3"
|
||||
>z : number
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : (a: any) => void
|
||||
>a : any
|
||||
|
||||
use(x.toExponential());
|
||||
>use(x.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
use(y.toExponential());
|
||||
>use(y.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>y.toExponential() : string
|
||||
>y.toExponential : (fractionDigits?: number) => string
|
||||
>y : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
use(z.toExponential());
|
||||
>use(z.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>z.toExponential() : string
|
||||
>z.toExponential : (fractionDigits?: number) => string
|
||||
>z : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== tests/cases/compiler/root/folder2/file1.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== tests/cases/compiler/root/generated/folder3/file2.ts ===
|
||||
export var y = 1;
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
=== tests/cases/compiler/root/shared/components/file3.ts ===
|
||||
export var z = 1;
|
||||
>z : number
|
||||
>1 : number
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution7_1.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "folder2/file1"
|
||||
import {y} from "folder3/file2"
|
||||
import {z} from "components/file3"
|
||||
|
||||
declare function use(a: any): void;
|
||||
|
||||
use(x.toExponential());
|
||||
use(y.toExponential());
|
||||
use(z.toExponential());
|
||||
|
||||
//// [file1.ts]
|
||||
export var x = 1;
|
||||
|
||||
//// [file2.ts]
|
||||
export var y = 1;
|
||||
|
||||
//// [file3.ts]
|
||||
export var z = 1;
|
||||
|
||||
//// [file1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.x = 1;
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.y = 1;
|
||||
});
|
||||
//// [file3.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.z = 1;
|
||||
});
|
||||
//// [file1.js]
|
||||
define(["require", "exports", "folder2/file1", "folder3/file2", "components/file3"], function (require, exports, file1_1, file2_1, file3_1) {
|
||||
"use strict";
|
||||
use(file1_1.x.toExponential());
|
||||
use(file2_1.y.toExponential());
|
||||
use(file3_1.z.toExponential());
|
||||
});
|
|
@ -1,44 +0,0 @@
|
|||
=== c:/root/folder1/file1.ts ===
|
||||
import {x} from "folder2/file1"
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
import {y} from "folder3/file2"
|
||||
>y : Symbol(y, Decl(file1.ts, 1, 8))
|
||||
|
||||
import {z} from "components/file3"
|
||||
>z : Symbol(z, Decl(file1.ts, 2, 8))
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : Symbol(use, Decl(file1.ts, 2, 34))
|
||||
>a : Symbol(a, Decl(file1.ts, 4, 21))
|
||||
|
||||
use(x.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 2, 34))
|
||||
>x.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
use(y.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 2, 34))
|
||||
>y.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(file1.ts, 1, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
use(z.toExponential());
|
||||
>use : Symbol(use, Decl(file1.ts, 2, 34))
|
||||
>z.toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
>z : Symbol(z, Decl(file1.ts, 2, 8))
|
||||
>toExponential : Symbol(Number.toExponential, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/folder2/file1.ts ===
|
||||
export var x = 1;
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 10))
|
||||
|
||||
=== c:/root/generated/folder3/file2.ts ===
|
||||
export var y = 1;
|
||||
>y : Symbol(y, Decl(file2.ts, 0, 10))
|
||||
|
||||
=== c:/root/shared/components/file3.ts ===
|
||||
export var z = 1;
|
||||
>z : Symbol(z, Decl(file3.ts, 0, 10))
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
=== c:/root/folder1/file1.ts ===
|
||||
import {x} from "folder2/file1"
|
||||
>x : number
|
||||
|
||||
import {y} from "folder3/file2"
|
||||
>y : number
|
||||
|
||||
import {z} from "components/file3"
|
||||
>z : number
|
||||
|
||||
declare function use(a: any): void;
|
||||
>use : (a: any) => void
|
||||
>a : any
|
||||
|
||||
use(x.toExponential());
|
||||
>use(x.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>x.toExponential() : string
|
||||
>x.toExponential : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
use(y.toExponential());
|
||||
>use(y.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>y.toExponential() : string
|
||||
>y.toExponential : (fractionDigits?: number) => string
|
||||
>y : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
use(z.toExponential());
|
||||
>use(z.toExponential()) : void
|
||||
>use : (a: any) => void
|
||||
>z.toExponential() : string
|
||||
>z.toExponential : (fractionDigits?: number) => string
|
||||
>z : number
|
||||
>toExponential : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/folder2/file1.ts ===
|
||||
export var x = 1;
|
||||
>x : number
|
||||
>1 : number
|
||||
|
||||
=== c:/root/generated/folder3/file2.ts ===
|
||||
export var y = 1;
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
=== c:/root/shared/components/file3.ts ===
|
||||
export var z = 1;
|
||||
>z : number
|
||||
>1 : number
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution7_classic.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "./project/file2";
|
||||
import {y} from "module3";
|
||||
|
||||
declare function use(x: string);
|
||||
use(x.toFixed());
|
||||
use(y.toFixed());
|
||||
|
||||
//// [file2.ts]
|
||||
import {a} from "module1";
|
||||
import {b} from "templates/module2";
|
||||
import {x as c} from "../file3";
|
||||
export let x = a + b + c;
|
||||
|
||||
//// [module1.d.ts]
|
||||
export let a: number
|
||||
|
||||
//// [module2.ts]
|
||||
export let b: number;
|
||||
|
||||
//// [file3.d.ts]
|
||||
export let x: number;
|
||||
|
||||
//// [module3.d.ts]
|
||||
export let y: number;
|
||||
|
||||
|
||||
|
||||
//// [module2.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
});
|
||||
//// [file2.js]
|
||||
define(["require", "exports", "module1", "templates/module2", "../file3"], function (require, exports, module1_1, module2_1, file3_1) {
|
||||
"use strict";
|
||||
exports.x = module1_1.a + module2_1.b + file3_1.x;
|
||||
});
|
||||
//// [file1.js]
|
||||
define(["require", "exports", "./project/file2", "module3"], function (require, exports, file2_1, module3_1) {
|
||||
"use strict";
|
||||
use(file2_1.x.toFixed());
|
||||
use(module3_1.y.toFixed());
|
||||
});
|
|
@ -0,0 +1,57 @@
|
|||
=== c:/root/src/file1.ts ===
|
||||
import {x} from "./project/file2";
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
import {y} from "module3";
|
||||
>y : Symbol(y, Decl(file1.ts, 1, 8))
|
||||
|
||||
declare function use(x: string);
|
||||
>use : Symbol(use, Decl(file1.ts, 1, 26))
|
||||
>x : Symbol(x, Decl(file1.ts, 3, 21))
|
||||
|
||||
use(x.toFixed());
|
||||
>use : Symbol(use, Decl(file1.ts, 1, 26))
|
||||
>x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
|
||||
|
||||
use(y.toFixed());
|
||||
>use : Symbol(use, Decl(file1.ts, 1, 26))
|
||||
>y.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(file1.ts, 1, 8))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/generated/src/project/file2.ts ===
|
||||
import {a} from "module1";
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
|
||||
import {b} from "templates/module2";
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
|
||||
import {x as c} from "../file3";
|
||||
>x : Symbol(c, Decl(file2.ts, 2, 8))
|
||||
>c : Symbol(c, Decl(file2.ts, 2, 8))
|
||||
|
||||
export let x = a + b + c;
|
||||
>x : Symbol(x, Decl(file2.ts, 3, 10))
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
>c : Symbol(c, Decl(file2.ts, 2, 8))
|
||||
|
||||
=== c:/shared/module1.d.ts ===
|
||||
export let a: number
|
||||
>a : Symbol(a, Decl(module1.d.ts, 0, 10))
|
||||
|
||||
=== c:/root/generated/src/templates/module2.ts ===
|
||||
export let b: number;
|
||||
>b : Symbol(b, Decl(module2.ts, 0, 10))
|
||||
|
||||
=== c:/root/src/file3.d.ts ===
|
||||
export let x: number;
|
||||
>x : Symbol(x, Decl(file3.d.ts, 0, 10))
|
||||
|
||||
=== c:/module3.d.ts ===
|
||||
export let y: number;
|
||||
>y : Symbol(y, Decl(module3.d.ts, 0, 10))
|
||||
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
[
|
||||
"======== Resolving module './project/file2' from 'c:/root/src/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Classic'.",
|
||||
"'rootDirs' option is set, using it to resolve relative module name './project/file2'",
|
||||
"Checking if 'c:/root/src/' is the longest matching prefix for 'c:/root/src/project/file2' - 'true'.",
|
||||
"Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/src/project/file2' - 'false'.",
|
||||
"Longest matching prefix for 'c:/root/src/project/file2' is 'c:/root/src/'",
|
||||
"Loading 'project/file2' from the root dir 'c:/root/src/', candidate location 'c:/root/src/project/file2'",
|
||||
"File 'c:/root/src/project/file2.ts' does not exist.",
|
||||
"File 'c:/root/src/project/file2.tsx' does not exist.",
|
||||
"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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'module3'",
|
||||
"'paths' option is specified, looking for a pattern to match module name 'module3'.",
|
||||
"Module name 'module3', matched pattern '*'.",
|
||||
"Trying substitution '*', candidate module location: 'module3'.",
|
||||
"File 'c:/root/module3.ts' does not exist.",
|
||||
"File 'c:/root/module3.tsx' does not exist.",
|
||||
"File 'c:/root/module3.d.ts' does not exist.",
|
||||
"Trying substitution 'c:/shared/*', candidate module location: 'c:/shared/module3'.",
|
||||
"File 'c:/shared/module3.ts' does not exist.",
|
||||
"File 'c:/shared/module3.tsx' does not exist.",
|
||||
"File 'c:/shared/module3.d.ts' does not exist.",
|
||||
"File 'c:/root/src/module3.ts' does not exist.",
|
||||
"File 'c:/root/src/module3.tsx' does not exist.",
|
||||
"File 'c:/root/src/module3.d.ts' does not exist.",
|
||||
"File 'c:/root/module3.ts' does not exist.",
|
||||
"File 'c:/root/module3.tsx' does not exist.",
|
||||
"File 'c:/root/module3.d.ts' does not exist.",
|
||||
"File 'c:/module3.ts' does not exist.",
|
||||
"File 'c:/module3.tsx' does not exist.",
|
||||
"File 'c:/module3.d.ts' exist - use it as a module 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'module1'",
|
||||
"'paths' option is specified, looking for a pattern to match module name 'module1'.",
|
||||
"Module name 'module1', matched pattern '*'.",
|
||||
"Trying substitution '*', candidate module location: 'module1'.",
|
||||
"File 'c:/root/module1.ts' does not exist.",
|
||||
"File 'c:/root/module1.tsx' does not exist.",
|
||||
"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.tsx' does not exist.",
|
||||
"File 'c:/shared/module1.d.ts' exist - use it as a module 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'templates/module2'",
|
||||
"'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.",
|
||||
"======== 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'.",
|
||||
"'rootDirs' option is set, using it to resolve relative module name '../file3'",
|
||||
"Checking if 'c:/root/src/' is the longest matching prefix for 'c:/root/generated/src/file3' - 'false'.",
|
||||
"Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/generated/src/file3' - 'true'.",
|
||||
"Longest matching prefix for 'c:/root/generated/src/file3' is 'c:/root/generated/src/'",
|
||||
"Loading 'file3' from the root dir 'c:/root/generated/src/', candidate location 'c:/root/generated/src/file3'",
|
||||
"File 'c:/root/generated/src/file3.ts' does not exist.",
|
||||
"File 'c:/root/generated/src/file3.tsx' does not exist.",
|
||||
"File 'c:/root/generated/src/file3.d.ts' does not exist.",
|
||||
"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.tsx' does not exist.",
|
||||
"File 'c:/root/src/file3.d.ts' exist - use it as a module resolution result.",
|
||||
"======== Module name '../file3' was successfully resolved to 'c:/root/src/file3.d.ts'. ========"
|
||||
]
|
|
@ -0,0 +1,63 @@
|
|||
=== c:/root/src/file1.ts ===
|
||||
import {x} from "./project/file2";
|
||||
>x : number
|
||||
|
||||
import {y} from "module3";
|
||||
>y : number
|
||||
|
||||
declare function use(x: string);
|
||||
>use : (x: string) => any
|
||||
>x : string
|
||||
|
||||
use(x.toFixed());
|
||||
>use(x.toFixed()) : any
|
||||
>use : (x: string) => any
|
||||
>x.toFixed() : string
|
||||
>x.toFixed : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
|
||||
use(y.toFixed());
|
||||
>use(y.toFixed()) : any
|
||||
>use : (x: string) => any
|
||||
>y.toFixed() : string
|
||||
>y.toFixed : (fractionDigits?: number) => string
|
||||
>y : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/generated/src/project/file2.ts ===
|
||||
import {a} from "module1";
|
||||
>a : number
|
||||
|
||||
import {b} from "templates/module2";
|
||||
>b : number
|
||||
|
||||
import {x as c} from "../file3";
|
||||
>x : number
|
||||
>c : number
|
||||
|
||||
export let x = a + b + c;
|
||||
>x : number
|
||||
>a + b + c : number
|
||||
>a + b : number
|
||||
>a : number
|
||||
>b : number
|
||||
>c : number
|
||||
|
||||
=== c:/shared/module1.d.ts ===
|
||||
export let a: number
|
||||
>a : number
|
||||
|
||||
=== c:/root/generated/src/templates/module2.ts ===
|
||||
export let b: number;
|
||||
>b : number
|
||||
|
||||
=== c:/root/src/file3.d.ts ===
|
||||
export let x: number;
|
||||
>x : number
|
||||
|
||||
=== c:/module3.d.ts ===
|
||||
export let y: number;
|
||||
>y : number
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
//// [tests/cases/compiler/pathMappingBasedModuleResolution7_node.ts] ////
|
||||
|
||||
//// [file1.ts]
|
||||
import {x} from "./project/file2";
|
||||
import {y} from "module3";
|
||||
|
||||
declare function use(x: string);
|
||||
use(x.toFixed());
|
||||
use(y.toFixed());
|
||||
|
||||
//// [file2.ts]
|
||||
import {a} from "module1";
|
||||
import {b} from "templates/module2";
|
||||
import {x as c} from "../file3";
|
||||
export let x = a + b + c;
|
||||
|
||||
//// [index.d.ts]
|
||||
export let a: number
|
||||
|
||||
//// [module2.ts]
|
||||
export let b: number;
|
||||
|
||||
//// [index.d.ts]
|
||||
export let x: number;
|
||||
|
||||
//// [module3.d.ts]
|
||||
export let y: number;
|
||||
|
||||
|
||||
|
||||
//// [module2.js]
|
||||
"use strict";
|
||||
//// [file2.js]
|
||||
"use strict";
|
||||
var module1_1 = require("module1");
|
||||
var module2_1 = require("templates/module2");
|
||||
var file3_1 = require("../file3");
|
||||
exports.x = module1_1.a + module2_1.b + file3_1.x;
|
||||
//// [file1.js]
|
||||
"use strict";
|
||||
var file2_1 = require("./project/file2");
|
||||
var module3_1 = require("module3");
|
||||
use(file2_1.x.toFixed());
|
||||
use(module3_1.y.toFixed());
|
|
@ -0,0 +1,57 @@
|
|||
=== c:/root/src/file1.ts ===
|
||||
import {x} from "./project/file2";
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
|
||||
import {y} from "module3";
|
||||
>y : Symbol(y, Decl(file1.ts, 1, 8))
|
||||
|
||||
declare function use(x: string);
|
||||
>use : Symbol(use, Decl(file1.ts, 1, 26))
|
||||
>x : Symbol(x, Decl(file1.ts, 3, 21))
|
||||
|
||||
use(x.toFixed());
|
||||
>use : Symbol(use, Decl(file1.ts, 1, 26))
|
||||
>x.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
|
||||
>x : Symbol(x, Decl(file1.ts, 0, 8))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
|
||||
|
||||
use(y.toFixed());
|
||||
>use : Symbol(use, Decl(file1.ts, 1, 26))
|
||||
>y.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
|
||||
>y : Symbol(y, Decl(file1.ts, 1, 8))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, --, --))
|
||||
|
||||
=== c:/root/generated/src/project/file2.ts ===
|
||||
import {a} from "module1";
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
|
||||
import {b} from "templates/module2";
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
|
||||
import {x as c} from "../file3";
|
||||
>x : Symbol(c, Decl(file2.ts, 2, 8))
|
||||
>c : Symbol(c, Decl(file2.ts, 2, 8))
|
||||
|
||||
export let x = a + b + c;
|
||||
>x : Symbol(x, Decl(file2.ts, 3, 10))
|
||||
>a : Symbol(a, Decl(file2.ts, 0, 8))
|
||||
>b : Symbol(b, Decl(file2.ts, 1, 8))
|
||||
>c : Symbol(c, Decl(file2.ts, 2, 8))
|
||||
|
||||
=== c:/shared/module1/index.d.ts ===
|
||||
export let a: number
|
||||
>a : Symbol(a, Decl(index.d.ts, 0, 10))
|
||||
|
||||
=== c:/root/generated/src/templates/module2.ts ===
|
||||
export let b: number;
|
||||
>b : Symbol(b, Decl(module2.ts, 0, 10))
|
||||
|
||||
=== c:/root/src/file3/index.d.ts ===
|
||||
export let x: number;
|
||||
>x : Symbol(x, Decl(index.d.ts, 0, 10))
|
||||
|
||||
=== c:/node_modules/module3.d.ts ===
|
||||
export let y: number;
|
||||
>y : Symbol(y, Decl(module3.d.ts, 0, 10))
|
||||
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
[
|
||||
"======== Resolving module './project/file2' from 'c:/root/src/file1.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeJs'.",
|
||||
"'rootDirs' option is set, using it to resolve relative module name './project/file2'",
|
||||
"Checking if 'c:/root/src/' is the longest matching prefix for 'c:/root/src/project/file2' - 'true'.",
|
||||
"Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/src/project/file2' - 'false'.",
|
||||
"Longest matching prefix for 'c:/root/src/project/file2' is 'c:/root/src/'",
|
||||
"Loading 'project/file2' from the root dir 'c:/root/src/', candidate location 'c:/root/src/project/file2'",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/src/project/file2'.",
|
||||
"File 'c:/root/src/project/file2.ts' does not exist.",
|
||||
"File 'c:/root/src/project/file2.tsx' does not exist.",
|
||||
"File 'c:/root/src/project/file2.d.ts' does not exist.",
|
||||
"File 'c:/root/src/project/file2/package.json' does not exist.",
|
||||
"File 'c:/root/src/project/file2/index.ts' does not exist.",
|
||||
"File 'c:/root/src/project/file2/index.tsx' does not exist.",
|
||||
"File 'c:/root/src/project/file2/index.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'",
|
||||
"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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'module3'",
|
||||
"'paths' option is specified, looking for a pattern to match module name 'module3'.",
|
||||
"Module name 'module3', matched pattern '*'.",
|
||||
"Trying substitution '*', candidate module location: 'module3'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/module3'.",
|
||||
"File 'c:/root/module3.ts' does not exist.",
|
||||
"File 'c:/root/module3.tsx' does not exist.",
|
||||
"File 'c:/root/module3.d.ts' does not exist.",
|
||||
"File 'c:/root/module3/package.json' does not exist.",
|
||||
"File 'c:/root/module3/index.ts' does not exist.",
|
||||
"File 'c:/root/module3/index.tsx' does not exist.",
|
||||
"File 'c:/root/module3/index.d.ts' does not exist.",
|
||||
"Trying substitution 'c:/shared/*', candidate module location: 'c:/shared/module3'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/shared/module3'.",
|
||||
"File 'c:/shared/module3.ts' does not exist.",
|
||||
"File 'c:/shared/module3.tsx' does not exist.",
|
||||
"File 'c:/shared/module3.d.ts' does not exist.",
|
||||
"File 'c:/shared/module3/package.json' does not exist.",
|
||||
"File 'c:/shared/module3/index.ts' does not exist.",
|
||||
"File 'c:/shared/module3/index.tsx' does not exist.",
|
||||
"File 'c:/shared/module3/index.d.ts' does not exist.",
|
||||
"Loading module 'module3' from 'node_modules' folder.",
|
||||
"File 'c:/root/src/node_modules/module3.ts' does not exist.",
|
||||
"File 'c:/root/src/node_modules/module3.tsx' does not exist.",
|
||||
"File 'c:/root/src/node_modules/module3.d.ts' does not exist.",
|
||||
"File 'c:/root/src/node_modules/module3/package.json' does not exist.",
|
||||
"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/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.",
|
||||
"File 'c:/root/node_modules/module3/package.json' does not exist.",
|
||||
"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:/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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'module1'",
|
||||
"'paths' option is specified, looking for a pattern to match module name 'module1'.",
|
||||
"Module name 'module1', matched pattern '*'.",
|
||||
"Trying substitution '*', candidate module location: 'module1'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/module1'.",
|
||||
"File 'c:/root/module1.ts' does not exist.",
|
||||
"File 'c:/root/module1.tsx' does not exist.",
|
||||
"File 'c:/root/module1.d.ts' does not exist.",
|
||||
"File 'c:/root/module1/package.json' does not exist.",
|
||||
"File 'c:/root/module1/index.ts' does not exist.",
|
||||
"File 'c:/root/module1/index.tsx' does not exist.",
|
||||
"File 'c:/root/module1/index.d.ts' does not exist.",
|
||||
"Trying substitution 'c:/shared/*', candidate module location: 'c:/shared/module1'.",
|
||||
"Loading module as file / folder, candidate module location 'c:/shared/module1'.",
|
||||
"File 'c:/shared/module1.ts' does not exist.",
|
||||
"File 'c:/shared/module1.tsx' does not exist.",
|
||||
"File 'c:/shared/module1.d.ts' does not exist.",
|
||||
"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.",
|
||||
"======== 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'.",
|
||||
"'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'templates/module2'",
|
||||
"'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'.",
|
||||
"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.",
|
||||
"======== 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'.",
|
||||
"'rootDirs' option is set, using it to resolve relative module name '../file3'",
|
||||
"Checking if 'c:/root/src/' is the longest matching prefix for 'c:/root/generated/src/file3' - 'false'.",
|
||||
"Checking if 'c:/root/generated/src/' is the longest matching prefix for 'c:/root/generated/src/file3' - 'true'.",
|
||||
"Longest matching prefix for 'c:/root/generated/src/file3' is 'c:/root/generated/src/'",
|
||||
"Loading 'file3' from the root dir 'c:/root/generated/src/', candidate location 'c:/root/generated/src/file3'",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/generated/src/file3'.",
|
||||
"File 'c:/root/generated/src/file3.ts' does not exist.",
|
||||
"File 'c:/root/generated/src/file3.tsx' does not exist.",
|
||||
"File 'c:/root/generated/src/file3.d.ts' does not exist.",
|
||||
"File 'c:/root/generated/src/file3/package.json' does not exist.",
|
||||
"File 'c:/root/generated/src/file3/index.ts' does not exist.",
|
||||
"File 'c:/root/generated/src/file3/index.tsx' does not exist.",
|
||||
"File 'c:/root/generated/src/file3/index.d.ts' does not exist.",
|
||||
"Trying other entries in 'rootDirs'",
|
||||
"Loading 'file3' from the root dir 'c:/root/src', candidate location 'c:/root/src/file3'",
|
||||
"Loading module as file / folder, candidate module location 'c:/root/src/file3'.",
|
||||
"File 'c:/root/src/file3.ts' does not exist.",
|
||||
"File 'c:/root/src/file3.tsx' does not exist.",
|
||||
"File 'c:/root/src/file3.d.ts' does not exist.",
|
||||
"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.",
|
||||
"======== Module name '../file3' was successfully resolved to 'c:/root/src/file3/index.d.ts'. ========"
|
||||
]
|
|
@ -0,0 +1,63 @@
|
|||
=== c:/root/src/file1.ts ===
|
||||
import {x} from "./project/file2";
|
||||
>x : number
|
||||
|
||||
import {y} from "module3";
|
||||
>y : number
|
||||
|
||||
declare function use(x: string);
|
||||
>use : (x: string) => any
|
||||
>x : string
|
||||
|
||||
use(x.toFixed());
|
||||
>use(x.toFixed()) : any
|
||||
>use : (x: string) => any
|
||||
>x.toFixed() : string
|
||||
>x.toFixed : (fractionDigits?: number) => string
|
||||
>x : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
|
||||
use(y.toFixed());
|
||||
>use(y.toFixed()) : any
|
||||
>use : (x: string) => any
|
||||
>y.toFixed() : string
|
||||
>y.toFixed : (fractionDigits?: number) => string
|
||||
>y : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
|
||||
=== c:/root/generated/src/project/file2.ts ===
|
||||
import {a} from "module1";
|
||||
>a : number
|
||||
|
||||
import {b} from "templates/module2";
|
||||
>b : number
|
||||
|
||||
import {x as c} from "../file3";
|
||||
>x : number
|
||||
>c : number
|
||||
|
||||
export let x = a + b + c;
|
||||
>x : number
|
||||
>a + b + c : number
|
||||
>a + b : number
|
||||
>a : number
|
||||
>b : number
|
||||
>c : number
|
||||
|
||||
=== c:/shared/module1/index.d.ts ===
|
||||
export let a: number
|
||||
>a : number
|
||||
|
||||
=== c:/root/generated/src/templates/module2.ts ===
|
||||
export let b: number;
|
||||
>b : number
|
||||
|
||||
=== c:/root/src/file3/index.d.ts ===
|
||||
export let x: number;
|
||||
>x : number
|
||||
|
||||
=== c:/node_modules/module3.d.ts ===
|
||||
export let y: number;
|
||||
>y : number
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue