typescript 4.6.0-dev.20220206 → 4.6.0-dev.20220210

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.6";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220206";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220210";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -5259,10 +5259,10 @@ var ts;
5259
5259
  A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."),
5260
5260
  A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."),
5261
5261
  An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."),
5262
- An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."),
5263
- An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."),
5262
+ An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1232", "An import declaration can only be used at the top level of a namespace or module."),
5263
+ An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module_1233", "An export declaration can only be used at the top level of a namespace or module."),
5264
5264
  An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."),
5265
- A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."),
5265
+ A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module_1235", "A namespace declaration is only allowed at the top level of a namespace or module."),
5266
5266
  The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."),
5267
5267
  The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."),
5268
5268
  Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."),
@@ -5430,6 +5430,8 @@ var ts;
5430
5430
  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."),
5431
5431
  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."),
5432
5432
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
5433
+ An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."),
5434
+ An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."),
5433
5435
  The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
5434
5436
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
5435
5437
  Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true),
@@ -10516,6 +10518,10 @@ var ts;
10516
10518
  return undefined;
10517
10519
  }
10518
10520
  ts.getDeclarationOfKind = getDeclarationOfKind;
10521
+ function getDeclarationsOfKind(symbol, kind) {
10522
+ return ts.filter(symbol.declarations || ts.emptyArray, function (d) { return d.kind === kind; });
10523
+ }
10524
+ ts.getDeclarationsOfKind = getDeclarationsOfKind;
10519
10525
  function createSymbolTable(symbols) {
10520
10526
  var result = new ts.Map();
10521
10527
  if (symbols) {
@@ -10735,6 +10741,10 @@ var ts;
10735
10741
  return getSourceFileOfNode(module.valueDeclaration || getNonAugmentationDeclaration(module));
10736
10742
  }
10737
10743
  ts.getSourceFileOfModule = getSourceFileOfModule;
10744
+ function isPlainJsFile(file, checkJs) {
10745
+ return !!file && (file.scriptKind === 1 || file.scriptKind === 2) && !file.checkJsDirective && checkJs === undefined;
10746
+ }
10747
+ ts.isPlainJsFile = isPlainJsFile;
10738
10748
  function isStatementWithLocals(node) {
10739
10749
  switch (node.kind) {
10740
10750
  case 234:
@@ -39325,13 +39335,13 @@ var ts;
39325
39335
  else {
39326
39336
  var isEitherEnum = !!(target.flags & 384 || source.flags & 384);
39327
39337
  var isEitherBlockScoped_1 = !!(target.flags & 2 || source.flags & 2);
39328
- var message = isEitherEnum
39329
- ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
39330
- : isEitherBlockScoped_1
39331
- ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
39338
+ var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
39339
+ : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
39332
39340
  : ts.Diagnostics.Duplicate_identifier_0;
39333
39341
  var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
39334
39342
  var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
39343
+ var isSourcePlainJs = ts.isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
39344
+ var isTargetPlainJs = ts.isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
39335
39345
  var symbolName_1 = symbolToString(source);
39336
39346
  if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
39337
39347
  var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 ? sourceSymbolFile : targetSymbolFile;
@@ -39342,12 +39352,16 @@ var ts;
39342
39352
  var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
39343
39353
  return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
39344
39354
  });
39345
- addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
39346
- addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
39355
+ if (!isSourcePlainJs)
39356
+ addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
39357
+ if (!isTargetPlainJs)
39358
+ addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
39347
39359
  }
39348
39360
  else {
39349
- addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
39350
- addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
39361
+ if (!isSourcePlainJs)
39362
+ addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
39363
+ if (!isTargetPlainJs)
39364
+ addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
39351
39365
  }
39352
39366
  }
39353
39367
  return target;
@@ -39728,6 +39742,8 @@ var ts;
39728
39742
  useResult = result.flags & 262144
39729
39743
  ? lastLocation === location.type ||
39730
39744
  lastLocation.kind === 163 ||
39745
+ lastLocation.kind === 338 ||
39746
+ lastLocation.kind === 339 ||
39731
39747
  lastLocation.kind === 162
39732
39748
  : false;
39733
39749
  }
@@ -39916,9 +39932,9 @@ var ts;
39916
39932
  lastSelfReferenceLocation = location;
39917
39933
  }
39918
39934
  lastLocation = location;
