typescript 4.8.0-dev.20220705 → 4.8.0-dev.20220708

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 CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220705";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220708";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -1707,7 +1707,7 @@ var ts;
1707
1707
  }
1708
1708
  ts.compareBooleans = compareBooleans;
1709
1709
  function getSpellingSuggestion(name, candidates, getName) {
1710
- var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
1710
+ var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34));
1711
1711
  var bestDistance = Math.floor(name.length * 0.4) + 1;
1712
1712
  var bestCandidate;
1713
1713
  for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
@@ -2362,6 +2362,22 @@ var ts;
2362
2362
  return formatEnum(flags, ts.FlowFlags, true);
2363
2363
  }
2364
2364
  Debug.formatFlowFlags = formatFlowFlags;
2365
+ function formatRelationComparisonResult(result) {
2366
+ return formatEnum(result, ts.RelationComparisonResult, true);
2367
+ }
2368
+ Debug.formatRelationComparisonResult = formatRelationComparisonResult;
2369
+ function formatCheckMode(mode) {
2370
+ return formatEnum(mode, ts.CheckMode, true);
2371
+ }
2372
+ Debug.formatCheckMode = formatCheckMode;
2373
+ function formatSignatureCheckMode(mode) {
2374
+ return formatEnum(mode, ts.SignatureCheckMode, true);
2375
+ }
2376
+ Debug.formatSignatureCheckMode = formatSignatureCheckMode;
2377
+ function formatTypeFacts(facts) {
2378
+ return formatEnum(facts, ts.TypeFacts, true);
2379
+ }
2380
+ Debug.formatTypeFacts = formatTypeFacts;
2365
2381
  var isDebugInfoEnabled = false;
2366
2382
  var extendedDebugModule;
2367
2383
  function extendedDebug() {
@@ -6187,6 +6203,7 @@ var ts;
6187
6203
  The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
6188
6204
  _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"),
6189
6205
  We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
6206
+ Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
6190
6207
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
6191
6208
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
6192
6209
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -15381,7 +15398,8 @@ var ts;
15381
15398
  function getDeclarationModifierFlagsFromSymbol(s, isWrite) {
15382
15399
  if (isWrite === void 0) { isWrite = false; }
15383
15400
  if (s.valueDeclaration) {
15384
- var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173; })) || s.valueDeclaration;
15401
+ var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration))
15402
+ || (s.flags & 32768 && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration;
15385
15403
  var flags = ts.getCombinedModifierFlags(declaration);
15386
15404
  return s.parent && s.parent.flags & 32 ? flags : flags & ~28;
15387
15405
  }
@@ -16003,7 +16021,7 @@ var ts;
16003
16021
  return !file.isDeclarationFile ? walkTreeForJSXTags(file) : undefined;
16004
16022
  }
16005
16023
  function isFileForcedToBeModuleByFormat(file) {
16006
- return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs", ".cts"]))) && !file.isDeclarationFile ? true : undefined;
16024
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs", ".cts", ".mjs", ".mts"]))) && !file.isDeclarationFile ? true : undefined;
16007
16025
  }
16008
16026
  function getSetExternalModuleIndicator(options) {
16009
16027
  switch (getEmitModuleDetectionKind(options)) {
@@ -16020,10 +16038,7 @@ var ts;
16020
16038
  if (options.jsx === 4 || options.jsx === 5) {
16021
16039
  checks.push(isFileModuleFromUsingJSXTag);
16022
16040
  }
16023
- var moduleKind = getEmitModuleKind(options);
16024
- if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) {
16025
- checks.push(isFileForcedToBeModuleByFormat);
16026
- }
16041
+ checks.push(isFileForcedToBeModuleByFormat);
16027
16042
  var combined_1 = ts.or.apply(void 0, checks);
16028
16043
  var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
16029
16044
  return callback;
@@ -27359,10 +27374,10 @@ var ts;
27359
27374
  var hasJSDoc = hasPrecedingJSDocComment();
27360
27375
  var modifiers = parseModifiers();
27361
27376
  if (parseContextualModifier(136)) {
27362
- return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 172);
27377
+ return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 172, 4);
27363
27378
  }
27364
27379
  if (parseContextualModifier(149)) {
27365
- return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 173);
27380
+ return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 173, 4);
27366
27381
  }
27367
27382
  if (isIndexSignature()) {
27368
27383
  return parseIndexSignatureDeclaration(pos, hasJSDoc, undefined, modifiers);
@@ -28953,10 +28968,10 @@ var ts;
28953
28968
  var decorators = parseDecorators();
28954
28969
  var modifiers = parseModifiers();
28955
28970
  if (parseContextualModifier(136)) {
28956
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172);
28971
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172, 0);
28957
28972
  }
28958
28973
  if (parseContextualModifier(149)) {
28959
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173);
28974
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173, 0);
28960
28975
  }
28961
28976
  var asteriskToken = parseOptionalToken(41);
28962
28977
  var tokenIsIdentifier = isIdentifier();
@@ -29574,9 +29589,15 @@ var ts;
29574
29589
  return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10);
29575
29590
  }
29576
29591
  function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
29577
- if (token() !== 18 && canParseSemicolon()) {
29578
- parseSemicolon();
29579
- return;
29592
+ if (token() !== 18) {
29593
+ if (flags & 4) {
29594
+ parseTypeMemberSemicolon();
29595
+ return;
29596
+ }
29597
+ if (canParseSemicolon()) {
29598
+ parseSemicolon();
29599
+ return;
29600
+ }
29580
29601
  }
29581
29602
  return parseFunctionBlock(flags, diagnosticMessage);
29582
29603
  }
@@ -29764,12 +29785,12 @@ var ts;
29764
29785
  }
29765
29786
  return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
29766
29787
  }
