typescript 4.6.0-dev.20220209 → 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.20220209";
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),
@@ -10739,6 +10741,10 @@ var ts;
10739
10741
  return getSourceFileOfNode(module.valueDeclaration || getNonAugmentationDeclaration(module));
10740
10742
  }
10741
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;
10742
10748
  function isStatementWithLocals(node) {
10743
10749
  switch (node.kind) {
10744
10750
  case 234:
@@ -39329,13 +39335,13 @@ var ts;
39329
39335
  else {
39330
39336
  var isEitherEnum = !!(target.flags & 384 || source.flags & 384);
39331
39337
  var isEitherBlockScoped_1 = !!(target.flags & 2 || source.flags & 2);
39332
- var message = isEitherEnum
39333
- ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
39334
- : isEitherBlockScoped_1
39335
- ? 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
39336
39340
  : ts.Diagnostics.Duplicate_identifier_0;
39337
39341
  var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
39338
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);
39339
39345
  var symbolName_1 = symbolToString(source);
39340
39346
  if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
39341
39347
  var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 ? sourceSymbolFile : targetSymbolFile;
@@ -39346,12 +39352,16 @@ var ts;
39346
39352
  var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
39347
39353
  return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
39348
39354
  });
39349
- addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
39350
- addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
39355
+ if (!isSourcePlainJs)
39356
+ addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
39357
+ if (!isTargetPlainJs)
39358
+ addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
39351
39359
  }
39352
39360
  else {
39353
- addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
39354
- 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);
39355
39365
  }
39356
39366
  }
39357
39367
  return target;
@@ -39732,6 +39742,8 @@ var ts;
39732
39742
  useResult = result.flags & 262144
39733
39743
  ? lastLocation === location.type ||
39734
39744
  lastLocation.kind === 163 ||
39745
+ lastLocation.kind === 338 ||
39746
+ lastLocation.kind === 339 ||
39735
39747
  lastLocation.kind === 162
39736
39748
  : false;
39737
39749
  }
@@ -39920,9 +39932,9 @@ var ts;
39920
39932
  lastSelfReferenceLocation = location;
39921
39933
  }
39922
39934
  lastLocation = location;
39923
- location = ts.isJSDocTemplateTag(location) ?
39924
- ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
39925
- 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;
39926
39938
  }
39927
39939
  if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
39928
39940
  result.isReferenced |= meaning;
@@ -40914,15 +40926,18 @@ var ts;
40914
40926
  return;
40915
40927
  }
40916
40928
  var host = ts.getJSDocHost(node);
40917
- if (host &&
40918
- ts.isExpressionStatement(host) &&
40919
- ts.isBinaryExpression(host.expression) &&
40920
- ts.getAssignmentDeclarationKind(host.expression) === 3) {
40929
+ if (host && ts.isExpressionStatement(host) && ts.isPrototypePropertyAssignment(host.expression)) {
40921
40930
  var symbol = getSymbolOfNode(host.expression.left);
40922
40931
  if (symbol) {
40923
40932
  return getDeclarationOfJSPrototypeContainer(symbol);
40924
40933
  }
40925
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
+ }
40926
40941
  if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
40927
40942
  ts.isBinaryExpression(host.parent.parent) &&
40928
40943
  ts.getAssignmentDeclarationKind(host.parent.parent) === 6) {
@@ -44805,9 +44820,12 @@ var ts;
44805
44820
  function isErrorType(type) {
44806
44821
  return type === errorType || !!(type.flags & 1 && type.aliasSymbol);
44807
44822
  }
44808
- function getTypeForBindingElementParent(node) {
44823
+ function getTypeForBindingElementParent(node, checkMode) {
44824
+ if (checkMode !== 0) {
44825
+ return getTypeForVariableLikeDeclaration(node, false, checkMode);
44826
+ }
44809
44827
  var symbol = getSymbolOfNode(node);
44810
- return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
44828
+ return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false, checkMode);
44811
44829
  }
44812
44830
  function getRestType(source, properties, symbol) {
44813
44831
  source = filterType(source, function (t) { return !(t.flags & 98304); });
@@ -44912,7 +44930,8 @@ var ts;
44912
44930
  return type.flags & (128 | 256) ? "" + type.value : undefined;
44913
44931
  }
44914
44932
  function getTypeForBindingElement(declaration) {
44915
- var parentType = getTypeForBindingElementParent(declaration.parent.parent);
44933
+ var checkMode = declaration.dotDotDotToken ? 32 : 0;
44934
+ var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
44916
44935
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
44917
44936
  }
44918
44937
  function getBindingElementTypeFromParentType(declaration, parentType) {
@@ -44972,9 +44991,9 @@ var ts;
44972
44991
  return type;
44973
44992
  }
44974
44993
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
44975
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ? getNonUndefinedType(type) : type;
44994
+ return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0)) & 32768) ? getNonUndefinedType(type) : type;
44976
44995
  }
44977
- return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2));
44996
+ return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0)], 2));
44978
44997
  }
