typescript 4.8.0-dev.20220801 → 4.8.0-dev.20220802
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +250 -131
- package/lib/tsserver.js +311 -179
- package/lib/tsserverlibrary.d.ts +16 -10
- package/lib/tsserverlibrary.js +311 -179
- package/lib/typescript.d.ts +16 -10
- package/lib/typescript.js +306 -174
- package/lib/typescriptServices.d.ts +16 -10
- package/lib/typescriptServices.js +306 -174
- package/lib/typingsInstaller.js +265 -141
- package/package.json +1 -1
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220802";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8756,6 +8756,10 @@ var ts;
|
|
|
8756
8756
|
resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."),
|
|
8757
8757
|
Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."),
|
|
8758
8758
|
Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"),
|
|
8759
|
+
File_is_ECMAScript_module_because_0_has_field_type_with_value_module: diag(1458, ts.DiagnosticCategory.Message, "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458", "File is ECMAScript module because '{0}' has field \"type\" with value \"module\""),
|
|
8760
|
+
File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module: diag(1459, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459", "File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\""),
|
|
8761
|
+
File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""),
|
|
8762
|
+
File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"),
|
|
8759
8763
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8760
8764
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8761
8765
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
@@ -43433,7 +43437,7 @@ var ts;
|
|
|
43433
43437
|
ts.createCacheWithRedirects = createCacheWithRedirects;
|
|
43434
43438
|
function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
|
|
43435
43439
|
var cache;
|
|
43436
|
-
return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries };
|
|
43440
|
+
return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap };
|
|
43437
43441
|
function getPackageJsonInfo(packageJsonPath) {
|
|
43438
43442
|
return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName));
|
|
43439
43443
|
}
|
|
@@ -43447,6 +43451,9 @@ var ts;
|
|
|
43447
43451
|
var iter = cache === null || cache === void 0 ? void 0 : cache.entries();
|
|
43448
43452
|
return iter ? ts.arrayFrom(iter) : [];
|
|
43449
43453
|
}
|
|
43454
|
+
function getInternalMap() {
|
|
43455
|
+
return cache;
|
|
43456
|
+
}
|
|
43450
43457
|
}
|
|
43451
43458
|
function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
|
|
43452
43459
|
var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
|
|
@@ -43550,15 +43557,18 @@ var ts;
|
|
|
43550
43557
|
}
|
|
43551
43558
|
ts.zipToModeAwareCache = zipToModeAwareCache;
|
|
43552
43559
|
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
|
|
43553
|
-
var
|
|
43560
|
+
var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
43554
43561
|
moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
|
|
43555
43562
|
var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
|
43556
|
-
return __assign(__assign(__assign({}, packageJsonInfoCache),
|
|
43563
|
+
return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
|
|
43557
43564
|
function clear() {
|
|
43558
|
-
|
|
43559
|
-
moduleNameToDirectoryMap.clear();
|
|
43565
|
+
clearAllExceptPackageJsonInfoCache();
|
|
43560
43566
|
packageJsonInfoCache.clear();
|
|
43561
43567
|
}
|
|
43568
|
+
function clearAllExceptPackageJsonInfoCache() {
|
|
43569
|
+
perDirectoryResolutionCache.clear();
|
|
43570
|
+
moduleNameToDirectoryMap.clear();
|
|
43571
|
+
}
|
|
43562
43572
|
function update(options) {
|
|
43563
43573
|
updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
|
|
43564
43574
|
}
|
|
@@ -43634,13 +43644,16 @@ var ts;
|
|
|
43634
43644
|
}
|
|
43635
43645
|
ts.createModuleResolutionCache = createModuleResolutionCache;
|
|
43636
43646
|
function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) {
|
|
43637
|
-
var
|
|
43647
|
+
var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
43638
43648
|
packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
|
|
43639
|
-
return __assign(__assign(__assign({}, packageJsonInfoCache),
|
|
43649
|
+
return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache });
|
|
43640
43650
|
function clear() {
|
|
43641
|
-
|
|
43651
|
+
clearAllExceptPackageJsonInfoCache();
|
|
43642
43652
|
packageJsonInfoCache.clear();
|
|
43643
43653
|
}
|
|
43654
|
+
function clearAllExceptPackageJsonInfoCache() {
|
|
43655
|
+
perDirectoryResolutionCache.clear();
|
|
43656
|
+
}
|
|
43644
43657
|
}
|
|
43645
43658
|
ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
|
|
43646
43659
|
function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
|
|
@@ -51428,10 +51441,6 @@ var ts;
|
|
|
51428
51441
|
checkExpressionCached(expression);
|
|
51429
51442
|
return getNodeLinks(expression).resolvedSymbol;
|
|
51430
51443
|
}
|
|
51431
|
-
function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
|
|
51432
|
-
var expression = node.initializer;
|
|
51433
|
-
return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
|
|
51434
|
-
}
|
|
51435
51444
|
function getTargetOfAccessExpression(node, dontRecursivelyResolve) {
|
|
51436
51445
|
if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) {
|
|
51437
51446
|
return undefined;
|
|
@@ -51463,7 +51472,7 @@ var ts;
|
|
|
51463
51472
|
case 297 /* ShorthandPropertyAssignment */:
|
|
51464
51473
|
return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve);
|
|
51465
51474
|
case 296 /* PropertyAssignment */:
|
|
51466
|
-
return
|
|
51475
|
+
return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve);
|
|
51467
51476
|
case 207 /* ElementAccessExpression */:
|
|
51468
51477
|
case 206 /* PropertyAccessExpression */:
|
|
51469
51478
|
return getTargetOfAccessExpression(node, dontRecursivelyResolve);
|
|
@@ -56988,7 +56997,7 @@ var ts;
|
|
|
56988
56997
|
(resolvedSymbol || symbol).exports.forEach(function (s, name) {
|
|
56989
56998
|
var _a;
|
|
56990
56999
|
var exportedMember = members_4.get(name);
|
|
56991
|
-
if (exportedMember && exportedMember !== s) {
|
|
57000
|
+
if (exportedMember && exportedMember !== s && !(s.flags & 2097152 /* Alias */)) {
|
|
56992
57001
|
if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) {
|
|
56993
57002
|
// If the member has an additional value-like declaration, union the types from the two declarations,
|
|
56994
57003
|
// but issue an error if they occurred in two different files. The purpose is to support a JS file with
|
|
@@ -63480,6 +63489,7 @@ var ts;
|
|
|
63480
63489
|
}
|
|
63481
63490
|
}
|
|
63482
63491
|
function getTypeFromImportTypeNode(node) {
|
|
63492
|
+
var _a;
|
|
63483
63493
|
var links = getNodeLinks(node);
|
|
63484
63494
|
if (!links.resolvedType) {
|
|
63485
63495
|
if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments
|
|
@@ -63499,6 +63509,7 @@ var ts;
|
|
|
63499
63509
|
links.resolvedSymbol = unknownSymbol;
|
|
63500
63510
|
return links.resolvedType = errorType;
|
|
63501
63511
|
}
|
|
63512
|
+
var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */));
|
|
63502
63513
|
var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false);
|
|
63503
63514
|
if (!ts.nodeIsMissing(node.qualifier)) {
|
|
63504
63515
|
var nameStack = getIdentifierChain(node.qualifier);
|
|
@@ -63510,9 +63521,11 @@ var ts;
|
|
|
63510
63521
|
// That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from
|
|
63511
63522
|
// the `exports` lookup process that only looks up namespace members which is used for most type references
|
|
63512
63523
|
var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace));
|
|
63513
|
-
var
|
|
63524
|
+
var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals
|
|
63514
63525
|
? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true)
|
|
63515
|
-
:
|
|
63526
|
+
: undefined;
|
|
63527
|
+
var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning);
|
|
63528
|
+
var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable;
|
|
63516
63529
|
if (!next) {
|
|
63517
63530
|
error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
|
|
63518
63531
|
return links.resolvedType = errorType;
|
|
@@ -82302,9 +82315,11 @@ var ts;
|
|
|
82302
82315
|
// We only need `Awaited<T>` if `T` contains possibly non-primitive types.
|
|
82303
82316
|
if (isGenericObjectType(type)) {
|
|
82304
82317
|
var baseConstraint = getBaseConstraintOfType(type);
|
|
82305
|
-
// We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
|
|
82318
|
+
// We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
|
|
82306
82319
|
// or is promise-like.
|
|
82307
|
-
if (
|
|
82320
|
+
if (baseConstraint ?
|
|
82321
|
+
baseConstraint.flags & 3 /* AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) :
|
|
82322
|
+
maybeTypeOfKind(type, 8650752 /* TypeVariable */)) {
|
|
82308
82323
|
return true;
|
|
82309
82324
|
}
|
|
82310
82325
|
}
|
|
@@ -95076,10 +95091,11 @@ var ts;
|
|
|
95076
95091
|
}
|
|
95077
95092
|
function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) {
|
|
95078
95093
|
if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) {
|
|
95079
|
-
|
|
95094
|
+
var operand = ts.skipParentheses(node.operand);
|
|
95095
|
+
if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) {
|
|
95080
95096
|
var info = void 0;
|
|
95081
|
-
if (info = accessPrivateIdentifier(
|
|
95082
|
-
var receiver = ts.visitNode(
|
|
95097
|
+
if (info = accessPrivateIdentifier(operand.name)) {
|
|
95098
|
+
var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression);
|
|
95083
95099
|
var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
|
|
95084
95100
|
var expression = createPrivateIdentifierAccess(info, readExpression);
|
|
95085
95101
|
var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
|
|
@@ -95095,7 +95111,7 @@ var ts;
|
|
|
95095
95111
|
}
|
|
95096
95112
|
}
|
|
95097
95113
|
else if (shouldTransformSuperInStaticInitializers &&
|
|
95098
|
-
ts.isSuperProperty(
|
|
95114
|
+
ts.isSuperProperty(operand) &&
|
|
95099
95115
|
currentStaticPropertyDeclarationOrStaticBlock &&
|
|
95100
95116
|
currentClassLexicalEnvironment) {
|
|
95101
95117
|
// converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)`
|
|
@@ -95108,31 +95124,31 @@ var ts;
|
|
|
95108
95124
|
// converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)`
|
|
95109
95125
|
var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts;
|
|
95110
95126
|
if (facts & 1 /* ClassWasDecorated */) {
|
|
95111
|
-
var
|
|
95127
|
+
var expression = visitInvalidSuperProperty(operand);
|
|
95112
95128
|
return ts.isPrefixUnaryExpression(node) ?
|
|
95113
|
-
factory.updatePrefixUnaryExpression(node,
|
|
95114
|
-
factory.updatePostfixUnaryExpression(node,
|
|
95129
|
+
factory.updatePrefixUnaryExpression(node, expression) :
|
|
95130
|
+
factory.updatePostfixUnaryExpression(node, expression);
|
|
95115
95131
|
}
|
|
95116
95132
|
if (classConstructor && superClassReference) {
|
|
95117
95133
|
var setterName = void 0;
|
|
95118
95134
|
var getterName = void 0;
|
|
95119
|
-
if (ts.isPropertyAccessExpression(
|
|
95120
|
-
if (ts.isIdentifier(
|
|
95121
|
-
getterName = setterName = factory.createStringLiteralFromNode(
|
|
95135
|
+
if (ts.isPropertyAccessExpression(operand)) {
|
|
95136
|
+
if (ts.isIdentifier(operand.name)) {
|
|
95137
|
+
getterName = setterName = factory.createStringLiteralFromNode(operand.name);
|
|
95122
95138
|
}
|
|
95123
95139
|
}
|
|
95124
95140
|
else {
|
|
95125
|
-
if (ts.isSimpleInlineableExpression(
|
|
95126
|
-
getterName = setterName =
|
|
95141
|
+
if (ts.isSimpleInlineableExpression(operand.argumentExpression)) {
|
|
95142
|
+
getterName = setterName = operand.argumentExpression;
|
|
95127
95143
|
}
|
|
95128
95144
|
else {
|
|
95129
95145
|
getterName = factory.createTempVariable(hoistVariableDeclaration);
|
|
95130
|
-
setterName = factory.createAssignment(getterName, ts.visitNode(
|
|
95146
|
+
setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression));
|
|
95131
95147
|
}
|
|
95132
95148
|
}
|
|
95133
95149
|
if (setterName && getterName) {
|
|
95134
95150
|
var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor);
|
|
95135
|
-
ts.setTextRange(expression,
|
|
95151
|
+
ts.setTextRange(expression, operand);
|
|
95136
95152
|
var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
|
|
95137
95153
|
expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp);
|
|
95138
95154
|
expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor);
|
|
@@ -117887,6 +117903,12 @@ var ts;
|
|
|
117887
117903
|
* @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
|
|
117888
117904
|
*/
|
|
117889
117905
|
function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
|
|
117906
|
+
var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options);
|
|
117907
|
+
return typeof result === "object" ? result.impliedNodeFormat : result;
|
|
117908
|
+
}
|
|
117909
|
+
ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
|
|
117910
|
+
/*@internal*/
|
|
117911
|
+
function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) {
|
|
117890
117912
|
switch (ts.getEmitModuleResolutionKind(options)) {
|
|
117891
117913
|
case ts.ModuleResolutionKind.Node16:
|
|
117892
117914
|
case ts.ModuleResolutionKind.NodeNext:
|
|
@@ -117898,11 +117920,16 @@ var ts;
|
|
|
117898
117920
|
return undefined;
|
|
117899
117921
|
}
|
|
117900
117922
|
function lookupFromPackageJson() {
|
|
117901
|
-
var
|
|
117902
|
-
|
|
117923
|
+
var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
|
117924
|
+
var packageJsonLocations = [];
|
|
117925
|
+
state.failedLookupLocations = packageJsonLocations;
|
|
117926
|
+
state.affectingLocations = packageJsonLocations;
|
|
117927
|
+
var packageJsonScope = ts.getPackageScopeForPath(fileName, state);
|
|
117928
|
+
var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
117929
|
+
return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope };
|
|
117903
117930
|
}
|
|
117904
117931
|
}
|
|
117905
|
-
ts.
|
|
117932
|
+
ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker;
|
|
117906
117933
|
/** @internal */
|
|
117907
117934
|
ts.plainJSErrors = new ts.Set([
|
|
117908
117935
|
// binder errors
|
|
@@ -118227,7 +118254,7 @@ var ts;
|
|
|
118227
118254
|
for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) {
|
|
118228
118255
|
var oldSourceFile = oldSourceFiles_1[_i];
|
|
118229
118256
|
var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
|
|
118230
|
-
if (shouldCreateNewSourceFile || !newFile ||
|
|
118257
|
+
if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
|
|
118231
118258
|
// old file wasn't redirect but new file is
|
|
118232
118259
|
(oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
|
|
118233
118260
|
host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
|
|
@@ -118620,7 +118647,7 @@ var ts;
|
|
|
118620
118647
|
});
|
|
118621
118648
|
}
|
|
118622
118649
|
function tryReuseStructureFromOldProgram() {
|
|
118623
|
-
var _a;
|
|
118650
|
+
var _a, _b;
|
|
118624
118651
|
if (!oldProgram) {
|
|
118625
118652
|
return 0 /* Not */;
|
|
118626
118653
|
}
|
|
@@ -118661,12 +118688,15 @@ var ts;
|
|
|
118661
118688
|
var seenPackageNames = new ts.Map();
|
|
118662
118689
|
for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
|
|
118663
118690
|
var oldSourceFile = oldSourceFiles_2[_i];
|
|
118691
|
+
var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options);
|
|
118664
118692
|
var newSourceFile = host.getSourceFileByPath
|
|
118665
|
-
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath,
|
|
118666
|
-
: host.getSourceFile(oldSourceFile.fileName,
|
|
118693
|
+
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat)
|
|
118694
|
+
: host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217
|
|
118667
118695
|
if (!newSourceFile) {
|
|
118668
118696
|
return 0 /* Not */;
|
|
118669
118697
|
}
|
|
118698
|
+
newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
118699
|
+
newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
118670
118700
|
ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
|
|
118671
118701
|
var fileChanged = void 0;
|
|
118672
118702
|
if (oldSourceFile.redirectInfo) {
|
|
@@ -118706,38 +118736,43 @@ var ts;
|
|
|
118706
118736
|
seenPackageNames.set(packageName, newKind);
|
|
118707
118737
|
}
|
|
118708
118738
|
if (fileChanged) {
|
|
118739
|
+
if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) {
|
|
118740
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118741
|
+
}
|
|
118709
118742
|
// The `newSourceFile` object was created for the new program.
|
|
118710
|
-
if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118743
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118711
118744
|
// 'lib' references has changed. Matches behavior in changesAffectModuleResolution
|
|
118712
118745
|
structureIsReused = 1 /* SafeModules */;
|
|
118713
118746
|
}
|
|
118714
|
-
if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
|
118747
|
+
else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
|
|
118715
118748
|
// value of no-default-lib has changed
|
|
118716
118749
|
// this will affect if default library is injected into the list of files
|
|
118717
118750
|
structureIsReused = 1 /* SafeModules */;
|
|
118718
118751
|
}
|
|
118719
118752
|
// check tripleslash references
|
|
118720
|
-
if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
|
118753
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
|
|
118721
118754
|
// tripleslash references has changed
|
|
118722
118755
|
structureIsReused = 1 /* SafeModules */;
|
|
118723
118756
|
}
|
|
118724
|
-
|
|
118725
|
-
|
|
118726
|
-
|
|
118727
|
-
|
|
118728
|
-
|
|
118729
|
-
|
|
118730
|
-
|
|
118731
|
-
|
|
118732
|
-
|
|
118733
|
-
|
|
118734
|
-
|
|
118735
|
-
|
|
118736
|
-
|
|
118737
|
-
|
|
118738
|
-
|
|
118739
|
-
|
|
118740
|
-
|
|
118757
|
+
else {
|
|
118758
|
+
// check imports and module augmentations
|
|
118759
|
+
collectExternalModuleReferences(newSourceFile);
|
|
118760
|
+
if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
|
|
118761
|
+
// imports has changed
|
|
118762
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118763
|
+
}
|
|
118764
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
|
|
118765
|
+
// moduleAugmentations has changed
|
|
118766
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118767
|
+
}
|
|
118768
|
+
else if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
|
|
118769
|
+
// dynamicImport has changed
|
|
118770
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118771
|
+
}
|
|
118772
|
+
else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
|
|
118773
|
+
// 'types' references has changed
|
|
118774
|
+
structureIsReused = 1 /* SafeModules */;
|
|
118775
|
+
}
|
|
118741
118776
|
}
|
|
118742
118777
|
// tentatively approve the file
|
|
118743
118778
|
modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
|
|
@@ -118755,18 +118790,18 @@ var ts;
|
|
|
118755
118790
|
return structureIsReused;
|
|
118756
118791
|
}
|
|
118757
118792
|
var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
|
|
118758
|
-
for (var
|
|
118759
|
-
var oldFile = oldSourceFiles_3[
|
|
118793
|
+
for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) {
|
|
118794
|
+
var oldFile = oldSourceFiles_3[_c];
|
|
118760
118795
|
if (!ts.contains(modifiedFiles, oldFile)) {
|
|
118761
|
-
for (var
|
|
118762
|
-
var moduleName = _d
|
|
118796
|
+
for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) {
|
|
118797
|
+
var moduleName = _e[_d];
|
|
118763
118798
|
ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
|
|
118764
118799
|
}
|
|
118765
118800
|
}
|
|
118766
118801
|
}
|
|
118767
118802
|
// try to verify results of module resolution
|
|
118768
|
-
for (var
|
|
118769
|
-
var
|
|
118803
|
+
for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) {
|
|
118804
|
+
var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile;
|
|
118770
118805
|
var moduleNames = getModuleNames(newSourceFile);
|
|
118771
118806
|
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
|
118772
118807
|
// ensure that module resolution results are still correct
|
|
@@ -118793,14 +118828,14 @@ var ts;
|
|
|
118793
118828
|
if (structureIsReused !== 2 /* Completely */) {
|
|
118794
118829
|
return structureIsReused;
|
|
118795
118830
|
}
|
|
118796
|
-
if (ts.changesAffectingProgramStructure(oldOptions, options) || ((
|
|
118831
|
+
if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) {
|
|
118797
118832
|
return 1 /* SafeModules */;
|
|
118798
118833
|
}
|
|
118799
118834
|
missingFilePaths = oldProgram.getMissingFilePaths();
|
|
118800
118835
|
// update fileName -> file mapping
|
|
118801
118836
|
ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
|
|
118802
|
-
for (var
|
|
118803
|
-
var newSourceFile = newSourceFiles_1[
|
|
118837
|
+
for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) {
|
|
118838
|
+
var newSourceFile = newSourceFiles_1[_h];
|
|
118804
118839
|
filesByName.set(newSourceFile.path, newSourceFile);
|
|
118805
118840
|
}
|
|
118806
118841
|
var oldFilesByNameMap = oldProgram.getFilesByNameMap();
|
|
@@ -119583,13 +119618,16 @@ var ts;
|
|
|
119583
119618
|
addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]);
|
|
119584
119619
|
}
|
|
119585
119620
|
}
|
|
119586
|
-
function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
|
|
119621
|
+
function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) {
|
|
119622
|
+
var _a;
|
|
119587
119623
|
var redirect = Object.create(redirectTarget);
|
|
119588
119624
|
redirect.fileName = fileName;
|
|
119589
119625
|
redirect.path = path;
|
|
119590
119626
|
redirect.resolvedPath = resolvedPath;
|
|
119591
119627
|
redirect.originalFileName = originalFileName;
|
|
119592
119628
|
redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
|
|
119629
|
+
redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
119630
|
+
redirect.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
119593
119631
|
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
|
|
119594
119632
|
Object.defineProperties(redirect, {
|
|
119595
119633
|
id: {
|
|
@@ -119618,14 +119656,14 @@ var ts;
|
|
|
119618
119656
|
// It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
|
|
119619
119657
|
// and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
|
|
119620
119658
|
// to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
|
|
119621
|
-
var
|
|
119622
|
-
|
|
119623
|
-
|
|
119624
|
-
|
|
119625
|
-
setExternalModuleIndicator:
|
|
119626
|
-
};
|
|
119659
|
+
var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
|
|
119660
|
+
var languageVersion = ts.getEmitScriptTarget(options);
|
|
119661
|
+
var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options);
|
|
119662
|
+
return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) :
|
|
119663
|
+
{ languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator };
|
|
119627
119664
|
}
|
|
119628
119665
|
function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
|
|
119666
|
+
var _a, _b;
|
|
119629
119667
|
var path = toPath(fileName);
|
|
119630
119668
|
if (useSourceOfProjectReferenceRedirect) {
|
|
119631
119669
|
var source = getSourceOfProjectReferenceRedirect(path);
|
|
@@ -119712,14 +119750,15 @@ var ts;
|
|
|
119712
119750
|
}
|
|
119713
119751
|
}
|
|
119714
119752
|
// We haven't looked for this file, do so now and cache result
|
|
119715
|
-
var
|
|
119753
|
+
var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
|
|
119754
|
+
var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat));
|
|
119716
119755
|
if (packageId) {
|
|
119717
119756
|
var packageIdKey = ts.packageIdToString(packageId);
|
|
119718
119757
|
var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
|
|
119719
119758
|
if (fileFromPackageId) {
|
|
119720
119759
|
// Some other SourceFile already exists with this package name and version.
|
|
119721
119760
|
// Instead of creating a duplicate, just redirect to the existing one.
|
|
119722
|
-
var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName);
|
|
119761
|
+
var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions);
|
|
119723
119762
|
redirectTargetsMap.add(fileFromPackageId.path, fileName);
|
|
119724
119763
|
addFileToFilesByName(dupFile, path, redirectedPath);
|
|
119725
119764
|
addFileIncludeReason(dupFile, reason);
|
|
@@ -119740,6 +119779,8 @@ var ts;
|
|
|
119740
119779
|
file.path = path;
|
|
119741
119780
|
file.resolvedPath = toPath(fileName);
|
|
119742
119781
|
file.originalFileName = originalFileName;
|
|
119782
|
+
file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined;
|
|
119783
|
+
file.packageJsonScope = sourceFileOptions.packageJsonScope;
|
|
119743
119784
|
addFileIncludeReason(file, reason);
|
|
119744
119785
|
if (host.useCaseSensitiveFileNames()) {
|
|
119745
119786
|
var pathLowerCase = ts.toFileNameLowerCase(path);
|
|
@@ -120370,7 +120411,7 @@ var ts;
|
|
|
120370
120411
|
fileIncludeReasons = undefined;
|
|
120371
120412
|
var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason);
|
|
120372
120413
|
var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon);
|
|
120373
|
-
var redirectInfo = file && ts.
|
|
120414
|
+
var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file);
|
|
120374
120415
|
var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false));
|
|
120375
120416
|
return location && isReferenceFileLocation(location) ?
|
|
120376
120417
|
ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) :
|
|
@@ -122675,7 +122716,7 @@ var ts;
|
|
|
122675
122716
|
* "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot"
|
|
122676
122717
|
* @param dirPath
|
|
122677
122718
|
*/
|
|
122678
|
-
function
|
|
122719
|
+
function canWatchDirectoryOrFile(dirPath) {
|
|
122679
122720
|
var rootLength = ts.getRootLength(dirPath);
|
|
122680
122721
|
if (dirPath.length === rootLength) {
|
|
122681
122722
|
// Ignore "/", "c:/"
|
|
@@ -122712,7 +122753,7 @@ var ts;
|
|
|
122712
122753
|
}
|
|
122713
122754
|
return true;
|
|
122714
122755
|
}
|
|
122715
|
-
ts.
|
|
122756
|
+
ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile;
|
|
122716
122757
|
function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
|
|
122717
122758
|
var filesWithChangedSetOfUnresolvedImports;
|
|
122718
122759
|
var filesWithInvalidatedResolutions;
|
|
@@ -122721,7 +122762,9 @@ var ts;
|
|
|
122721
122762
|
var resolutionsWithFailedLookups = [];
|
|
122722
122763
|
var resolutionsWithOnlyAffectingLocations = [];
|
|
122723
122764
|
var resolvedFileToResolution = ts.createMultiMap();
|
|
122765
|
+
var impliedFormatPackageJsons = new ts.Map();
|
|
122724
122766
|
var hasChangedAutomaticTypeDirectiveNames = false;
|
|
122767
|
+
var affectingPathChecksForFile;
|
|
122725
122768
|
var affectingPathChecks;
|
|
122726
122769
|
var failedLookupChecks;
|
|
122727
122770
|
var startsWithPathChecks;
|
|
@@ -122761,7 +122804,7 @@ var ts;
|
|
|
122761
122804
|
finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
|
|
122762
122805
|
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
|
122763
122806
|
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
|
122764
|
-
startCachingPerDirectoryResolution:
|
|
122807
|
+
startCachingPerDirectoryResolution: startCachingPerDirectoryResolution,
|
|
122765
122808
|
finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
|
|
122766
122809
|
resolveModuleNames: resolveModuleNames,
|
|
122767
122810
|
getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
|
|
@@ -122805,9 +122848,10 @@ var ts;
|
|
|
122805
122848
|
startsWithPathChecks = undefined;
|
|
122806
122849
|
isInDirectoryChecks = undefined;
|
|
122807
122850
|
affectingPathChecks = undefined;
|
|
122808
|
-
|
|
122809
|
-
|
|
122810
|
-
|
|
122851
|
+
affectingPathChecksForFile = undefined;
|
|
122852
|
+
moduleResolutionCache.clear();
|
|
122853
|
+
typeReferenceDirectiveResolutionCache.clear();
|
|
122854
|
+
impliedFormatPackageJsons.clear();
|
|
122811
122855
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
122812
122856
|
}
|
|
122813
122857
|
function startRecordingFilesWithChangedResolutions() {
|
|
@@ -122839,15 +122883,44 @@ var ts;
|
|
|
122839
122883
|
return function (path) { return (!!collected && collected.has(path)) ||
|
|
122840
122884
|
isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
|
|
122841
122885
|
}
|
|
122842
|
-
function
|
|
122843
|
-
moduleResolutionCache.
|
|
122844
|
-
typeReferenceDirectiveResolutionCache.
|
|
122886
|
+
function startCachingPerDirectoryResolution() {
|
|
122887
|
+
moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
|
|
122888
|
+
typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
|
|
122889
|
+
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
|
|
122890
|
+
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
|
|
122845
122891
|
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
|
122846
122892
|
nonRelativeExternalModuleResolutions.clear();
|
|
122847
122893
|
}
|
|
122848
|
-
function finishCachingPerDirectoryResolution() {
|
|
122894
|
+
function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
|
|
122849
122895
|
filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
|
|
122850
|
-
|
|
122896
|
+
nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
|
|
122897
|
+
nonRelativeExternalModuleResolutions.clear();
|
|
122898
|
+
// Update file watches
|
|
122899
|
+
if (newProgram !== oldProgram) {
|
|
122900
|
+
newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) {
|
|
122901
|
+
var _a, _b, _c;
|
|
122902
|
+
var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0;
|
|
122903
|
+
var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray;
|
|
122904
|
+
for (var i = existing.length; i < expected; i++) {
|
|
122905
|
+
createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false);
|
|
122906
|
+
}
|
|
122907
|
+
if (existing.length > expected) {
|
|
122908
|
+
for (var i = expected; i < existing.length; i++) {
|
|
122909
|
+
fileWatchesOfAffectingLocations.get(existing[i]).files--;
|
|
122910
|
+
}
|
|
122911
|
+
}
|
|
122912
|
+
if (expected)
|
|
122913
|
+
impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations);
|
|
122914
|
+
else
|
|
122915
|
+
impliedFormatPackageJsons.delete(newFile.path);
|
|
122916
|
+
});
|
|
122917
|
+
impliedFormatPackageJsons.forEach(function (existing, path) {
|
|
122918
|
+
if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) {
|
|
122919
|
+
existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; });
|
|
122920
|
+
impliedFormatPackageJsons.delete(path);
|
|
122921
|
+
}
|
|
122922
|
+
});
|
|
122923
|
+
}
|
|
122851
122924
|
directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
|
|
122852
122925
|
if (watcher.refCount === 0) {
|
|
122853
122926
|
directoryWatchesOfFailedLookups.delete(path);
|
|
@@ -122855,7 +122928,7 @@ var ts;
|
|
|
122855
122928
|
}
|
|
122856
122929
|
});
|
|
122857
122930
|
fileWatchesOfAffectingLocations.forEach(function (watcher, path) {
|
|
122858
|
-
if (watcher.
|
|
122931
|
+
if (watcher.files === 0 && watcher.resolutions === 0) {
|
|
122859
122932
|
fileWatchesOfAffectingLocations.delete(path);
|
|
122860
122933
|
watcher.watcher.close();
|
|
122861
122934
|
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
@@ -123086,7 +123159,7 @@ var ts;
|
|
|
123086
123159
|
}
|
|
123087
123160
|
// If the directory is node_modules use it to watch, always watch it recursively
|
|
123088
123161
|
if (ts.isNodeModulesDirectory(dirPath)) {
|
|
123089
|
-
return
|
|
123162
|
+
return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
|
|
123090
123163
|
}
|
|
123091
123164
|
var nonRecursive = true;
|
|
123092
123165
|
// Use some ancestor of the root directory
|
|
@@ -123104,7 +123177,7 @@ var ts;
|
|
|
123104
123177
|
dir = ts.getDirectoryPath(dir);
|
|
123105
123178
|
}
|
|
123106
123179
|
}
|
|
123107
|
-
return
|
|
123180
|
+
return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
|
|
123108
123181
|
}
|
|
123109
123182
|
function isPathWithDefaultFailedLookupExtension(path) {
|
|
123110
123183
|
return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
|
|
@@ -123175,46 +123248,58 @@ var ts;
|
|
|
123175
123248
|
// Watch package json
|
|
123176
123249
|
for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
|
|
123177
123250
|
var affectingLocation = affectingLocations_1[_i];
|
|
123178
|
-
createFileWatcherOfAffectingLocation(affectingLocation);
|
|
123251
|
+
createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true);
|
|
123179
123252
|
}
|
|
123180
123253
|
}
|
|
123181
|
-
function createFileWatcherOfAffectingLocation(affectingLocation) {
|
|
123182
|
-
var
|
|
123183
|
-
var fileWatcher = fileWatchesOfAffectingLocations.get(path);
|
|
123254
|
+
function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
|
|
123255
|
+
var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
|
|
123184
123256
|
if (fileWatcher) {
|
|
123185
|
-
|
|
123257
|
+
if (forResolution)
|
|
123258
|
+
fileWatcher.resolutions++;
|
|
123259
|
+
else
|
|
123260
|
+
fileWatcher.files++;
|
|
123186
123261
|
return;
|
|
123187
123262
|
}
|
|
123188
123263
|
var locationToWatch = affectingLocation;
|
|
123189
|
-
var locationToWatchPath = path;
|
|
123190
123264
|
if (resolutionHost.realpath) {
|
|
123191
123265
|
locationToWatch = resolutionHost.realpath(affectingLocation);
|
|
123192
|
-
|
|
123193
|
-
|
|
123194
|
-
var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath);
|
|
123266
|
+
if (affectingLocation !== locationToWatch) {
|
|
123267
|
+
var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch);
|
|
123195
123268
|
if (fileWatcher_1) {
|
|
123196
|
-
|
|
123197
|
-
|
|
123198
|
-
|
|
123269
|
+
if (forResolution)
|
|
123270
|
+
fileWatcher_1.resolutions++;
|
|
123271
|
+
else
|
|
123272
|
+
fileWatcher_1.files++;
|
|
123273
|
+
fileWatcher_1.paths.add(affectingLocation);
|
|
123274
|
+
fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1);
|
|
123199
123275
|
return;
|
|
123200
123276
|
}
|
|
123201
123277
|
}
|
|
123202
123278
|
}
|
|
123203
123279
|
var paths = new ts.Set();
|
|
123204
|
-
paths.add(
|
|
123280
|
+
paths.add(locationToWatch);
|
|
123205
123281
|
var watcher = {
|
|
123206
|
-
watcher: resolutionHost.
|
|
123207
|
-
|
|
123208
|
-
|
|
123209
|
-
|
|
123210
|
-
|
|
123211
|
-
|
|
123282
|
+
watcher: canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
|
|
123283
|
+
resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
|
|
123284
|
+
cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
|
|
123285
|
+
paths.forEach(function (path) {
|
|
123286
|
+
var _a;
|
|
123287
|
+
if (watcher.resolutions)
|
|
123288
|
+
(affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
|
|
123289
|
+
if (watcher.files)
|
|
123290
|
+
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123291
|
+
(_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) === null || _a === void 0 ? void 0 : _a.delete(resolutionHost.toPath(path));
|
|
123292
|
+
});
|
|
123293
|
+
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123294
|
+
}) : ts.noopFileWatcher,
|
|
123295
|
+
resolutions: forResolution ? 1 : 0,
|
|
123296
|
+
files: forResolution ? 0 : 1,
|
|
123212
123297
|
paths: paths,
|
|
123213
123298
|
};
|
|
123214
|
-
fileWatchesOfAffectingLocations.set(
|
|
123215
|
-
if (
|
|
123216
|
-
fileWatchesOfAffectingLocations.set(
|
|
123217
|
-
paths.add(
|
|
123299
|
+
fileWatchesOfAffectingLocations.set(locationToWatch, watcher);
|
|
123300
|
+
if (affectingLocation !== locationToWatch) {
|
|
123301
|
+
fileWatchesOfAffectingLocations.set(affectingLocation, watcher);
|
|
123302
|
+
paths.add(affectingLocation);
|
|
123218
123303
|
}
|
|
123219
123304
|
}
|
|
123220
123305
|
function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
|
|
@@ -123282,8 +123367,8 @@ var ts;
|
|
|
123282
123367
|
}
|
|
123283
123368
|
for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) {
|
|
123284
123369
|
var affectingLocation = affectingLocations_2[_a];
|
|
123285
|
-
var watcher = fileWatchesOfAffectingLocations.get(
|
|
123286
|
-
watcher.
|
|
123370
|
+
var watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
|
|
123371
|
+
watcher.resolutions--;
|
|
123287
123372
|
}
|
|
123288
123373
|
}
|
|
123289
123374
|
function removeDirectoryWatcher(dirPath) {
|
|
@@ -123337,7 +123422,7 @@ var ts;
|
|
|
123337
123422
|
resolution.isInvalidated = invalidated = true;
|
|
123338
123423
|
for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) {
|
|
123339
123424
|
var containingFilePath = _b[_a];
|
|
123340
|
-
(filesWithInvalidatedResolutions
|
|
123425
|
+
(filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
|
|
123341
123426
|
// When its a file with inferred types resolution, invalidate type reference directive resolution
|
|
123342
123427
|
hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
|
|
123343
123428
|
}
|
|
@@ -123404,10 +123489,25 @@ var ts;
|
|
|
123404
123489
|
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123405
123490
|
}
|
|
123406
123491
|
function invalidateResolutionsOfFailedLookupLocations() {
|
|
123492
|
+
var _a;
|
|
123493
|
+
var invalidated = false;
|
|
123494
|
+
if (affectingPathChecksForFile) {
|
|
123495
|
+
(_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) {
|
|
123496
|
+
if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) {
|
|
123497
|
+
(filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path);
|
|
123498
|
+
invalidated = true;
|
|
123499
|
+
}
|
|
123500
|
+
});
|
|
123501
|
+
affectingPathChecksForFile = undefined;
|
|
123502
|
+
}
|
|
123407
123503
|
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
|
|
123408
|
-
return
|
|
123504
|
+
return invalidated;
|
|
123505
|
+
}
|
|
123506
|
+
invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated;
|
|
123507
|
+
var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
123508
|
+
if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
|
|
123509
|
+
packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; });
|
|
123409
123510
|
}
|
|
123410
|
-
var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
|
|
123411
123511
|
failedLookupChecks = undefined;
|
|
123412
123512
|
startsWithPathChecks = undefined;
|
|
123413
123513
|
isInDirectoryChecks = undefined;
|
|
@@ -123420,17 +123520,15 @@ var ts;
|
|
|
123420
123520
|
return true;
|
|
123421
123521
|
if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks)
|
|
123422
123522
|
return false;
|
|
123423
|
-
return resolution.failedLookupLocations.some(function (location) {
|
|
123424
|
-
|
|
123425
|
-
|
|
123426
|
-
|
|
123427
|
-
|
|
123428
|
-
|
|
123523
|
+
return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); });
|
|
123524
|
+
}
|
|
123525
|
+
function isInvalidatedFailedLookup(locationPath) {
|
|
123526
|
+
return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) ||
|
|
123527
|
+
ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) ||
|
|
123528
|
+
ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; });
|
|
123429
123529
|
}
|
|
123430
123530
|
function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
|
|
123431
|
-
return !!affectingPathChecks && resolution.affectingLocations.some(function (location) {
|
|
123432
|
-
return affectingPathChecks.has(resolutionHost.toPath(location));
|
|
123433
|
-
});
|
|
123531
|
+
return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); });
|
|
123434
123532
|
}
|
|
123435
123533
|
function closeTypeRootsWatch() {
|
|
123436
123534
|
ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
|
|
@@ -123496,7 +123594,7 @@ var ts;
|
|
|
123496
123594
|
function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
|
|
123497
123595
|
var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
|
|
123498
123596
|
var dirPath = resolutionHost.toPath(dir);
|
|
123499
|
-
return dirPath === rootPath ||
|
|
123597
|
+
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|
|
123500
123598
|
}
|
|
123501
123599
|
}
|
|
123502
123600
|
ts.createResolutionCache = createResolutionCache;
|
|
@@ -124469,23 +124567,46 @@ var ts;
|
|
|
124469
124567
|
var file = _c[_i];
|
|
124470
124568
|
write("" + toFileName(file, relativeFileName));
|
|
124471
124569
|
(_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); });
|
|
124472
|
-
(_b =
|
|
124570
|
+
(_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); });
|
|
124473
124571
|
}
|
|
124474
124572
|
}
|
|
124475
124573
|
ts.explainFiles = explainFiles;
|
|
124476
|
-
function
|
|
124574
|
+
function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) {
|
|
124575
|
+
var _a;
|
|
124477
124576
|
var result;
|
|
124478
124577
|
if (file.path !== file.resolvedPath) {
|
|
124479
|
-
(result
|
|
124578
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124480
124579
|
/*details*/ undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor)));
|
|
124481
124580
|
}
|
|
124482
124581
|
if (file.redirectInfo) {
|
|
124483
|
-
(result
|
|
124582
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124484
124583
|
/*details*/ undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor)));
|
|
124485
124584
|
}
|
|
124585
|
+
if (ts.isExternalOrCommonJsModule(file)) {
|
|
124586
|
+
switch (file.impliedNodeFormat) {
|
|
124587
|
+
case ts.ModuleKind.ESNext:
|
|
124588
|
+
if (file.packageJsonScope) {
|
|
124589
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124590
|
+
/*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
|
|
124591
|
+
}
|
|
124592
|
+
break;
|
|
124593
|
+
case ts.ModuleKind.CommonJS:
|
|
124594
|
+
if (file.packageJsonScope) {
|
|
124595
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124596
|
+
/*details*/ undefined, file.packageJsonScope.packageJsonContent.type ?
|
|
124597
|
+
ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module :
|
|
124598
|
+
ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor)));
|
|
124599
|
+
}
|
|
124600
|
+
else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) {
|
|
124601
|
+
(result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(
|
|
124602
|
+
/*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found));
|
|
124603
|
+
}
|
|
124604
|
+
break;
|
|
124605
|
+
}
|
|
124606
|
+
}
|
|
124486
124607
|
return result;
|
|
124487
124608
|
}
|
|
124488
|
-
ts.
|
|
124609
|
+
ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat;
|
|
124489
124610
|
function getMatchedFileSpec(program, fileName) {
|
|
124490
124611
|
var _a;
|
|
124491
124612
|
var configFile = program.getCompilerOptions().configFile;
|
|
@@ -124695,6 +124816,7 @@ var ts;
|
|
|
124695
124816
|
MissingFile: "Missing file",
|
|
124696
124817
|
WildcardDirectory: "Wild card directory",
|
|
124697
124818
|
FailedLookupLocations: "Failed Lookup Locations",
|
|
124819
|
+
AffectingFileLocation: "File location affecting resolution",
|
|
124698
124820
|
TypeRoots: "Type roots",
|
|
124699
124821
|
ConfigFileOfReferencedProject: "Config file of referened project",
|
|
124700
124822
|
ExtendedConfigOfReferencedProject: "Extended config file of referenced project",
|
|
@@ -125018,7 +125140,7 @@ var ts;
|
|
|
125018
125140
|
compilerHost.getCompilationSettings = function () { return compilerOptions; };
|
|
125019
125141
|
compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
|
|
125020
125142
|
compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
|
|
125021
|
-
compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.
|
|
125143
|
+
compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); };
|
|
125022
125144
|
compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
|
|
125023
125145
|
compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
|
|
125024
125146
|
compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
|
|
@@ -125052,6 +125174,9 @@ var ts;
|
|
|
125052
125174
|
return host.resolveTypeReferenceDirectives.apply(host, args);
|
|
125053
125175
|
}) :
|
|
125054
125176
|
(function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
|
|
125177
|
+
compilerHost.getModuleResolutionCache = host.resolveModuleNames ?
|
|
125178
|
+
ts.maybeBind(host, host.getModuleResolutionCache) :
|
|
125179
|
+
(function () { return resolutionCache.getModuleResolutionCache(); });
|
|
125055
125180
|
var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
|
|
125056
125181
|
builderProgram = readBuilderProgram(compilerOptions, compilerHost);
|
|
125057
125182
|
synchronizeProgram();
|
|
@@ -125154,8 +125279,9 @@ var ts;
|
|
|
125154
125279
|
resolutionCache.startCachingPerDirectoryResolution();
|
|
125155
125280
|
compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
|
|
125156
125281
|
compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
|
|
125282
|
+
var oldProgram = getCurrentProgram();
|
|
125157
125283
|
builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
|
|
125158
|
-
resolutionCache.finishCachingPerDirectoryResolution();
|
|
125284
|
+
resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram);
|
|
125159
125285
|
// Update watches
|
|
125160
125286
|
ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
|
|
125161
125287
|
if (needsUpdateInTypeRootWatch) {
|
|
@@ -125237,9 +125363,6 @@ var ts;
|
|
|
125237
125363
|
sourceFilesCache.set(path, false);
|
|
125238
125364
|
}
|
|
125239
125365
|
}
|
|
125240
|
-
if (sourceFile) {
|
|
125241
|
-
sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
|
|
125242
|
-
}
|
|
125243
125366
|
return sourceFile;
|
|
125244
125367
|
}
|
|
125245
125368
|
return hostSourceFile.sourceFile;
|
|
@@ -125755,6 +125878,7 @@ var ts;
|
|
|
125755
125878
|
compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
|
|
125756
125879
|
compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
|
|
125757
125880
|
compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
|
|
125881
|
+
compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache);
|
|
125758
125882
|
var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
|
|
125759
125883
|
var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
|
|
125760
125884
|
if (!compilerHost.resolveModuleNames) {
|
|
@@ -137973,60 +138097,64 @@ var ts;
|
|
|
137973
138097
|
}
|
|
137974
138098
|
return settingsOrHost;
|
|
137975
138099
|
}
|
|
137976
|
-
function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
|
|
138100
|
+
function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
137977
138101
|
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
137978
138102
|
var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
|
|
137979
|
-
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
|
138103
|
+
return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
|
|
137980
138104
|
}
|
|
137981
|
-
function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
|
|
137982
|
-
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind);
|
|
138105
|
+
function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
138106
|
+
return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind, languageVersionOrOptions);
|
|
137983
138107
|
}
|
|
137984
|
-
function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
|
|
138108
|
+
function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
137985
138109
|
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
137986
138110
|
var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
|
|
137987
|
-
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
|
|
138111
|
+
return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions);
|
|
137988
138112
|
}
|
|
137989
|
-
function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
|
|
137990
|
-
return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
|
|
138113
|
+
function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) {
|
|
138114
|
+
return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind, languageVersionOrOptions);
|
|
137991
138115
|
}
|
|
137992
138116
|
function getDocumentRegistryEntry(bucketEntry, scriptKind) {
|
|
137993
138117
|
var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided"));
|
|
137994
138118
|
ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry);
|
|
137995
138119
|
return entry;
|
|
137996
138120
|
}
|
|
137997
|
-
function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) {
|
|
138121
|
+
function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind, languageVersionOrOptions) {
|
|
137998
138122
|
var _a, _b, _c, _d;
|
|
137999
138123
|
scriptKind = ts.ensureScriptKind(fileName, scriptKind);
|
|
138000
138124
|
var compilationSettings = getCompilationSettings(compilationSettingsOrHost);
|
|
138001
138125
|
var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost;
|
|
138002
138126
|
var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
|
|
138003
|
-
var sourceFileOptions =
|
|
138004
|
-
|
|
138005
|
-
|
|
138006
|
-
|
|
138007
|
-
|
|
138127
|
+
var sourceFileOptions = typeof languageVersionOrOptions === "object" ?
|
|
138128
|
+
languageVersionOrOptions :
|
|
138129
|
+
{
|
|
138130
|
+
languageVersion: scriptTarget,
|
|
138131
|
+
impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings),
|
|
138132
|
+
setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
|
|
138133
|
+
};
|
|
138134
|
+
sourceFileOptions.languageVersion = scriptTarget;
|
|
138008
138135
|
var oldBucketCount = buckets.size;
|
|
138009
|
-
var
|
|
138136
|
+
var keyWithMode = getDocumentRegistryBucketKeyWithMode(key, sourceFileOptions.impliedNodeFormat);
|
|
138137
|
+
var bucket = ts.getOrUpdate(buckets, keyWithMode, function () { return new ts.Map(); });
|
|
138010
138138
|
if (ts.tracing) {
|
|
138011
138139
|
if (buckets.size > oldBucketCount) {
|
|
138012
138140
|
// It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
|
|
138013
138141
|
// perhaps they are for two projects that don't have any overlap.
|
|
138014
138142
|
// Bonus: these events can help us interpret the more interesting event below.
|
|
138015
|
-
ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key:
|
|
138143
|
+
ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: keyWithMode });
|
|
138016
138144
|
}
|
|
138017
138145
|
// It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
|
|
138018
138146
|
// If this occurs unexpectedly, the fix is likely to synchronize the project settings.
|
|
138019
138147
|
// Skip .d.ts files to reduce noise (should also cover most of node_modules).
|
|
138020
138148
|
var otherBucketKey = !ts.isDeclarationFileName(path) &&
|
|
138021
|
-
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !==
|
|
138149
|
+
ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== keyWithMode && bucket.has(path) && bucketKey; });
|
|
138022
138150
|
if (otherBucketKey) {
|
|
138023
|
-
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2:
|
|
138151
|
+
ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: keyWithMode });
|
|
138024
138152
|
}
|
|
138025
138153
|
}
|
|
138026
138154
|
var bucketEntry = bucket.get(path);
|
|
138027
138155
|
var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
138028
138156
|
if (!entry && externalCache) {
|
|
138029
|
-
var sourceFile = externalCache.getDocument(
|
|
138157
|
+
var sourceFile = externalCache.getDocument(keyWithMode, path);
|
|
138030
138158
|
if (sourceFile) {
|
|
138031
138159
|
ts.Debug.assert(acquiring);
|
|
138032
138160
|
entry = {
|
|
@@ -138040,7 +138168,7 @@ var ts;
|
|
|
138040
138168
|
// Have never seen this file with these settings. Create a new source file for it.
|
|
138041
138169
|
var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind);
|
|
138042
138170
|
if (externalCache) {
|
|
138043
|
-
externalCache.setDocument(
|
|
138171
|
+
externalCache.setDocument(keyWithMode, path, sourceFile);
|
|
138044
138172
|
}
|
|
138045
138173
|
entry = {
|
|
138046
138174
|
sourceFile: sourceFile,
|
|
@@ -138055,7 +138183,7 @@ var ts;
|
|
|
138055
138183
|
if (entry.sourceFile.version !== version) {
|
|
138056
138184
|
entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217
|
|
138057
138185
|
if (externalCache) {
|
|
138058
|
-
externalCache.setDocument(
|
|
138186
|
+
externalCache.setDocument(keyWithMode, path, entry.sourceFile);
|
|
138059
138187
|
}
|
|
138060
138188
|
}
|
|
138061
138189
|
// If we're acquiring, then this is the first time this LS is asking for this document.
|
|
@@ -138084,13 +138212,13 @@ var ts;
|
|
|
138084
138212
|
}
|
|
138085
138213
|
}
|
|
138086
138214
|
}
|
|
138087
|
-
function releaseDocument(fileName, compilationSettings, scriptKind) {
|
|
138215
|
+
function releaseDocument(fileName, compilationSettings, scriptKind, impliedNodeFormat) {
|
|
138088
138216
|
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
138089
138217
|
var key = getKeyForCompilationSettings(compilationSettings);
|
|
138090
|
-
return releaseDocumentWithKey(path, key, scriptKind);
|
|
138218
|
+
return releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat);
|
|
138091
138219
|
}
|
|
138092
|
-
function releaseDocumentWithKey(path, key, scriptKind) {
|
|
138093
|
-
var bucket = ts.Debug.checkDefined(buckets.get(key));
|
|
138220
|
+
function releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat) {
|
|
138221
|
+
var bucket = ts.Debug.checkDefined(buckets.get(getDocumentRegistryBucketKeyWithMode(key, impliedNodeFormat)));
|
|
138094
138222
|
var bucketEntry = bucket.get(path);
|
|
138095
138223
|
var entry = getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
138096
138224
|
entry.languageServiceRefCount--;
|
|
@@ -138147,6 +138275,9 @@ var ts;
|
|
|
138147
138275
|
function getKeyForCompilationSettings(settings) {
|
|
138148
138276
|
return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined);
|
|
138149
138277
|
}
|
|
138278
|
+
function getDocumentRegistryBucketKeyWithMode(key, mode) {
|
|
138279
|
+
return (mode ? key + "|" + mode : key);
|
|
138280
|
+
}
|
|
138150
138281
|
})(ts || (ts = {}));
|
|
138151
138282
|
/* Code for finding imports of an exported symbol. Used only by FindAllReferences. */
|
|
138152
138283
|
/* @internal */
|
|
@@ -167390,12 +167521,12 @@ var ts;
|
|
|
167390
167521
|
// not part of the new program.
|
|
167391
167522
|
function onReleaseOldSourceFile(oldSourceFile, oldOptions) {
|
|
167392
167523
|
var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions);
|
|
167393
|
-
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind);
|
|
167524
|
+
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
|
|
167394
167525
|
}
|
|
167395
|
-
function getOrCreateSourceFile(fileName,
|
|
167396
|
-
return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName),
|
|
167526
|
+
function getOrCreateSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
|
|
167527
|
+
return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
|
167397
167528
|
}
|
|
167398
|
-
function getOrCreateSourceFileByPath(fileName, path,
|
|
167529
|
+
function getOrCreateSourceFileByPath(fileName, path, languageVersionOrOptions, _onError, shouldCreateNewSourceFile) {
|
|
167399
167530
|
ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
|
|
167400
167531
|
// The program is asking for this file, check first if the host can locate it.
|
|
167401
167532
|
// If the host can not locate the file, then it does not exist. return undefined
|
|
@@ -167438,17 +167569,17 @@ var ts;
|
|
|
167438
167569
|
// file's script kind, i.e. in one project some file is treated as ".ts"
|
|
167439
167570
|
// and in another as ".js"
|
|
167440
167571
|
if (scriptKind === oldSourceFile.scriptKind) {
|
|
167441
|
-
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
|
|
167572
|
+
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
|
|
167442
167573
|
}
|
|
167443
167574
|
else {
|
|
167444
167575
|
// Release old source file and fall through to aquire new file with new script kind
|
|
167445
|
-
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind);
|
|
167576
|
+
documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat);
|
|
167446
167577
|
}
|
|
167447
167578
|
}
|
|
167448
167579
|
// We didn't already have the file. Fall through and acquire it from the registry.
|
|
167449
167580
|
}
|
|
167450
167581
|
// Could not find this file in the old program, create a new SourceFile for it.
|
|
167451
|
-
return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
|
|
167582
|
+
return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions);
|
|
167452
167583
|
}
|
|
167453
167584
|
}
|
|
167454
167585
|
// TODO: GH#18217 frequently asserted as defined
|
|
@@ -167527,7 +167658,7 @@ var ts;
|
|
|
167527
167658
|
// Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host
|
|
167528
167659
|
var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions());
|
|
167529
167660
|
ts.forEach(program.getSourceFiles(), function (f) {
|
|
167530
|
-
return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind);
|
|
167661
|
+
return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind, f.impliedNodeFormat);
|
|
167531
167662
|
});
|
|
167532
167663
|
program = undefined; // TODO: GH#18217
|
|
167533
167664
|
}
|
|
@@ -168444,6 +168575,7 @@ var ts;
|
|
|
168444
168575
|
getEmitOutput: getEmitOutput,
|
|
168445
168576
|
getNonBoundSourceFile: getNonBoundSourceFile,
|
|
168446
168577
|
getProgram: getProgram,
|
|
168578
|
+
getCurrentProgram: function () { return program; },
|
|
168447
168579
|
getAutoImportProvider: getAutoImportProvider,
|
|
168448
168580
|
updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols,
|
|
168449
168581
|
getApplicableRefactors: getApplicableRefactors,
|