29767
- function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
29788
+ function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) {
29768
29789
  var name = parsePropertyName();
29769
29790
  var typeParameters = parseTypeParameters();
29770
29791
  var parameters = parseParameters(0);
29771
29792
  var type = parseReturnType(58, false);
29772
- var body = parseFunctionBlockOrSemicolon(0);
29793
+ var body = parseFunctionBlockOrSemicolon(flags);
29773
29794
  var node = kind === 172
29774
29795
  ? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
29775
29796
  : factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
@@ -29925,10 +29946,10 @@ var ts;
29925
29946
  return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
29926
29947
  }
29927
29948
  if (parseContextualModifier(136)) {
29928
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172);
29949
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172, 0);
29929
29950
  }
29930
29951
  if (parseContextualModifier(149)) {
29931
- return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173);
29952
+ return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173, 0);
29932
29953
  }
29933
29954
  if (token() === 134 || token() === 10) {
29934
29955
  var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
@@ -36352,6 +36373,7 @@ var ts;
36352
36373
  return 1;
36353
36374
  return 0;
36354
36375
  }
36376
+ ts.comparePatternKeys = comparePatternKeys;
36355
36377
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
36356
36378
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
36357
36379
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
@@ -40031,7 +40053,7 @@ var ts;
40031
40053
  },
40032
40054
  getContextualTypeForObjectLiteralElement: function (nodeIn) {
40033
40055
  var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
40034
- return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
40056
+ return node ? getContextualTypeForObjectLiteralElement(node, undefined) : undefined;
40035
40057
  },
40036
40058
  getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
40037
40059
  var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
@@ -40039,7 +40061,7 @@ var ts;
40039
40061
  },
40040
40062
  getContextualTypeForJsxAttribute: function (nodeIn) {
40041
40063
  var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
40042
- return node && getContextualTypeForJsxAttribute(node);
40064
+ return node && getContextualTypeForJsxAttribute(node, undefined);
40043
40065
  },
40044
40066
  isContextSensitive: isContextSensitive,
40045
40067
  getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType,
@@ -40239,6 +40261,7 @@ var ts;
40239
40261
  var stringMappingTypes = new ts.Map();
40240
40262
  var substitutionTypes = new ts.Map();
40241
40263
  var subtypeReductionCache = new ts.Map();
40264
+ var cachedTypes = new ts.Map();
40242
40265
  var evolvingArrayTypes = [];
40243
40266
  var undefinedProperties = new ts.Map();
40244
40267
  var markerTypes = new ts.Set();
@@ -40477,6 +40500,14 @@ var ts;
40477
40500
  ];
40478
40501
  initializeTypeChecker();
40479
40502
  return checker;
40503
+ function getCachedType(key) {
40504
+ return key ? cachedTypes.get(key) : undefined;
40505
+ }
40506
+ function setCachedType(key, type) {
40507
+ if (key)
40508
+ cachedTypes.set(key, type);
40509
+ return type;
40510
+ }
40480
40511
  function getJsxNamespace(location) {
40481
40512
  if (location) {
40482
40513
  var file = ts.getSourceFileOfNode(location);
@@ -41216,6 +41247,7 @@ var ts;
41216
41247
  var ctor = findConstructorDeclaration(location.parent);
41217
41248
  if (ctor && ctor.locals) {
41218
41249
  if (lookup(ctor.locals, name, meaning & 111551)) {
41250
+ ts.Debug.assertNode(location, ts.isPropertyDeclaration);
41219
41251
  propertyWithInvalidInitializer = location;
41220
41252
  }
41221
41253
  }
@@ -41361,11 +41393,21 @@ var ts;
41361
41393
  }
41362
41394
  }
41363
41395
  }
41396
+ function checkAndReportErrorForInvalidInitializer() {
41397
+ if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 && useDefineForClassFields)) {
41398
+ error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
41399
+ ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
41400
+ : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg));
41401
+ return true;
41402
+ }
41403
+ return false;
41404
+ }
41364
41405
  if (!result) {
41365
41406
  if (nameNotFoundMessage) {
41366
41407
  addLazyDiagnostic(function () {
41367
41408
  if (!errorLocation ||
41368
41409
  !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
41410
+ !checkAndReportErrorForInvalidInitializer() &&
41369
41411
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
41370
41412
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
41371
41413
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
@@ -41373,7 +41415,14 @@ var ts;
41373
41415
  !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
41374
41416
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
41375
41417
  var suggestion = void 0;
41376
- if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
41418
+ var suggestedLib = void 0;
41419
+ if (nameArg) {
41420
+ suggestedLib = getSuggestedLibForNonExistentName(nameArg);
41421
+ if (suggestedLib) {
41422
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib);
41423
+ }
41424
+ }
41425
+ if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
41377
41426
  suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
41378
41427
  var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
41379
41428
  if (isGlobalScopeAugmentationDeclaration) {
@@ -41392,16 +41441,8 @@ var ts;
41392
41441
  }
41393
41442
  }
41394
41443
  }
41395
- if (!suggestion) {
41396
- if (nameArg) {
41397
- var lib = getSuggestedLibForNonExistentName(nameArg);
41398
- if (lib) {
41399
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
41400
- }
41401
- else {
41402
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
41403
- }
41404
- }
41444
+ if (!suggestion && !suggestedLib && nameArg) {
41445
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
41405
41446
  }
41406
41447
  suggestionCount++;
41407
41448
  }
@@ -41409,9 +41450,7 @@ var ts;
41409
41450
  }
41410
41451
  return undefined;
41411
41452
  }