39919
- location = ts.isJSDocTemplateTag(location) ?
39920
- ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
39921
- location.parent;
39935
+ location = ts.isJSDocTemplateTag(location) ? ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
39936
+ ts.isJSDocParameterTag(location) || ts.isJSDocReturnTag(location) ? ts.getHostSignatureFromJSDoc(location) || location.parent :
39937
+ location.parent;
39922
39938
  }
39923
39939
  if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
39924
39940
  result.isReferenced |= meaning;
@@ -40910,15 +40926,18 @@ var ts;
40910
40926
  return;
40911
40927
  }
40912
40928
  var host = ts.getJSDocHost(node);
40913
- if (host &&
40914
- ts.isExpressionStatement(host) &&
40915
- ts.isBinaryExpression(host.expression) &&
40916
- ts.getAssignmentDeclarationKind(host.expression) === 3) {
40929
+ if (host && ts.isExpressionStatement(host) && ts.isPrototypePropertyAssignment(host.expression)) {
40917
40930
  var symbol = getSymbolOfNode(host.expression.left);
40918
40931
  if (symbol) {
40919
40932
  return getDeclarationOfJSPrototypeContainer(symbol);
40920
40933
  }
40921
40934
  }
40935
+ if (host && ts.isFunctionExpression(host) && ts.isPrototypePropertyAssignment(host.parent) && ts.isExpressionStatement(host.parent.parent)) {
40936
+ var symbol = getSymbolOfNode(host.parent.left);
40937
+ if (symbol) {
40938
+ return getDeclarationOfJSPrototypeContainer(symbol);
40939
+ }
40940
+ }
40922
40941
  if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
40923
40942
  ts.isBinaryExpression(host.parent.parent) &&
40924
40943
  ts.getAssignmentDeclarationKind(host.parent.parent) === 6) {
@@ -44801,9 +44820,12 @@ var ts;
44801
44820
  function isErrorType(type) {
44802
44821
  return type === errorType || !!(type.flags & 1 && type.aliasSymbol);
44803
44822
  }
44804
- function getTypeForBindingElementParent(node) {
44823
+ function getTypeForBindingElementParent(node, checkMode) {
44824
+ if (checkMode !== 0) {
44825
+ return getTypeForVariableLikeDeclaration(node, false, checkMode);
44826
+ }
44805
44827
  var symbol = getSymbolOfNode(node);
44806
- return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
44828
+ return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false, checkMode);
44807
44829
  }
44808
44830
  function getRestType(source, properties, symbol) {
44809
44831
  source = filterType(source, function (t) { return !(t.flags & 98304); });
@@ -44908,7 +44930,8 @@ var ts;
44908
44930
  return type.flags & (128 | 256) ? "" + type.value : undefined;
44909
44931
  }
44910
44932
  function getTypeForBindingElement(declaration) {
44911
- var parentType = getTypeForBindingElementParent(declaration.parent.parent);
44933
+ var checkMode = declaration.dotDotDotToken ? 32 : 0;
44934
+ var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
44912
44935
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
44913
44936
  }
44914
44937
  function getBindingElementTypeFromParentType(declaration, parentType) {
@@ -44968,9 +44991,9 @@ var ts;
44968
44991
  return type;
44969
44992
  }
44970
44993
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
44971
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ? getNonUndefinedType(type) : type;
44994
+ return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0)) & 32768) ? getNonUndefinedType(type) : type;
44972
44995
  }
44973
- return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2));
44996
+ return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0)], 2));
44974
44997
  }
44975
44998
  function getTypeForDeclarationFromJSDocComment(declaration) {
44976
44999
  var jsdocType = ts.getJSDocType(declaration);
@@ -44992,9 +45015,9 @@ var ts;
44992
45015
  if (isOptional === void 0) { isOptional = true; }
44993
45016
  return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
44994
45017
  }
44995
- function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
45018
+ function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
44996
45019
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242) {
44997
- var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
45020
+ var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, checkMode)));
44998
45021
  return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType;
44999
45022
  }
45000
45023
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243) {
@@ -45056,7 +45079,7 @@ var ts;
45056
45079
  return containerObjectType;
45057
45080
  }
45058
45081
  }
45059
- var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
45082
+ var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
45060
45083
  return addOptionality(type, isProperty, isOptional);
45061
45084
  }
45062
45085
  if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
@@ -45389,7 +45412,7 @@ var ts;
45389
45412
  function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