44979
44998
  function getTypeForDeclarationFromJSDocComment(declaration) {
44980
44999
  var jsdocType = ts.getJSDocType(declaration);
@@ -44996,9 +45015,9 @@ var ts;
44996
45015
  if (isOptional === void 0) { isOptional = true; }
44997
45016
  return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
44998
45017
  }
44999
- function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
45018
+ function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
45000
45019
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242) {
45001
- var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
45020
+ var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, checkMode)));
45002
45021
  return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType;
45003
45022
  }
45004
45023
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243) {
@@ -45060,7 +45079,7 @@ var ts;
45060
45079
  return containerObjectType;
45061
45080
  }
45062
45081
  }
45063
- var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
45082
+ var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
45064
45083
  return addOptionality(type, isProperty, isOptional);
45065
45084
  }
45066
45085
  if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
@@ -45393,7 +45412,7 @@ var ts;
45393
45412
  function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
45394
45413
  if (element.initializer) {
45395
45414
  var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType;
45396
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
45415
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0, contextualType)));
45397
45416
  }
45398
45417
  if (ts.isBindingPattern(element.name)) {
45399
45418
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
@@ -45459,7 +45478,7 @@ var ts;
45459
45478
  : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
45460
45479
  }
45461
45480
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
45462
- return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors);
45481
+ return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true, 0), declaration, reportErrors);
45463
45482
  }
45464
45483
  function isGlobalSymbolConstructor(node) {
45465
45484
  var symbol = getSymbolOfNode(node);
@@ -45670,9 +45689,11 @@ var ts;
45670
45689
  if (writing === void 0) { writing = false; }
45671
45690
  var getter = ts.getDeclarationOfKind(symbol, 171);
45672
45691
  var setter = ts.getDeclarationOfKind(symbol, 172);
45673
- var setterType = getAnnotatedAccessorType(setter);
45674
- if (writing && setterType) {
45675
- return instantiateTypeIfNeeded(setterType, symbol);
45692
+ if (writing) {
45693
+ var setterType_1 = getAnnotatedAccessorType(setter);
45694
+ if (setterType_1) {
45695
+ return instantiateTypeIfNeeded(setterType_1, symbol);
45696
+ }
45676
45697
  }
45677
45698
  if (getter && ts.isInJSFile(getter)) {
45678
45699
  var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
@@ -45684,6 +45705,7 @@ var ts;
45684
45705
  if (getterType) {
45685
45706
  return instantiateTypeIfNeeded(getterType, symbol);
45686
45707
  }
45708
+ var setterType = getAnnotatedAccessorType(setter);
45687
45709
  if (setterType) {
45688
45710
  return setterType;
45689
45711
  }
@@ -58415,16 +58437,18 @@ var ts;
58415
58437
  function isGenericTypeWithoutNullableConstraint(type) {
58416
58438
  return !!(type.flags & 465829888 && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304));
58417
58439
  }
58418
- function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) {
58440
+ function hasContextualTypeWithNoGenericTypes(node, checkMode) {
58419
58441
  var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
58420
58442
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
58421
- getContextualType(node, 8);
58443
+ (checkMode && checkMode & 32 ?
58444
+ getContextualType(node, 8)
58445
+ : getContextualType(node));
58422
58446
  return contextualType && !isGenericType(contextualType);
58423
58447
  }
58424
58448
  function getNarrowableTypeForReference(type, reference, checkMode) {
58425
58449
  var substituteConstraints = !(checkMode && checkMode & 2) &&
58426
58450
  someType(type, isGenericTypeWithUnionConstraint) &&
58427
- (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
58451
+ (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
58428
58452
  return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
58429
58453
  }
58430
58454
  function isExportOrExportExpression(location) {
@@ -58466,7 +58490,7 @@ var ts;
58466
58490
  var links = getNodeLinks(location);
58467
58491
  if (!(links.flags & 268435456)) {
58468
58492
  links.flags |= 268435456;
58469
- var parentType = getTypeForBindingElementParent(parent);
58493
+ var parentType = getTypeForBindingElementParent(parent, 0);
58470
58494
  links.flags &= ~268435456;
58471
58495
  if (parentType && parentType.flags & 1048576 && !(parent.kind === 163 && isSymbolAssigned(symbol))) {
58472
58496
  var pattern = declaration.parent;
@@ -59137,7 +59161,7 @@ var ts;
59137
59161
  var parent = declaration.parent.parent;
59138
59162
  var name = declaration.propertyName || declaration.name;
59139
59163
  var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
59140
- parent.kind !== 202 && parent.initializer && checkDeclarationInitializer(parent);
59164
+ parent.kind !== 202 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 : 0);
59141
59165
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
59142
59166
  return undefined;
59143
59167
  if (parent.name.kind === 201) {
@@ -65106,11 +65130,11 @@ var ts;
65106
65130
  }
65107
65131
  }
65108
65132
  function checkExpressionCached(node, checkMode) {
65133
+ if (checkMode && checkMode !== 0) {
65134
+ return checkExpression(node, checkMode);
65135
+ }
65109
65136
  var links = getNodeLinks(node);
65110
65137
  if (!links.resolvedType) {
65111
- if (checkMode && checkMode !== 0) {
65112
- return checkExpression(node, checkMode);
65113
- }
65114
65138
  var saveFlowLoopStart = flowLoopStart;
65115
65139
  var saveFlowTypeCache = flowTypeCache;
65116
65140
  flowLoopStart = flowLoopCount;
@@ -65127,10 +65151,12 @@ var ts;
65127
65151
  node.kind === 228 ||
65128
65152
  ts.isJSDocTypeAssertion(node);
65129
65153
  }
65130
- function checkDeclarationInitializer(declaration, contextualType) {
65154
+ function checkDeclarationInitializer(declaration, checkMode, contextualType) {
65131
65155
  var initializer = ts.getEffectiveInitializer(declaration);
65132
65156
  var type = getQuickTypeOfExpression(initializer) ||
65133
- (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
65157
+ (contextualType ?
65158
+ checkExpressionWithContextualType(initializer, contextualType, undefined, checkMode || 0)
65159
+ : checkExpressionCached(initializer, checkMode));
65134
65160
  return ts.isParameter(declaration) && declaration.name.kind === 201 &&
65135
65161
  isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
65136
65162
  padTupleType(type, declaration.name) : type;
@@ -67601,7 +67627,8 @@ var ts;
67601
67627
  checkComputedPropertyName(node.propertyName);
67602
67628
  }
67603
67629
  var parent = node.parent.parent;
67604
- var parentType = getTypeForBindingElementParent(parent);
67630
+ var parentCheckMode = node.dotDotDotToken ? 32 : 0;
67631
+ var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
67605
67632
  var name = node.propertyName || node.name;
67606
67633
  if (parentType && !ts.isBindingPattern(name)) {
67607
67634
  var exprType = getLiteralTypeFromPropertyName(name);
@@ -68565,7 +68592,7 @@ var ts;
68565
68592
  var declaration = catchClause.variableDeclaration;
68566
68593
  var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
68567
68594
  if (typeNode) {
68568
- var type = getTypeForVariableLikeDeclaration(declaration, false);
68595
+ var type = getTypeForVariableLikeDeclaration(declaration, false, 0);
68569
68596
  if (type && !(type.flags & 3)) {
68570
68597
  grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
68571
68598
  }
@@ -69559,7 +69586,7 @@ var ts;
69559
69586
  var isAmbientExternalModule = ts.isAmbientModule(node);
69560
69587
  var contextErrorMessage = isAmbientExternalModule
69561
69588
  ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
69562
- : 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;
69563
69590
  if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
69564
69591
  return;
69565
69592
  }
@@ -69840,7 +69867,7 @@ var ts;
69840
69867
  }
69841
69868
  }
69842
69869
  function checkImportDeclaration(node) {
69843
- 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)) {
69844
69871
  return;
69845
69872
  }
69846
69873
  if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
@@ -69871,7 +69898,7 @@ var ts;
69871
69898
  checkAssertClause(node);
69872
69899
  }
69873
69900
  function checkImportEqualsDeclaration(node) {
69874
- 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)) {
69875
69902
  return;
69876
69903
  }
69877
69904
  checkGrammarDecoratorsAndModifiers(node);
@@ -69905,7 +69932,7 @@ var ts;
69905
69932
  }
69906
69933
  }
69907
69934
  function checkExportDeclaration(node) {
69908
- 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)) {
69909
69936
  return;
69910
69937
  }
69911
69938
  if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
@@ -71023,7 +71050,7 @@ var ts;
71023
71050
  return errorType;
71024
71051
  }