41412
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 && useDefineForClassFields)) {
41413
- var propertyName = propertyWithInvalidInitializer.name;
41414
- error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
41453
+ else if (checkAndReportErrorForInvalidInitializer()) {
41415
41454
  return undefined;
41416
41455
  }
41417
41456
  if (nameNotFoundMessage) {
@@ -43285,13 +43324,25 @@ var ts;
43285
43324
  && isDeclarationVisible(declaration.parent)) {
43286
43325
  return addVisibleAlias(declaration, declaration);
43287
43326
  }
43288
- else if (symbol.flags & 2097152 && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent)
43289
- && ts.isVariableDeclaration(declaration.parent.parent)
43290
- && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
43291
- && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1)
43292
- && declaration.parent.parent.parent.parent.parent
43293
- && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
43294
- return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
43327
+ else if (ts.isBindingElement(declaration)) {
43328
+ if (symbol.flags & 2097152 && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent)
43329
+ && ts.isVariableDeclaration(declaration.parent.parent)
43330
+ && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
43331
+ && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1)
43332
+ && declaration.parent.parent.parent.parent.parent
43333
+ && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
43334
+ return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
43335
+ }
43336
+ else if (symbol.flags & 2) {
43337
+ var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement);
43338
+ if (ts.hasSyntacticModifier(variableStatement, 1)) {
43339
+ return true;
43340
+ }
43341
+ if (!isDeclarationVisible(variableStatement.parent)) {
43342
+ return false;
43343
+ }
43344
+ return addVisibleAlias(declaration, variableStatement);
43345
+ }
43295
43346
  }
43296
43347
  return false;
43297
43348
  }
@@ -43411,7 +43462,7 @@ var ts;
43411
43462
  }
43412
43463
  function toNodeBuilderFlags(flags) {
43413
43464
  if (flags === void 0) { flags = 0; }
43414
- return flags & 814775659;
43465
+ return flags & 848330091;
43415
43466
  }
43416
43467
  function isClassInstanceSide(type) {
43417
43468
  return !!type.symbol && !!(type.symbol.flags & 32) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288) && !!(ts.getObjectFlags(type) & 16777216)));
@@ -43782,6 +43833,10 @@ var ts;
43782
43833
  }
43783
43834
  return typeToTypeNodeHelper(type, context);
43784
43835
  }
43836
+ function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) {
43837
+ return isMappedTypeWithKeyofConstraintDeclaration(type)
43838
+ && !(getModifiersTypeFromMappedType(type).flags & 262144);
43839
+ }
43785
43840
  function createMappedTypeNodeFromType(type) {
43786
43841
  ts.Debug.assert(!!(type.flags & 524288));
43787
43842
  var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
@@ -43789,7 +43844,7 @@ var ts;
43789
43844
  var appropriateConstraintTypeNode;
43790
43845
  var newTypeVariable;
43791
43846
  if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
43792
- if (!(getModifiersTypeFromMappedType(type).flags & 262144) && context.flags & 4) {
43847
+ if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4) {
43793
43848
  var newParam = createTypeParameter(createSymbol(262144, "T"));
43794
43849
  var name = typeParameterToName(newParam, context);
43795
43850
  newTypeVariable = ts.factory.createTypeReferenceNode(name);
@@ -43805,8 +43860,9 @@ var ts;
43805
43860
  var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, undefined);
43806
43861
  context.approximateLength += 10;
43807
43862
  var result = ts.setEmitFlags(mappedTypeNode, 1);
43808
- if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144) && context.flags & 4) {
43809
- return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143));
43863
+ if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4) {
43864
+ var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper);
43865
+ return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(undefined, ts.factory.cloneNode(newTypeVariable.typeName), originalConstraint.flags & 2 ? undefined : typeToTypeNodeHelper(originalConstraint, context))), result, ts.factory.createKeywordTypeNode(143));
43810
43866
  }
43811
43867
  return result;
43812
43868
  }
@@ -44324,7 +44380,7 @@ var ts;
44324
44380
  }
44325
44381
  var expandedParams = getExpandedParameters(signature, true)[0];
44326
44382
  var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
44327
- var thisParameter = tryGetThisParameterDeclaration(signature, context);
44383
+ var thisParameter = context.flags & 33554432 ? undefined : tryGetThisParameterDeclaration(signature, context);
44328
44384
  if (thisParameter) {
44329
44385
  parameters.unshift(thisParameter);
44330
44386
  }
@@ -45277,12 +45333,11 @@ var ts;
45277
45333
  if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
45278
45334
  var oldContext = context;
45279
45335
  context = cloneNodeBuilderContext(context);
45280
- var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
45336
+ serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
45281
45337
  if (context.reportedDiagnostic) {
45282
45338
  oldcontext.reportedDiagnostic = context.reportedDiagnostic;
45283
45339
  }
45284
45340
  context = oldContext;
45285
- return result;
45286
45341
  }
45287
45342
  }
45288
45343
  function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
@@ -47867,7 +47922,7 @@ var ts;
47867
47922
  error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
47868
47923
  }
47869
47924
  else {
47870
- error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
47925
+ error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
47871
47926
  }
47872
47927
  }
47873
47928
  links.declaredType = type;
@@ -51766,19 +51821,22 @@ var ts;
51766
51821
  return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1, undefined, undefined, origin);
51767
51822
  }
51768
51823
  function isPossiblyReducibleByInstantiation(type) {
51769
- return ts.some(type.types, function (t) {
51770
- var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
51771
- return getReducedType(uniqueFilled) !== uniqueFilled;
51772
- });
51824
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(type);
51825
+ return getReducedType(uniqueFilled) !== uniqueFilled;
51826
+ }
51827
+ function shouldDeferIndexType(type) {
51828
+ return !!(type.flags & 58982400 ||
51829
+ isGenericTupleType(type) ||
51830
+ isGenericMappedType(type) && !hasDistributiveNameType(type) ||
51831
+ type.flags & 1048576 && ts.some(type.types, isPossiblyReducibleByInstantiation) ||
51832
+ type.flags & 2097152 && maybeTypeOfKind(type, 465829888) && ts.some(type.types, isEmptyAnonymousObjectType));
51773
51833
  }