45390
45413
  if (element.initializer) {
45391
45414
  var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType;
45392
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
45415
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0, contextualType)));
45393
45416
  }
45394
45417
  if (ts.isBindingPattern(element.name)) {
45395
45418
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
@@ -45455,7 +45478,7 @@ var ts;
45455
45478
  : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
45456
45479
  }
45457
45480
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
45458
- return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors);
45481
+ return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true, 0), declaration, reportErrors);
45459
45482
  }
45460
45483
  function isGlobalSymbolConstructor(node) {
45461
45484
  var symbol = getSymbolOfNode(node);
@@ -45666,9 +45689,11 @@ var ts;
45666
45689
  if (writing === void 0) { writing = false; }
45667
45690
  var getter = ts.getDeclarationOfKind(symbol, 171);
45668
45691
  var setter = ts.getDeclarationOfKind(symbol, 172);
45669
- var setterType = getAnnotatedAccessorType(setter);
45670
- if (writing && setterType) {
45671
- return instantiateTypeIfNeeded(setterType, symbol);
45692
+ if (writing) {
45693
+ var setterType_1 = getAnnotatedAccessorType(setter);
45694
+ if (setterType_1) {
45695
+ return instantiateTypeIfNeeded(setterType_1, symbol);
45696
+ }
45672
45697
  }
45673
45698
  if (getter && ts.isInJSFile(getter)) {
45674
45699
  var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
@@ -45680,6 +45705,7 @@ var ts;
45680
45705
  if (getterType) {
45681
45706
  return instantiateTypeIfNeeded(getterType, symbol);
45682
45707
  }
45708
+ var setterType = getAnnotatedAccessorType(setter);
45683
45709
  if (setterType) {
45684
45710
  return setterType;
45685
45711
  }
@@ -45815,6 +45841,31 @@ var ts;
45815
45841
  }
45816
45842
  return links.type;
45817
45843
  }
45844
+ function getWriteTypeOfSymbolWithDeferredType(symbol) {
45845
+ var links = getSymbolLinks(symbol);
45846
+ if (!links.writeType && links.deferralWriteConstituents) {
45847
+ ts.Debug.assertIsDefined(links.deferralParent);
45848
+ ts.Debug.assertIsDefined(links.deferralConstituents);
45849
+ links.writeType = links.deferralParent.flags & 1048576 ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
45850
+ }
45851
+ return links.writeType;
45852
+ }
45853
+ function getWriteTypeOfSymbol(symbol) {
45854
+ var checkFlags = ts.getCheckFlags(symbol);
45855
+ if (checkFlags & 65536) {
45856
+ var writeType = getWriteTypeOfSymbolWithDeferredType(symbol);
45857
+ if (writeType) {
45858
+ return writeType;
45859
+ }
45860
+ }
45861
+ if (symbol.flags & 33554432) {
45862
+ var writeType = symbol.writeType;
45863
+ if (writeType) {
45864
+ return writeType;
45865
+ }
45866
+ }
45867
+ return getSetAccessorTypeOfSymbol(symbol);
45868
+ }
45818
45869
  function getSetAccessorTypeOfSymbol(symbol) {
45819
45870
  if (symbol.flags & 98304) {
45820
45871
  var type = getTypeOfSetAccessor(symbol);
@@ -47868,6 +47919,7 @@ var ts;
47868
47919
  var firstType;
47869
47920
  var nameType;
47870
47921
  var propTypes = [];
47922
+ var writeTypes;
47871
47923
  var firstValueDeclaration;
47872
47924
  var hasNonUniformValueDeclaration = false;
47873
47925
  for (var _d = 0, props_1 = props; _d < props_1.length; _d++) {
@@ -47884,6 +47936,10 @@ var ts;
47884
47936
  firstType = type;
47885
47937
  nameType = getSymbolLinks(prop).nameType;
47886
47938
  }
47939
+ var writeType = getWriteTypeOfSymbol(prop);
47940
+ if (writeTypes || writeType !== type) {
47941
+ writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType);
47942
+ }
47887
47943
  else if (type !== firstType) {
47888
47944
  checkFlags |= 64;
47889
47945
  }
@@ -47910,9 +47966,13 @@ var ts;
47910
47966
  result.checkFlags |= 65536;
47911
47967
  result.deferralParent = containingType;
47912
47968
  result.deferralConstituents = propTypes;
47969
+ result.deferralWriteConstituents = writeTypes;
47913
47970
  }
47914
47971
  else {
47915
47972
  result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
47973
+ if (writeTypes) {
47974
+ result.writeType = isUnion ? getUnionType(writeTypes) : getIntersectionType(writeTypes);
47975
+ }
47916
47976
  }
47917
47977
  return result;
47918
47978
  }