71025
71052
  if (ts.isBindingPattern(node)) {
71026
- return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
71053
+ return getTypeForVariableLikeDeclaration(node.parent, true, 0) || errorType;
71027
71054
  }
71028
71055
  if (isInRightSideOfImportOrExportAssignment(node)) {
71029
71056
  var symbol = getSymbolAtLocation(node);
@@ -94349,9 +94376,9 @@ var ts;
94349
94376
  ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
94350
94377
  ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
94351
94378
  ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
94352
- 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,
94353
94380
  ts.Diagnostics.An_export_declaration_cannot_have_modifiers.code,
94354
- 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,
94355
94382
  ts.Diagnostics.An_import_declaration_cannot_have_modifiers.code,
94356
94383
  ts.Diagnostics.An_object_member_cannot_be_declared_optional.code,
94357
94384
  ts.Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code,
@@ -95249,7 +95276,7 @@ var ts;
95249
95276
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
95250
95277
  var isJs = sourceFile.scriptKind === 1 || sourceFile.scriptKind === 2;
95251
95278
  var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
95252
- var isPlainJs = isJs && !sourceFile.checkJsDirective && options.checkJs === undefined;
95279
+ var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs);
95253
95280
  var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
95254
95281
  var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4
95255
95282
  || sourceFile.scriptKind === 5 || isPlainJs || isCheckJs || sourceFile.scriptKind === 7);