51774
51834
  function getIndexType(type, stringsOnly, noIndexSignatures) {
51775
51835
  if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
51776
51836
  type = getReducedType(type);
51777
- return type.flags & 1048576 ? isPossiblyReducibleByInstantiation(type)
51778
- ? getIndexTypeForGenericType(type, stringsOnly)
51779
- : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
51780
- type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
51781
- type.flags & 58982400 || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
51837
+ return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
51838
+ type.flags & 1048576 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
51839
+ type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
51782
51840
  ts.getObjectFlags(type) & 32 ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
51783
51841
  type === wildcardType ? wildcardType :
51784
51842
  type.flags & 2 ? neverType :
@@ -55149,13 +55207,20 @@ var ts;
55149
55207
  return result;
55150
55208
  }
55151
55209
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
55210
+ var saveErrorInfo = captureErrorCalculationState();
55211
+ var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
55212
+ if (result) {
55213
+ resetErrorInfo(saveErrorInfo);
55214
+ }
55215
+ return result;
55216
+ }
55217
+ function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
55152
55218
  if (intersectionState & 4) {
55153
55219
  return propertiesRelatedTo(source, target, reportErrors, undefined, 0);
55154
55220
  }
55155
55221
  var result;
55156
55222
  var originalErrorInfo;
55157
55223
  var varianceCheckFailed = false;
55158
- var saveErrorInfo = captureErrorCalculationState();
55159
55224
  var sourceFlags = source.flags;
55160
55225
  var targetFlags = target.flags;
55161
55226
  if (relation === identityRelation) {
@@ -55204,7 +55269,6 @@ var ts;
55204
55269
  var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576));
55205
55270
  if (constraint && everyType(constraint, function (c) { return c !== source; })) {
55206
55271
  if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
55207
- resetErrorInfo(saveErrorInfo);
55208
55272
  return result;
55209
55273
  }
55210
55274
  }
@@ -55297,7 +55361,6 @@ var ts;
55297
55361
  result &= isRelatedTo(source.indexType, target.indexType, 3, reportErrors);
55298
55362
  }
55299
55363
  if (result) {
55300
- resetErrorInfo(saveErrorInfo);
55301
55364
  return result;
55302
55365
  }
55303
55366
  if (reportErrors) {
@@ -55373,7 +55436,6 @@ var ts;
55373
55436
  }
55374
55437
  else if (targetFlags & 16777216) {
55375
55438
  if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
55376
- resetErrorInfo(saveErrorInfo);
55377
55439
  return 3;
55378
55440
  }
55379
55441
  var c = target;
@@ -55383,7 +55445,6 @@ var ts;
55383
55445
  if (result = skipTrue ? -1 : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2, false)) {
55384
55446
  result &= skipFalse ? -1 : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2, false);
55385
55447
  if (result) {
55386
- resetErrorInfo(saveErrorInfo);
55387
55448
  return result;
55388
55449
  }
55389
55450
  }
@@ -55411,18 +55472,15 @@ var ts;
55411
55472
  if (!(sourceFlags & 8388608 && targetFlags & 8388608)) {
55412
55473
  var constraint = getConstraintOfType(source) || unknownType;
55413
55474
  if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
55414
- resetErrorInfo(saveErrorInfo);
55415
55475
  return result;
55416
55476
  }
55417
55477
  else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) {
55418
- resetErrorInfo(saveErrorInfo);
55419
55478
  return result;
55420
55479
  }
55421
55480
  if (isMappedTypeGenericIndexedAccess(source)) {
55422
55481
  var indexConstraint = getConstraintOfType(source.indexType);
55423
55482
  if (indexConstraint) {
55424
55483
  if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1, reportErrors)) {
55425
- resetErrorInfo(saveErrorInfo);
55426
55484
  return result;
55427
55485
  }
55428
55486
  }
@@ -55431,7 +55489,6 @@ var ts;
55431
55489
  }
55432
55490
  else if (sourceFlags & 4194304) {
55433
55491
  if (result = isRelatedTo(keyofConstraintType, target, 1, reportErrors)) {
55434
- resetErrorInfo(saveErrorInfo);
55435
55492
  return result;
55436
55493
  }
55437
55494
  }
@@ -55439,7 +55496,6 @@ var ts;
55439
55496
  if (!(targetFlags & 134217728)) {
55440
55497
  var constraint = getBaseConstraintOfType(source);
55441
55498
  if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1, reportErrors))) {
55442
- resetErrorInfo(saveErrorInfo);
55443
55499
  return result;
55444
55500
  }
55445
55501
  }
@@ -55450,21 +55506,18 @@ var ts;
55450
55506
  return 0;
55451
55507
  }
55452
55508
  if (result = isRelatedTo(source.type, target.type, 3, reportErrors)) {
55453
- resetErrorInfo(saveErrorInfo);
55454
55509
  return result;
55455
55510
  }
55456
55511
  }
55457
55512
  else {
55458
55513
  var constraint = getBaseConstraintOfType(source);
55459
55514
  if (constraint && (result = isRelatedTo(constraint, target, 1, reportErrors))) {
55460
- resetErrorInfo(saveErrorInfo);
55461
55515
  return result;
55462
55516
  }
55463
55517
  }
55464
55518
  }
55465
55519
  else if (sourceFlags & 16777216) {
55466
55520
  if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
55467
- resetErrorInfo(saveErrorInfo);
55468
55521
  return 3;
55469
55522
  }
55470
55523
  if (targetFlags & 16777216) {
@@ -55483,7 +55536,6 @@ var ts;
55483
55536
  result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3, reportErrors);
55484
55537
  }
55485
55538
  if (result) {
55486
- resetErrorInfo(saveErrorInfo);
55487
55539
  return result;
55488
55540
  }
55489
55541
  }
@@ -55492,7 +55544,6 @@ var ts;
55492
55544
  var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