@@ -48920,7 +48980,7 @@ var ts;
48920
48980
  }
48921
48981
  function getImpliedConstraint(type, checkNode, extendsNode) {
48922
48982
  return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
48923
- getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
48983
+ getActualTypeVariable(getTypeFromTypeNode(checkNode)) === getActualTypeVariable(type) ? getTypeFromTypeNode(extendsNode) :
48924
48984
  undefined;
48925
48985
  }
48926
48986
  function getConditionalFlowTypeOfType(type, node) {
@@ -58377,16 +58437,18 @@ var ts;
58377
58437
  function isGenericTypeWithoutNullableConstraint(type) {
58378
58438
  return !!(type.flags & 465829888 && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304));
58379
58439
  }
58380
- function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) {
58440
+ function hasContextualTypeWithNoGenericTypes(node, checkMode) {
58381
58441
  var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
58382
58442
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
58383
- getContextualType(node, 8);
58443
+ (checkMode && checkMode & 32 ?
58444
+ getContextualType(node, 8)
58445
+ : getContextualType(node));
58384
58446
  return contextualType && !isGenericType(contextualType);
58385
58447
  }
58386
58448
  function getNarrowableTypeForReference(type, reference, checkMode) {
58387
58449
  var substituteConstraints = !(checkMode && checkMode & 2) &&
58388
58450
  someType(type, isGenericTypeWithUnionConstraint) &&
58389
- (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
58451
+ (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
58390
58452
  return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
58391
58453
  }
58392
58454
  function isExportOrExportExpression(location) {
@@ -58428,7 +58490,7 @@ var ts;
58428
58490
  var links = getNodeLinks(location);
58429
58491
  if (!(links.flags & 268435456)) {
58430
58492
  links.flags |= 268435456;
58431
- var parentType = getTypeForBindingElementParent(parent);
58493
+ var parentType = getTypeForBindingElementParent(parent, 0);
58432
58494
  links.flags &= ~268435456;
58433
58495
  if (parentType && parentType.flags & 1048576 && !(parent.kind === 163 && isSymbolAssigned(symbol))) {
58434
58496
  var pattern = declaration.parent;
@@ -59099,7 +59161,7 @@ var ts;
59099
59161
  var parent = declaration.parent.parent;
59100
59162
  var name = declaration.propertyName || declaration.name;
59101
59163
  var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
59102
- parent.kind !== 202 && parent.initializer && checkDeclarationInitializer(parent);
59164
+ parent.kind !== 202 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 : 0);
59103
59165
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
59104
59166
  return undefined;
59105
59167
  if (parent.name.kind === 201) {
@@ -61014,7 +61076,7 @@ var ts;
61014
61076
  error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
61015
61077
  return errorType;
61016
61078
  }
61017
- propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getSetAccessorTypeOfSymbol(prop) : getTypeOfSymbol(prop);
61079
+ propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getWriteTypeOfSymbol(prop) : getTypeOfSymbol(prop);
61018
61080
  }
61019
61081
  return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode);
61020
61082
  }
@@ -65068,11 +65130,11 @@ var ts;
65068
65130
  }
65069
65131
  }
