From dde8411b0ed2d8c1df39a578de202372f13cdd8f Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 22 Dec 2016 16:17:55 -0800 Subject: [PATCH] Update LKG --- lib/tsc.js | 24 +++++++++++++----------- lib/tsserver.js | 24 +++++++++++++----------- lib/tsserverlibrary.js | 24 +++++++++++++----------- lib/typescript.js | 27 ++++++++++++++++----------- lib/typescriptServices.js | 27 ++++++++++++++++----------- lib/typingsInstaller.js | 24 +++++++++++++----------- 6 files changed, 84 insertions(+), 66 deletions(-) diff --git a/lib/tsc.js b/lib/tsc.js index c95e7675eb0..b5ed3a82f47 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -18964,13 +18964,7 @@ var ts; case 0: return tryReadFromField("typings") || tryReadFromField("types"); case 1: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; + return tryReadFromField("main"); } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { @@ -19488,12 +19482,20 @@ var ts; if (resolved_3) { return resolved_3; } - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } var resolved = tryAddingExtensions(mainOrTypesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); if (resolved) { return resolved; } + if (extensions === 1) { + var resolved_4 = tryAddingExtensions(mainOrTypesFile, 1, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved_4) { + return resolved_4; + } + } } else { if (state.traceEnabled) { @@ -19584,7 +19586,7 @@ var ts; } var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_5 = forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); if (resolutionFromCache) { return resolutionFromCache; @@ -19592,8 +19594,8 @@ var ts; var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_4) { - return resolved_4; + if (resolved_5) { + return resolved_5; } if (extensions === 0) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); diff --git a/lib/tsserver.js b/lib/tsserver.js index 279a01d0c19..b88f04482a6 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -6323,13 +6323,7 @@ var ts; case 0: return tryReadFromField("typings") || tryReadFromField("types"); case 1: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; + return tryReadFromField("main"); } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { @@ -6847,12 +6841,20 @@ var ts; if (resolved_3) { return resolved_3; } - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } var resolved = tryAddingExtensions(mainOrTypesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); if (resolved) { return resolved; } + if (extensions === 1) { + var resolved_4 = tryAddingExtensions(mainOrTypesFile, 1, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved_4) { + return resolved_4; + } + } } else { if (state.traceEnabled) { @@ -6943,7 +6945,7 @@ var ts; } var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_5 = forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); if (resolutionFromCache) { return resolutionFromCache; @@ -6951,8 +6953,8 @@ var ts; var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_4) { - return resolved_4; + if (resolved_5) { + return resolved_5; } if (extensions === 0) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 0b7f12915a4..8f8e918220c 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -6323,13 +6323,7 @@ var ts; case 0: return tryReadFromField("typings") || tryReadFromField("types"); case 1: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; + return tryReadFromField("main"); } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { @@ -6847,12 +6841,20 @@ var ts; if (resolved_3) { return resolved_3; } - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } var resolved = tryAddingExtensions(mainOrTypesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); if (resolved) { return resolved; } + if (extensions === 1) { + var resolved_4 = tryAddingExtensions(mainOrTypesFile, 1, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved_4) { + return resolved_4; + } + } } else { if (state.traceEnabled) { @@ -6943,7 +6945,7 @@ var ts; } var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_5 = forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); if (resolutionFromCache) { return resolutionFromCache; @@ -6951,8 +6953,8 @@ var ts; var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_4) { - return resolved_4; + if (resolved_5) { + return resolved_5; } if (extensions === 0) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state); diff --git a/lib/typescript.js b/lib/typescript.js index a79cee7f14d..0c690f2b913 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -23428,13 +23428,7 @@ var ts; case 0 /* TypeScript */: return tryReadFromField("typings") || tryReadFromField("types"); case 1 /* JavaScript */: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; + return tryReadFromField("main"); } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { @@ -24077,12 +24071,23 @@ var ts; if (resolved_3) { return resolved_3; } - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } var resolved = tryAddingExtensions(mainOrTypesFile, 0 /* TypeScript */, failedLookupLocations, onlyRecordFailures_1, state); if (resolved) { return resolved; } + if (extensions === 1 /* JavaScript */) { + // A package.json "main" may specify an exact filename, or may choose to omit an extension. + // We tried the ts extensions erlier, now try the js extensions. + // tryReadPackageJsonMainOrTypes returns main iff extensions is Extensions.JavaScript. + var resolved_4 = tryAddingExtensions(mainOrTypesFile, 1 /* JavaScript */, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved_4) { + return resolved_4; + } + } } else { if (state.traceEnabled) { @@ -24179,7 +24184,7 @@ var ts; var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { // Climb up parent directories looking for a module. - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_5 = forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); if (resolutionFromCache) { return resolutionFromCache; @@ -24187,8 +24192,8 @@ var ts; var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); - if (resolved_4) { - return resolved_4; + if (resolved_5) { + return resolved_5; } if (extensions === 0 /* TypeScript */) { // If we didn't find the file normally, look it up in @types. diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index a79cee7f14d..0c690f2b913 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -23428,13 +23428,7 @@ var ts; case 0 /* TypeScript */: return tryReadFromField("typings") || tryReadFromField("types"); case 1 /* JavaScript */: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; + return tryReadFromField("main"); } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { @@ -24077,12 +24071,23 @@ var ts; if (resolved_3) { return resolved_3; } - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } var resolved = tryAddingExtensions(mainOrTypesFile, 0 /* TypeScript */, failedLookupLocations, onlyRecordFailures_1, state); if (resolved) { return resolved; } + if (extensions === 1 /* JavaScript */) { + // A package.json "main" may specify an exact filename, or may choose to omit an extension. + // We tried the ts extensions erlier, now try the js extensions. + // tryReadPackageJsonMainOrTypes returns main iff extensions is Extensions.JavaScript. + var resolved_4 = tryAddingExtensions(mainOrTypesFile, 1 /* JavaScript */, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved_4) { + return resolved_4; + } + } } else { if (state.traceEnabled) { @@ -24179,7 +24184,7 @@ var ts; var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { // Climb up parent directories looking for a module. - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_5 = forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); if (resolutionFromCache) { return resolutionFromCache; @@ -24187,8 +24192,8 @@ var ts; var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, /*onlyRecordFailures*/ false, state)); }); - if (resolved_4) { - return resolved_4; + if (resolved_5) { + return resolved_5; } if (extensions === 0 /* TypeScript */) { // If we didn't find the file normally, look it up in @types. diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 5a6d364ec0e..f8e9b9a8c72 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -6130,13 +6130,7 @@ var ts; case 0: return tryReadFromField("typings") || tryReadFromField("types"); case 1: - if (typeof jsonContent.main === "string") { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.No_types_specified_in_package_json_so_returning_main_value_of_0, jsonContent.main); - } - return ts.normalizePath(ts.combinePaths(baseDirectory, jsonContent.main)); - } - return undefined; + return tryReadFromField("main"); } function tryReadFromField(fieldName) { if (ts.hasProperty(jsonContent, fieldName)) { @@ -6654,12 +6648,20 @@ var ts; if (resolved_3) { return resolved_3; } - trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromExactFile); + } } var resolved = tryAddingExtensions(mainOrTypesFile, 0, failedLookupLocations, onlyRecordFailures_1, state); if (resolved) { return resolved; } + if (extensions === 1) { + var resolved_4 = tryAddingExtensions(mainOrTypesFile, 1, failedLookupLocations, onlyRecordFailures_1, state); + if (resolved_4) { + return resolved_4; + } + } } else { if (state.traceEnabled) { @@ -6750,7 +6752,7 @@ var ts; } var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName); if (moduleHasNonRelativeName(moduleName)) { - var resolved_4 = forEachAncestorDirectory(containingDirectory, function (directory) { + var resolved_5 = forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, directory, traceEnabled, host); if (resolutionFromCache) { return resolutionFromCache; @@ -6758,8 +6760,8 @@ var ts; var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName)); return toSearchResult(loadModuleFromFile(extensions, searchName, failedLookupLocations, false, state)); }); - if (resolved_4) { - return resolved_4; + if (resolved_5) { + return resolved_5; } if (extensions === 0) { return loadModuleFromNodeModulesAtTypes(moduleName, containingDirectory, failedLookupLocations, state);