55493
55545
  if (distributiveConstraint) {
55494
55546
  if (result = isRelatedTo(distributiveConstraint, target, 1, reportErrors)) {
55495
- resetErrorInfo(saveErrorInfo);
55496
55547
  return result;
55497
55548
  }
55498
55549
  }
@@ -55500,7 +55551,6 @@ var ts;
55500
55551
  var defaultConstraint = getDefaultConstraintOfConditionalType(source);
55501
55552
  if (defaultConstraint) {
55502
55553
  if (result = isRelatedTo(defaultConstraint, target, 1, reportErrors)) {
55503
- resetErrorInfo(saveErrorInfo);
55504
55554
  return result;
55505
55555
  }
55506
55556
  }
@@ -55512,7 +55562,6 @@ var ts;
55512
55562
  if (isGenericMappedType(target)) {
55513
55563
  if (isGenericMappedType(source)) {
55514
55564
  if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
55515
- resetErrorInfo(saveErrorInfo);
55516
55565
  return result;
55517
55566
  }
55518
55567
  }
@@ -56759,9 +56808,14 @@ var ts;
56759
56808
  type.flags & 256 ? numberType :
56760
56809
  type.flags & 2048 ? bigintType :
56761
56810
  type.flags & 512 ? booleanType :
56762
- type.flags & 1048576 ? mapType(type, getBaseTypeOfLiteralType) :
56811
+ type.flags & 1048576 ? getBaseTypeOfLiteralTypeUnion(type) :
56763
56812
  type;
56764
56813
  }
56814
+ function getBaseTypeOfLiteralTypeUnion(type) {
56815
+ var _a;
56816
+ var key = "B" + getTypeId(type);
56817
+ return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
56818
+ }
56765
56819
  function getWidenedLiteralType(type) {
56766
56820
  return type.flags & 1024 && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
56767
56821
  type.flags & 128 && isFreshLiteralType(type) ? stringType :
@@ -58366,6 +58420,14 @@ var ts;
58366
58420
  var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
58367
58421
  return key && key + "." + propName;
58368
58422
  }
58423
+ break;
58424
+ case 201:
58425
+ case 202:
58426
+ case 256:
58427
+ case 213:
58428
+ case 214:
58429
+ case 169:
58430
+ return getNodeId(node) + "#" + getTypeId(declaredType);
58369
58431
  }
58370
58432
  return undefined;
58371
58433
  }
@@ -58611,19 +58673,20 @@ var ts;
58611
58673
  return false;
58612
58674
  }
58613
58675
  function getAssignmentReducedType(declaredType, assignedType) {
58614
- if (declaredType !== assignedType) {
58615
- if (assignedType.flags & 131072) {
58616
- return assignedType;
58617
- }
58618
- var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
58619
- if (assignedType.flags & 512 && isFreshLiteralType(assignedType)) {
58620
- reducedType = mapType(reducedType, getFreshTypeOfLiteralType);
58621
- }
58622
- if (isTypeAssignableTo(assignedType, reducedType)) {
58623
- return reducedType;
58624
- }
58676
+ var _a;
58677
+ if (declaredType === assignedType) {
58678
+ return declaredType;
58625
58679
  }
58626
- return declaredType;
58680
+ if (assignedType.flags & 131072) {
58681
+ return assignedType;
58682
+ }
58683
+ var key = "A" + getTypeId(declaredType) + "," + getTypeId(assignedType);
58684
+ return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType));
58685
+ }
58686
+ function getAssignmentReducedTypeWorker(declaredType, assignedType) {
58687
+ var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
58688
+ var reducedType = assignedType.flags & 512 && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
58689
+ return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
58627
58690
  }
58628
58691
  function isFunctionObjectType(type) {
58629
58692
  var resolved = resolveStructuredTypeMembers(type);
@@ -59892,7 +59955,7 @@ var ts;
59892
59955
  var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
59893
59956
  ? getTypeOfSymbol(classSymbol)
59894
59957
  : getDeclaredTypeOfSymbol(classSymbol);
59895
- return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
59958
+ return getNarrowedType(type, targetType, assumeTrue, true);
59896
59959
  }
59897
59960
  function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
59898
59961
  var equalsOperator = operator === 34 || operator === 36;
@@ -60101,9 +60164,15 @@ var ts;
60101
60164
  if (!nonConstructorTypeInUnion)
60102
60165
  return type;
60103
60166
  }
60104
- return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
60167
+ return getNarrowedType(type, targetType, assumeTrue, true);
60168
+ }
60169
+ function getNarrowedType(type, candidate, assumeTrue, checkDerived) {
60170
+ var _a;
60171
+ var key = type.flags & 1048576 ? "N" + getTypeId(type) + "," + getTypeId(candidate) + "," + ((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined;
60172
+ return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived));
60105
60173
  }
60106
- function getNarrowedType(type, candidate, assumeTrue, isRelated) {
60174
+ function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
60175
+ var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
60107
60176
  if (!assumeTrue) {
60108
60177
  return filterType(type, function (t) { return !isRelated(t, candidate); });
60109
60178
  }
@@ -60143,7 +60212,7 @@ var ts;
60143
60212
  var predicateArgument = getTypePredicateArgument(predicate, callExpression);
60144
60213
  if (predicateArgument) {
60145
60214
  if (isMatchingReference(reference, predicateArgument)) {
60146
- return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf);
60215
+ return getNarrowedType(type, predicate.type, assumeTrue, false);
60147
60216
  }
60148
60217
  if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
60149
60218
  !(getTypeFacts(predicate.type) & 65536)) {
@@ -60151,7 +60220,7 @@ var ts;
60151
60220
  }
60152
60221
  var access = getDiscriminantPropertyAccess(predicateArgument, type);
60153
60222
  if (access) {
60154
- return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); });
60223
+ return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, false); });
60155
60224
  }