65070
65132
  function checkExpressionCached(node, checkMode) {
65133
+ if (checkMode && checkMode !== 0) {
65134
+ return checkExpression(node, checkMode);
65135
+ }
65071
65136
  var links = getNodeLinks(node);
65072
65137
  if (!links.resolvedType) {
65073
- if (checkMode && checkMode !== 0) {
65074
- return checkExpression(node, checkMode);
65075
- }
65076
65138
  var saveFlowLoopStart = flowLoopStart;
65077
65139
  var saveFlowTypeCache = flowTypeCache;
65078
65140
  flowLoopStart = flowLoopCount;
@@ -65089,10 +65151,12 @@ var ts;
65089
65151
  node.kind === 228 ||
65090
65152
  ts.isJSDocTypeAssertion(node);
65091
65153
  }
65092
- function checkDeclarationInitializer(declaration, contextualType) {
65154
+ function checkDeclarationInitializer(declaration, checkMode, contextualType) {
65093
65155
  var initializer = ts.getEffectiveInitializer(declaration);
65094
65156
  var type = getQuickTypeOfExpression(initializer) ||
65095
- (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
65157
+ (contextualType ?
65158
+ checkExpressionWithContextualType(initializer, contextualType, undefined, checkMode || 0)
65159
+ : checkExpressionCached(initializer, checkMode));
65096
65160
  return ts.isParameter(declaration) && declaration.name.kind === 201 &&
65097
65161
  isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
65098
65162
  padTupleType(type, declaration.name) : type;
@@ -67563,7 +67627,8 @@ var ts;
67563
67627
  checkComputedPropertyName(node.propertyName);
67564
67628
  }
67565
67629
  var parent = node.parent.parent;
67566
- var parentType = getTypeForBindingElementParent(parent);
67630
+ var parentCheckMode = node.dotDotDotToken ? 32 : 0;
67631
+ var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
67567
67632
  var name = node.propertyName || node.name;
67568
67633
  if (parentType && !ts.isBindingPattern(name)) {
67569
67634
  var exprType = getLiteralTypeFromPropertyName(name);
@@ -68527,7 +68592,7 @@ var ts;
68527
68592
  var declaration = catchClause.variableDeclaration;
68528
68593
  var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
68529
68594
  if (typeNode) {
68530
- var type = getTypeForVariableLikeDeclaration(declaration, false);
68595
+ var type = getTypeForVariableLikeDeclaration(declaration, false, 0);
68531
68596
  if (type && !(type.flags & 3)) {
68532
68597
  grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
68533
68598
  }
@@ -69521,7 +69586,7 @@ var ts;
69521
69586
  var isAmbientExternalModule = ts.isAmbientModule(node);
69522
69587
  var contextErrorMessage = isAmbientExternalModule
69523
69588
  ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
69524
- : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
69589
+ : ts.Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module;
69525
69590
  if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
69526
69591
  return;
69527
69592
  }
@@ -69802,7 +69867,7 @@ var ts;
69802
69867
  }
69803
69868
  }
69804
69869
  function checkImportDeclaration(node) {
69805
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
69870
+ if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
69806
69871
  return;
69807
69872
  }
69808
69873
  if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
@@ -69833,7 +69898,7 @@ var ts;
69833
69898
  checkAssertClause(node);
69834
69899
  }
69835
69900
  function checkImportEqualsDeclaration(node) {
69836
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
69901
+ if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
69837
69902
  return;
69838
69903
  }
69839
69904
  checkGrammarDecoratorsAndModifiers(node);
@@ -69867,7 +69932,7 @@ var ts;
69867
69932
  }
69868
69933
  }
69869
69934
  function checkExportDeclaration(node) {
69870
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
69935
+ if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
69871
69936
  return;
69872
69937
  }
69873
69938
  if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
@@ -70985,7 +71050,7 @@ var ts;
70985
71050
  return errorType;
70986
71051
  }
70987
71052
  if (ts.isBindingPattern(node)) {
70988
- return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
71053
+ return getTypeForVariableLikeDeclaration(node.parent, true, 0) || errorType;
70989
71054
  }
70990
71055
  if (isInRightSideOfImportOrExportAssignment(node)) {
70991
71056
  var symbol = getSymbolAtLocation(node);
@@ -94311,9 +94376,9 @@ var ts;
94311
94376
  ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
94312
94377
  ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
94313
94378
  ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
94314
- ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module.code,
94379
+ ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
94315
94380
  ts.Diagnostics.An_export_declaration_cannot_have_modifiers.code,
94316
- ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module.code,
94381
+ ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
94317
94382
  ts.Diagnostics.An_import_declaration_cannot_have_modifiers.code,
94318
94383
  ts.Diagnostics.An_object_member_cannot_be_declared_optional.code,
94319
94384
  ts.Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code,
@@ -95211,7 +95276,7 @@ var ts;
95211
95276
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
95212
95277
  var isJs = sourceFile.scriptKind === 1 || sourceFile.scriptKind === 2;
95213
95278
  var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
95214
- var isPlainJs = isJs && !sourceFile.checkJsDirective && options.checkJs === undefined;
95279
+ var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs);
95215
95280
  var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
95216
95281
  var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4
95217
95282
  || sourceFile.scriptKind === 5 || isPlainJs || isCheckJs || sourceFile.scriptKind === 7);