60156
60225
  }
60157
60226
  }
@@ -60304,7 +60373,7 @@ var ts;
60304
60373
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
60305
60374
  (checkMode && checkMode & 64 ?
60306
60375
  getContextualType(node, 8)
60307
- : getContextualType(node));
60376
+ : getContextualType(node, undefined));
60308
60377
  return contextualType && !isGenericType(contextualType);
60309
60378
  }
60310
60379
  function getNarrowableTypeForReference(type, reference, checkMode) {
@@ -60407,7 +60476,7 @@ var ts;
60407
60476
  getNodeLinks(container).flags |= 8192;
60408
60477
  return getTypeOfSymbol(symbol);
60409
60478
  }
60410
- if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
60479
+ if (shouldMarkIdentifierAliasReferenced(node)) {
60411
60480
  markAliasReferenced(symbol, node);
60412
60481
  }
60413
60482
  var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
@@ -60520,6 +60589,23 @@ var ts;
60520
60589
  }
60521
60590
  return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
60522
60591
  }
60592
+ function shouldMarkIdentifierAliasReferenced(node) {
60593
+ var _a;
60594
+ var parent = node.parent;
60595
+ if (parent) {
60596
+ if (ts.isPropertyAccessExpression(parent) && parent.expression === node) {
60597
+ return false;
60598
+ }
60599
+ if (ts.isExportSpecifier(parent) && parent.isTypeOnly) {
60600
+ return false;
60601
+ }
60602
+ var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent;
60603
+ if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) {
60604
+ return false;
60605
+ }
60606
+ }
60607
+ return true;
60608
+ }
60523
60609
  function isInsideFunctionOrInstancePropertyInitializer(node, threshold) {
60524
60610
  return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); });
60525
60611
  }
@@ -60944,7 +61030,7 @@ var ts;
60944
61030
  if (noImplicitThis || inJs) {
60945
61031
  var containingLiteral = getContainingObjectLiteral(func);
60946
61032
  if (containingLiteral) {
60947
- var contextualType = getApparentTypeOfContextualType(containingLiteral);
61033
+ var contextualType = getApparentTypeOfContextualType(containingLiteral, undefined);
60948
61034
  var literal = containingLiteral;
60949
61035
  var type = contextualType;
60950
61036
  while (type) {
@@ -60956,7 +61042,7 @@ var ts;
60956
61042
  break;
60957
61043
  }
60958
61044
  literal = literal.parent.parent;
60959
- type = getApparentTypeOfContextualType(literal);
61045
+ type = getApparentTypeOfContextualType(literal, undefined);
60960
61046
  }
60961
61047
  return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
60962
61048
  }
@@ -61006,7 +61092,7 @@ var ts;
61006
61092
  tryGetTypeAtPosition(contextualSignature, index);
61007
61093
  }
61008
61094
  }
61009
- function getContextualTypeForVariableLikeDeclaration(declaration) {
61095
+ function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) {
61010
61096
  var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
61011
61097
  if (typeNode) {
61012
61098
  return getTypeFromTypeNode(typeNode);
@@ -61015,17 +61101,17 @@ var ts;
61015
61101
  case 164:
61016
61102
  return getContextuallyTypedParameterType(declaration);
61017
61103
  case 203:
61018
- return getContextualTypeForBindingElement(declaration);
61104
+ return getContextualTypeForBindingElement(declaration, contextFlags);
61019
61105
  case 167:
61020
61106
  if (ts.isStatic(declaration)) {
61021
- return getContextualTypeForStaticPropertyDeclaration(declaration);
61107
+ return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags);
61022
61108
  }
61023
61109
  }
61024
61110
  }
61025
- function getContextualTypeForBindingElement(declaration) {
61111
+ function getContextualTypeForBindingElement(declaration, contextFlags) {
61026
61112
  var parent = declaration.parent.parent;
61027
61113
  var name = declaration.propertyName || declaration.name;
61028
- var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
61114
+ var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) ||
61029
61115
  parent.kind !== 203 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 : 0);
61030
61116
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
61031
61117
  return undefined;
@@ -61041,8 +61127,8 @@ var ts;
61041
61127
  return getTypeOfPropertyOfType(parentType, text);
61042
61128
  }
61043
61129
  }
61044
- function getContextualTypeForStaticPropertyDeclaration(declaration) {
61045
- var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent);
61130
+ function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) {
61131
+ var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags);
61046
61132
  if (!parentType)
61047
61133
  return undefined;
61048
61134
  return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
@@ -61050,7 +61136,7 @@ var ts;
61050
61136
  function getContextualTypeForInitializerExpression(node, contextFlags) {
61051
61137
  var declaration = node.parent;
61052
61138
  if (ts.hasInitializer(declaration) && node === declaration.initializer) {
61053
- var result = getContextualTypeForVariableLikeDeclaration(declaration);
61139
+ var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags);
61054
61140
  if (result) {
61055
61141
  return result;
61056
61142
  }
@@ -61060,10 +61146,10 @@ var ts;
61060
61146
  }
61061
61147
  return undefined;
61062
61148
  }
61063
- function getContextualTypeForReturnExpression(node) {
61149
+ function getContextualTypeForReturnExpression(node, contextFlags) {
61064
61150
  var func = ts.getContainingFunction(node);
61065
61151
  if (func) {
61066
- var contextualReturnType = getContextualReturnType(func);
61152
+ var contextualReturnType = getContextualReturnType(func, contextFlags);
61067
61153
  if (contextualReturnType) {
61068
61154
  var functionFlags = ts.getFunctionFlags(func);
61069
61155
  if (functionFlags & 1) {
@@ -61091,11 +61177,11 @@ var ts;
61091
61177
  }
61092
61178
  return undefined;
61093
61179
  }
61094
- function getContextualTypeForYieldOperand(node) {
61180
+ function getContextualTypeForYieldOperand(node, contextFlags) {
61095
61181
  var func = ts.getContainingFunction(node);
61096
61182
  if (func) {
61097
61183
  var functionFlags = ts.getFunctionFlags(func);
61098
- var contextualReturnType = getContextualReturnType(func);
61184
+ var contextualReturnType = getContextualReturnType(func, contextFlags);
61099
61185
  if (contextualReturnType) {
61100
61186
  return node.asteriskToken
61101
61187
  ? contextualReturnType
@@ -61119,14 +61205,14 @@ var ts;
61119
61205
  }
61120
61206
  function getContextualIterationType(kind, functionDecl) {
61121
61207
  var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2);
61122
- var contextualReturnType = getContextualReturnType(functionDecl);
61208
+ var contextualReturnType = getContextualReturnType(functionDecl, undefined);
61123
61209
  if (contextualReturnType) {
61124
61210
  return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
61125
61211
  || undefined;
61126
61212
  }
61127
61213
  return undefined;
61128
61214
  }
61129
- function getContextualReturnType(functionDecl) {
61215
+ function getContextualReturnType(functionDecl, contextFlags) {
61130
61216
  var returnType = getReturnTypeFromAnnotation(functionDecl);
61131
61217
  if (returnType) {
61132
61218
  return returnType;
@@ -61137,7 +61223,7 @@ var ts;
61137
61223
  }
61138
61224
  var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl);
61139
61225
  if (iife) {
61140
- return getContextualType(iife);
61226
+ return getContextualType(iife, contextFlags);
61141
61227
  }
61142
61228
  return undefined;
61143
61229
  }
@@ -61367,7 +61453,7 @@ var ts;
61367
61453
  }
61368
61454
  function getContextualTypeForObjectLiteralElement(element, contextFlags) {
61369
61455
  var objectLiteral = element.parent;
61370
- var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element);
61456
+ var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags);
61371
61457
  if (propertyAssignmentType) {
61372
61458
  return propertyAssignmentType;
61373
61459
  }
@@ -61512,9 +61598,9 @@ var ts;
61512
61598
  return getContextualTypeForInitializerExpression(node, contextFlags);
61513
61599
  case 214:
61514
61600
  case 247:
61515
- return getContextualTypeForReturnExpression(node);
61601
+ return getContextualTypeForReturnExpression(node, contextFlags);
61516
61602
  case 224:
61517
- return getContextualTypeForYieldOperand(parent);
61603
+ return getContextualTypeForYieldOperand(parent, contextFlags);
61518
61604
  case 218:
61519
61605
  return getContextualTypeForAwaitOperand(parent, contextFlags);
61520
61606
  case 208:
@@ -61561,7 +61647,7 @@ var ts;
61561
61647
  }
61562
61648
  return undefined;
61563
61649
  function tryFindWhenConstTypeReference(node) {
61564
- return getContextualType(node);
61650
+ return getContextualType(node, contextFlags);
61565
61651
  }
61566
61652
  }
61567
61653
  function getInferenceContext(node) {
@@ -61830,7 +61916,7 @@ var ts;
61830
61916
  var elementCount = elements.length;
61831
61917
  var elementTypes = [];
61832
61918
  var elementFlags = [];
61833
- var contextualType = getApparentTypeOfContextualType(node);
61919
+ var contextualType = getApparentTypeOfContextualType(node, undefined);
61834
61920
  var inDestructuringPattern = ts.isAssignmentTarget(node);
61835
61921
  var inConstContext = isConstContext(node);
61836
61922
  var hasOmittedExpression = false;
@@ -61979,7 +62065,7 @@ var ts;
61979
62065
  var propertiesTable = ts.createSymbolTable();
61980
62066
  var propertiesArray = [];
61981
62067
  var spread = emptyObjectType;
61982
- var contextualType = getApparentTypeOfContextualType(node);
62068
+ var contextualType = getApparentTypeOfContextualType(node, undefined);
61983
62069
  var contextualTypeHasPattern = contextualType && contextualType.pattern &&
61984
62070
  (contextualType.pattern.kind === 201 || contextualType.pattern.kind === 205);
61985
62071
  var inConstContext = isConstContext(node);
@@ -62277,7 +62363,7 @@ var ts;
62277
62363
  if (explicitlySpecifyChildrenAttribute) {
62278
62364
  error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
62279
62365
  }
62280
- var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
62366
+ var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, undefined);
62281
62367
  var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
62282
62368
  var childrenPropSymbol = createSymbol(4, jsxChildrenPropertyName);
62283
62369
  childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] :
@@ -64336,7 +64422,7 @@ var ts;
64336
64422
  argCheckMode = checkMode & 32;
64337
64423
  if (inferenceContext) {
64338
64424
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
64339
- checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
64425
+ checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
64340
64426
  if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
64341
64427
  candidateForArgumentArityError = checkCandidate;
64342
64428
  continue;
@@ -65565,13 +65651,6 @@ var ts;
65565
65651
  }
65566
65652
  }
65567
65653
  }
65568
- var restType = getEffectiveRestType(context);
65569
- if (restType && restType.flags & 262144) {
65570
- var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
65571
- assignContextualParameterTypes(signature, instantiatedContext);
65572
- var restPos = getParameterCount(context) - 1;
65573
- inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
65574
- }
65575
65654
  }
65576
65655
  function assignContextualParameterTypes(signature, context) {
65577
65656
  if (context.typeParameters) {
@@ -65744,7 +65823,7 @@ var ts;
65744
65823
  var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
65745
65824
  var contextualType = !contextualSignature ? undefined :
65746
65825
  contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
65747
- instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
65826
+ instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, undefined);
65748
65827
  if (isGenerator) {
65749
65828
  yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0, isAsync);
65750
65829
  returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1, isAsync);
@@ -65807,7 +65886,7 @@ var ts;
65807
65886
  nextType = iterationTypes && iterationTypes.nextType;
65808
65887
  }
65809
65888
  else {
65810
- nextType = getContextualType(yieldExpression);
65889
+ nextType = getContextualType(yieldExpression, undefined);
65811
65890
  }
65812
65891
  if (nextType)
65813
65892
  ts.pushIfUnique(nextTypes, nextType);
@@ -65980,11 +66059,16 @@ var ts;
65980
66059
  if (isContextSensitive(node)) {
65981
66060
  if (contextualSignature) {
65982
66061
  var inferenceContext = getInferenceContext(node);
66062
+ var instantiatedContextualSignature = void 0;
65983
66063
  if (checkMode && checkMode & 2) {
65984
66064
  inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
66065
+ var restType = getEffectiveRestType(contextualSignature);
66066
+ if (restType && restType.flags & 262144) {
66067
+ instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper);
66068
+ }
65985
66069
  }
65986
- var instantiatedContextualSignature = inferenceContext ?
65987
- instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
66070
+ instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ?
66071
+ instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature);
65988
66072
  assignContextualParameterTypes(signature, instantiatedContextualSignature);
65989
66073
  }
65990
66074
  else {
@@ -67099,7 +67183,7 @@ var ts;
67099
67183
  type = anyType;
67100
67184
  addLazyDiagnostic(function () {
67101
67185
  if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
67102
- var contextualType = getContextualType(node);
67186
+ var contextualType = getContextualType(node, undefined);
67103
67187
  if (!contextualType || isTypeAny(contextualType)) {
67104
67188
  error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
67105
67189
  }
@@ -67140,7 +67224,7 @@ var ts;
67140
67224
  texts.push(span.literal.text);
67141
67225
  types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
67142
67226
  }
67143
- return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
67227
+ return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
67144
67228
  }
67145
67229
  function isTemplateLiteralContextualType(type) {
67146
67230
  return !!(type.flags & (128 | 134217728) ||
@@ -67163,7 +67247,7 @@ var ts;
67163
67247
  if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
67164
67248
  inferenceContext.intraExpressionInferenceSites = undefined;
67165
67249
  }
67166
- var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
67250
+ var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, undefined)) ?
67167
67251
  getRegularTypeOfLiteralType(type) : type;
67168
67252
  return result;
67169
67253
  }
@@ -67267,7 +67351,7 @@ var ts;
67267
67351
  var type = checkExpression(node, checkMode, forceTuple);
67268
67352
  return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
67269
67353
  isTypeAssertion(node) ? type :
67270
- getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
67354
+ getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, undefined) : contextualType, node, undefined));
67271
67355
  }
67272
67356
  function checkPropertyAssignment(node, checkMode) {
67273
67357
  if (node.name.kind === 162) {
@@ -72352,7 +72436,9 @@ var ts;
72352
72436
  error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
72353
72437
  }
72354
72438
  else {
72355
- markExportAsReferenced(node);
72439
+ if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) {
72440
+ markExportAsReferenced(node);
72441
+ }
72356
72442
  var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol);
72357
72443
  if (!target || target === unknownSymbol || target.flags & 111551) {
72358
72444
  checkExpressionCached(node.propertyName || node.name);
@@ -75409,9 +75495,6 @@ var ts;
75409
75495
  else {
75410
75496
  return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
75411
75497
  }
75412
- if (!isConstOrReadonly || isInvalidInitializer) {
75413
- return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
75414
- }
75415
75498
  }
75416
75499
  }
75417
75500
  function checkGrammarVariableDeclaration(node) {
@@ -91571,7 +91654,7 @@ var ts;
91571
91654
  if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
91572
91655
  return;
91573
91656
  }
91574
- if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
91657
+ if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) {
91575
91658
  emitSkipped = true;
91576
91659
  return;
91577
91660
  }
@@ -103337,7 +103420,6 @@ var ts;
103337
103420
  var parsedConfigs;
103338
103421
  var sharedExtendedConfigFileWatchers;
103339
103422
  var extendedConfigCache = host.extendedConfigCache;
103340
- var changesAffectResolution = false;
103341
103423
  var reportFileChangeDetectedOnCreateProgram = false;
103342
103424
  var sourceFilesCache = new ts.Map();
103343
103425
  var missingFilePathsRequestedForRelease;
@@ -103482,11 +103564,11 @@ var ts;
103482
103564
  var program = getCurrentBuilderProgram();
103483
103565
  if (hasChangedCompilerOptions) {
103484
103566
  newLine = updateNewLine();
103485
- if (program && (changesAffectResolution || ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) {
103567
+ if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
103486
103568
  resolutionCache.clear();
103487
103569
  }
103488
103570
  }
103489
- var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
103571
+ var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
103490
103572
  if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
103491
103573
  if (hasChangedConfigFileParsingErrors) {
103492
103574
  if (reportFileChangeDetectedOnCreateProgram) {
@@ -103502,7 +103584,6 @@ var ts;
103502
103584
  }
103503
103585
  createNewProgram(hasInvalidatedResolution);
103504
103586
  }
103505
- changesAffectResolution = false;
103506
103587
  reportFileChangeDetectedOnCreateProgram = false;
103507
103588
  if (host.afterProgramCreate && program !== builderProgram) {
103508
103589
  host.afterProgramCreate(builderProgram);
@@ -104780,7 +104861,7 @@ var ts;
104780
104861
  }
104781
104862
  function afterProgramDone(state, program, config) {
104782
104863
  if (program) {
104783
- if (program && state.write)
104864
+ if (state.write)
104784
104865
  ts.listFiles(program, state.write);
104785
104866
  if (state.host.afterProgramEmitAndDiagnostics) {
104786
104867
  state.host.afterProgramEmitAndDiagnostics(program);