typescript 4.6.0-dev.20220207 → 4.6.0-dev.20220211

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.20220207";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220211";
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."),
@@ -5294,6 +5294,7 @@ var ts;
5294
5294
  An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."),
5295
5295
  Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."),
5296
5296
  An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."),
5297
+ Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
5297
5298
  with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
5298
5299
  await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
5299
5300
  Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
@@ -5430,6 +5431,8 @@ var ts;
5430
5431
  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
5432
  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
5433
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
5434
+ 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."),
5435
+ 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
5436
  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
5437
  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
5438
  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),
@@ -6850,6 +6853,9 @@ var ts;
6850
6853
  Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
6851
6854
  Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
6852
6855
  Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
6856
+ Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
6857
+ Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
6858
+ Rename_param_tag_name_0_to_1: diag(95173, ts.DiagnosticCategory.Message, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
6853
6859
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
6854
6860
  Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
6855
6861
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -10516,6 +10522,10 @@ var ts;
10516
10522
  return undefined;
10517
10523
  }
10518
10524
  ts.getDeclarationOfKind = getDeclarationOfKind;
10525
+ function getDeclarationsOfKind(symbol, kind) {
10526
+ return ts.filter(symbol.declarations || ts.emptyArray, function (d) { return d.kind === kind; });
10527
+ }
10528
+ ts.getDeclarationsOfKind = getDeclarationsOfKind;
10519
10529
  function createSymbolTable(symbols) {
10520
10530
  var result = new ts.Map();
10521
10531
  if (symbols) {
@@ -10735,6 +10745,10 @@ var ts;
10735
10745
  return getSourceFileOfNode(module.valueDeclaration || getNonAugmentationDeclaration(module));
10736
10746
  }
10737
10747
  ts.getSourceFileOfModule = getSourceFileOfModule;
10748
+ function isPlainJsFile(file, checkJs) {
10749
+ return !!file && (file.scriptKind === 1 || file.scriptKind === 2) && !file.checkJsDirective && checkJs === undefined;
10750
+ }
10751
+ ts.isPlainJsFile = isPlainJsFile;
10738
10752
  function isStatementWithLocals(node) {
10739
10753
  switch (node.kind) {
10740
10754
  case 234:
@@ -39325,13 +39339,13 @@ var ts;
39325
39339
  else {
39326
39340
  var isEitherEnum = !!(target.flags & 384 || source.flags & 384);
39327
39341
  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
39342
+ var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
39343
+ : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
39332
39344
  : ts.Diagnostics.Duplicate_identifier_0;
39333
39345
  var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
39334
39346
  var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
39347
+ var isSourcePlainJs = ts.isPlainJsFile(sourceSymbolFile, compilerOptions.checkJs);
39348
+ var isTargetPlainJs = ts.isPlainJsFile(targetSymbolFile, compilerOptions.checkJs);
39335
39349
  var symbolName_1 = symbolToString(source);
39336
39350
  if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
39337
39351
  var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 ? sourceSymbolFile : targetSymbolFile;
@@ -39342,12 +39356,16 @@ var ts;
39342
39356
  var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
39343
39357
  return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
39344
39358
  });
39345
- addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
39346
- addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
39359
+ if (!isSourcePlainJs)
39360
+ addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
39361
+ if (!isTargetPlainJs)
39362
+ addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
39347
39363
  }
39348
39364
  else {
39349
- addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
39350
- addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
39365
+ if (!isSourcePlainJs)
39366
+ addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
39367
+ if (!isTargetPlainJs)
39368
+ addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
39351
39369
  }
39352
39370
  }
39353
39371
  return target;
@@ -39728,6 +39746,8 @@ var ts;
39728
39746
  useResult = result.flags & 262144
39729
39747
  ? lastLocation === location.type ||
39730
39748
  lastLocation.kind === 163 ||
39749
+ lastLocation.kind === 338 ||
39750
+ lastLocation.kind === 339 ||
39731
39751
  lastLocation.kind === 162
39732
39752
  : false;
39733
39753
  }
@@ -39916,9 +39936,9 @@ var ts;
39916
39936
  lastSelfReferenceLocation = location;
39917
39937
  }
39918
39938
  lastLocation = location;
39919
- location = ts.isJSDocTemplateTag(location) ?
39920
- ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
39921
- location.parent;
39939
+ location = ts.isJSDocTemplateTag(location) ? ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent :
39940
+ ts.isJSDocParameterTag(location) || ts.isJSDocReturnTag(location) ? ts.getHostSignatureFromJSDoc(location) || location.parent :
39941
+ location.parent;
39922
39942
  }
39923
39943
  if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
39924
39944
  result.isReferenced |= meaning;
@@ -40910,15 +40930,18 @@ var ts;
40910
40930
  return;
40911
40931
  }
40912
40932
  var host = ts.getJSDocHost(node);
40913
- if (host &&
40914
- ts.isExpressionStatement(host) &&
40915
- ts.isBinaryExpression(host.expression) &&
40916
- ts.getAssignmentDeclarationKind(host.expression) === 3) {
40933
+ if (host && ts.isExpressionStatement(host) && ts.isPrototypePropertyAssignment(host.expression)) {
40917
40934
  var symbol = getSymbolOfNode(host.expression.left);
40918
40935
  if (symbol) {
40919
40936
  return getDeclarationOfJSPrototypeContainer(symbol);
40920
40937
  }
40921
40938
  }
40939
+ if (host && ts.isFunctionExpression(host) && ts.isPrototypePropertyAssignment(host.parent) && ts.isExpressionStatement(host.parent.parent)) {
40940
+ var symbol = getSymbolOfNode(host.parent.left);
40941
+ if (symbol) {
40942
+ return getDeclarationOfJSPrototypeContainer(symbol);
40943
+ }
40944
+ }
40922
40945
  if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
40923
40946
  ts.isBinaryExpression(host.parent.parent) &&
40924
40947
  ts.getAssignmentDeclarationKind(host.parent.parent) === 6) {
@@ -44801,9 +44824,12 @@ var ts;
44801
44824
  function isErrorType(type) {
44802
44825
  return type === errorType || !!(type.flags & 1 && type.aliasSymbol);
44803
44826
  }
44804
- function getTypeForBindingElementParent(node) {
44827
+ function getTypeForBindingElementParent(node, checkMode) {
44828
+ if (checkMode !== 0) {
44829
+ return getTypeForVariableLikeDeclaration(node, false, checkMode);
44830
+ }
44805
44831
  var symbol = getSymbolOfNode(node);
44806
- return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
44832
+ return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false, checkMode);
44807
44833
  }
44808
44834
  function getRestType(source, properties, symbol) {
44809
44835
  source = filterType(source, function (t) { return !(t.flags & 98304); });
@@ -44908,7 +44934,8 @@ var ts;
44908
44934
  return type.flags & (128 | 256) ? "" + type.value : undefined;
44909
44935
  }
44910
44936
  function getTypeForBindingElement(declaration) {
44911
- var parentType = getTypeForBindingElementParent(declaration.parent.parent);
44937
+ var checkMode = declaration.dotDotDotToken ? 32 : 0;
44938
+ var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
44912
44939
  return parentType && getBindingElementTypeFromParentType(declaration, parentType);
44913
44940
  }
44914
44941
  function getBindingElementTypeFromParentType(declaration, parentType) {
@@ -44968,9 +44995,9 @@ var ts;
44968
44995
  return type;
44969
44996
  }
44970
44997
  if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
44971
- return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ? getNonUndefinedType(type) : type;
44998
+ return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration, 0)) & 32768) ? getNonUndefinedType(type) : type;
44972
44999
  }
44973
- return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2));
45000
+ return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0)], 2));
44974
45001
  }
44975
45002
  function getTypeForDeclarationFromJSDocComment(declaration) {
44976
45003
  var jsdocType = ts.getJSDocType(declaration);
@@ -44992,9 +45019,9 @@ var ts;
44992
45019
  if (isOptional === void 0) { isOptional = true; }
44993
45020
  return strictNullChecks && isOptional ? getOptionalType(type, isProperty) : type;
44994
45021
  }
44995
- function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
45022
+ function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) {
44996
45023
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242) {
44997
- var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
45024
+ var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, checkMode)));
44998
45025
  return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType;
44999
45026
  }
45000
45027
  if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243) {
@@ -45037,12 +45064,9 @@ var ts;
45037
45064
  }
45038
45065
  }
45039
45066
  if (ts.isInJSFile(declaration)) {
45040
- var typeTag = ts.getJSDocType(func);
45041
- if (typeTag && ts.isFunctionTypeNode(typeTag)) {
45042
- var signature = getSignatureFromDeclaration(typeTag);
45043
- var pos = func.parameters.indexOf(declaration);
45044
- return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
45045
- }
45067
+ var type_1 = getParameterTypeOfTypeTag(func, declaration);
45068
+ if (type_1)
45069
+ return type_1;
45046
45070
  }
45047
45071
  var type = declaration.symbol.escapedName === "this" ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
45048
45072
  if (type) {
@@ -45056,7 +45080,7 @@ var ts;
45056
45080
  return containerObjectType;
45057
45081
  }
45058
45082
  }
45059
- var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
45083
+ var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration, checkMode));
45060
45084
  return addOptionality(type, isProperty, isOptional);
45061
45085
  }
45062
45086
  if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
@@ -45389,7 +45413,7 @@ var ts;
45389
45413
  function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
45390
45414
  if (element.initializer) {
45391
45415
  var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType;
45392
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
45416
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0, contextualType)));
45393
45417
  }
45394
45418
  if (ts.isBindingPattern(element.name)) {
45395
45419
  return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
@@ -45455,7 +45479,7 @@ var ts;
45455
45479
  : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
45456
45480
  }
45457
45481
  function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
45458
- return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors);
45482
+ return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true, 0), declaration, reportErrors);
45459
45483
  }
45460
45484
  function isGlobalSymbolConstructor(node) {
45461
45485
  var symbol = getSymbolOfNode(node);
@@ -45534,8 +45558,8 @@ var ts;
45534
45558
  if (typeNode === undefined) {
45535
45559
  return useUnknownInCatchVariables ? unknownType : anyType;
45536
45560
  }
45537
- var type_1 = getTypeOfNode(typeNode);
45538
- return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
45561
+ var type_2 = getTypeOfNode(typeNode);
45562
+ return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
45539
45563
  }
45540
45564
  if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
45541
45565
  if (!declaration.statements.length) {
@@ -45666,9 +45690,11 @@ var ts;
45666
45690
  if (writing === void 0) { writing = false; }
45667
45691
  var getter = ts.getDeclarationOfKind(symbol, 171);
45668
45692
  var setter = ts.getDeclarationOfKind(symbol, 172);
45669
- var setterType = getAnnotatedAccessorType(setter);
45670
- if (writing && setterType) {
45671
- return instantiateTypeIfNeeded(setterType, symbol);
45693
+ if (writing) {
45694
+ var setterType_1 = getAnnotatedAccessorType(setter);
45695
+ if (setterType_1) {
45696
+ return instantiateTypeIfNeeded(setterType_1, symbol);
45697
+ }
45672
45698
  }
45673
45699
  if (getter && ts.isInJSFile(getter)) {
45674
45700
  var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
@@ -45680,6 +45706,7 @@ var ts;
45680
45706
  if (getterType) {
45681
45707
  return instantiateTypeIfNeeded(getterType, symbol);
45682
45708
  }
45709
+ var setterType = getAnnotatedAccessorType(setter);
45683
45710
  if (setterType) {
45684
45711
  return setterType;
45685
45712
  }
@@ -45747,11 +45774,11 @@ var ts;
45747
45774
  return errorType;
45748
45775
  }
45749
45776
  var exportEquals = getMergedSymbol(symbol.exports.get("export="));
45750
- var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
45777
+ var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
45751
45778
  if (!popTypeResolution()) {
45752
45779
  return reportCircularityError(symbol);
45753
45780
  }
45754
- return type_2;
45781
+ return type_3;
45755
45782
  }
45756
45783
  }
45757
45784
  var type = createObjectType(16, symbol);
@@ -45815,6 +45842,31 @@ var ts;
45815
45842
  }
45816
45843
  return links.type;
45817
45844
  }
45845
+ function getWriteTypeOfSymbolWithDeferredType(symbol) {
45846
+ var links = getSymbolLinks(symbol);
45847
+ if (!links.writeType && links.deferralWriteConstituents) {
45848
+ ts.Debug.assertIsDefined(links.deferralParent);
45849
+ ts.Debug.assertIsDefined(links.deferralConstituents);
45850
+ links.writeType = links.deferralParent.flags & 1048576 ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
45851
+ }
45852
+ return links.writeType;
45853
+ }
45854
+ function getWriteTypeOfSymbol(symbol) {
45855
+ var checkFlags = ts.getCheckFlags(symbol);
45856
+ if (checkFlags & 65536) {
45857
+ var writeType = getWriteTypeOfSymbolWithDeferredType(symbol);
45858
+ if (writeType) {
45859
+ return writeType;
45860
+ }
45861
+ }
45862
+ if (symbol.flags & 33554432) {
45863
+ var writeType = symbol.writeType;
45864
+ if (writeType) {
45865
+ return writeType;
45866
+ }
45867
+ }
45868
+ return getSetAccessorTypeOfSymbol(symbol);
45869
+ }
45818
45870
  function getSetAccessorTypeOfSymbol(symbol) {
45819
45871
  if (symbol.flags & 98304) {
45820
45872
  var type = getTypeOfSetAccessor(symbol);
@@ -47659,10 +47711,10 @@ var ts;
47659
47711
  var baseTypes = [];
47660
47712
  var different = false;
47661
47713
  for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
47662
- var type_3 = types_7[_i];
47663
- var baseType = getBaseConstraint(type_3);
47714
+ var type_4 = types_7[_i];
47715
+ var baseType = getBaseConstraint(type_4);
47664
47716
  if (baseType) {
47665
- if (baseType !== type_3) {
47717
+ if (baseType !== type_4) {
47666
47718
  different = true;
47667
47719
  }
47668
47720
  baseTypes.push(baseType);
@@ -47868,6 +47920,7 @@ var ts;
47868
47920
  var firstType;
47869
47921
  var nameType;
47870
47922
  var propTypes = [];
47923
+ var writeTypes;
47871
47924
  var firstValueDeclaration;
47872
47925
  var hasNonUniformValueDeclaration = false;
47873
47926
  for (var _d = 0, props_1 = props; _d < props_1.length; _d++) {
@@ -47884,6 +47937,10 @@ var ts;
47884
47937
  firstType = type;
47885
47938
  nameType = getSymbolLinks(prop).nameType;
47886
47939
  }
47940
+ var writeType = getWriteTypeOfSymbol(prop);
47941
+ if (writeTypes || writeType !== type) {
47942
+ writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType);
47943
+ }
47887
47944
  else if (type !== firstType) {
47888
47945
  checkFlags |= 64;
47889
47946
  }
@@ -47910,9 +47967,13 @@ var ts;
47910
47967
  result.checkFlags |= 65536;
47911
47968
  result.deferralParent = containingType;
47912
47969
  result.deferralConstituents = propTypes;
47970
+ result.deferralWriteConstituents = writeTypes;
47913
47971
  }
47914
47972
  else {
47915
47973
  result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
47974
+ if (writeTypes) {
47975
+ result.writeType = isUnion ? getUnionType(writeTypes) : getIntersectionType(writeTypes);
47976
+ }
47916
47977
  }
47917
47978
  return result;
47918
47979
  }
@@ -48263,6 +48324,13 @@ var ts;
48263
48324
  var typeTag = ts.getJSDocTypeTag(node);
48264
48325
  return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
48265
48326
  }
48327
+ function getParameterTypeOfTypeTag(func, parameter) {
48328
+ var signature = getSignatureOfTypeTag(func);
48329
+ if (!signature)
48330
+ return undefined;
48331
+ var pos = func.parameters.indexOf(parameter);
48332
+ return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
48333
+ }
48266
48334
  function getReturnTypeOfTypeTag(node) {
48267
48335
  var signature = getSignatureOfTypeTag(node);
48268
48336
  return signature && getReturnTypeOfSignature(signature);
@@ -48920,7 +48988,7 @@ var ts;
48920
48988
  }
48921
48989
  function getImpliedConstraint(type, checkNode, extendsNode) {
48922
48990
  return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
48923
- getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
48991
+ getActualTypeVariable(getTypeFromTypeNode(checkNode)) === getActualTypeVariable(type) ? getTypeFromTypeNode(extendsNode) :
48924
48992
  undefined;
48925
48993
  }
48926
48994
  function getConditionalFlowTypeOfType(type, node) {
@@ -58377,16 +58445,18 @@ var ts;
58377
58445
  function isGenericTypeWithoutNullableConstraint(type) {
58378
58446
  return !!(type.flags & 465829888 && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304));
58379
58447
  }
58380
- function hasNonBindingPatternContextualTypeWithNoGenericTypes(node) {
58448
+ function hasContextualTypeWithNoGenericTypes(node, checkMode) {
58381
58449
  var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
58382
58450
  !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
58383
- getContextualType(node, 8);
58451
+ (checkMode && checkMode & 32 ?
58452
+ getContextualType(node, 8)
58453
+ : getContextualType(node));
58384
58454
  return contextualType && !isGenericType(contextualType);
58385
58455
  }
58386
58456
  function getNarrowableTypeForReference(type, reference, checkMode) {
58387
58457
  var substituteConstraints = !(checkMode && checkMode & 2) &&
58388
58458
  someType(type, isGenericTypeWithUnionConstraint) &&
58389
- (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
58459
+ (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
58390
58460
  return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
58391
58461
  }
58392
58462
  function isExportOrExportExpression(location) {
@@ -58428,7 +58498,7 @@ var ts;
58428
58498
  var links = getNodeLinks(location);
58429
58499
  if (!(links.flags & 268435456)) {
58430
58500
  links.flags |= 268435456;
58431
- var parentType = getTypeForBindingElementParent(parent);
58501
+ var parentType = getTypeForBindingElementParent(parent, 0);
58432
58502
  links.flags &= ~268435456;
58433
58503
  if (parentType && parentType.flags & 1048576 && !(parent.kind === 163 && isSymbolAssigned(symbol))) {
58434
58504
  var pattern = declaration.parent;
@@ -59099,7 +59169,7 @@ var ts;
59099
59169
  var parent = declaration.parent.parent;
59100
59170
  var name = declaration.propertyName || declaration.name;
59101
59171
  var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
59102
- parent.kind !== 202 && parent.initializer && checkDeclarationInitializer(parent);
59172
+ parent.kind !== 202 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 32 : 0);
59103
59173
  if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
59104
59174
  return undefined;
59105
59175
  if (parent.name.kind === 201) {
@@ -61014,7 +61084,7 @@ var ts;
61014
61084
  error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
61015
61085
  return errorType;
61016
61086
  }
61017
- propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getSetAccessorTypeOfSymbol(prop) : getTypeOfSymbol(prop);
61087
+ propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getWriteTypeOfSymbol(prop) : getTypeOfSymbol(prop);
61018
61088
  }
61019
61089
  return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode);
61020
61090
  }
@@ -63106,8 +63176,8 @@ var ts;
63106
63176
  if (hasDefaultOnly && type && !isErrorType(type)) {
63107
63177
  var synthType = type;
63108
63178
  if (!synthType.defaultOnlyType) {
63109
- var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
63110
- synthType.defaultOnlyType = type_4;
63179
+ var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
63180
+ synthType.defaultOnlyType = type_5;
63111
63181
  }
63112
63182
  return synthType.defaultOnlyType;
63113
63183
  }
@@ -63773,11 +63843,11 @@ var ts;
63773
63843
  var operandType = getTypeOfExpression(node.expression.expression);
63774
63844
  var witnesses = getSwitchClauseTypeOfWitnesses(node, false);
63775
63845
  var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true);
63776
- var type_5 = getBaseConstraintOfType(operandType) || operandType;
63777
- if (type_5.flags & 3) {
63846
+ var type_6 = getBaseConstraintOfType(operandType) || operandType;
63847
+ if (type_6.flags & 3) {
63778
63848
  return (556800 & notEqualFacts_1) === 556800;
63779
63849
  }
63780
- return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
63850
+ return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
63781
63851
  }
63782
63852
  var type = getTypeOfExpression(node.expression);
63783
63853
  if (!isLiteralType(type)) {
@@ -65068,11 +65138,11 @@ var ts;
65068
65138
  }
65069
65139
  }
65070
65140
  function checkExpressionCached(node, checkMode) {
65141
+ if (checkMode && checkMode !== 0) {
65142
+ return checkExpression(node, checkMode);
65143
+ }
65071
65144
  var links = getNodeLinks(node);
65072
65145
  if (!links.resolvedType) {
65073
- if (checkMode && checkMode !== 0) {
65074
- return checkExpression(node, checkMode);
65075
- }
65076
65146
  var saveFlowLoopStart = flowLoopStart;
65077
65147
  var saveFlowTypeCache = flowTypeCache;
65078
65148
  flowLoopStart = flowLoopCount;
@@ -65089,10 +65159,12 @@ var ts;
65089
65159
  node.kind === 228 ||
65090
65160
  ts.isJSDocTypeAssertion(node);
65091
65161
  }
65092
- function checkDeclarationInitializer(declaration, contextualType) {
65162
+ function checkDeclarationInitializer(declaration, checkMode, contextualType) {
65093
65163
  var initializer = ts.getEffectiveInitializer(declaration);
65094
65164
  var type = getQuickTypeOfExpression(initializer) ||
65095
- (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
65165
+ (contextualType ?
65166
+ checkExpressionWithContextualType(initializer, contextualType, undefined, checkMode || 0)
65167
+ : checkExpressionCached(initializer, checkMode));
65096
65168
  return ts.isParameter(declaration) && declaration.name.kind === 201 &&
65097
65169
  isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
65098
65170
  padTupleType(type, declaration.name) : type;
@@ -65660,6 +65732,7 @@ var ts;
65660
65732
  }
65661
65733
  }
65662
65734
  checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
65735
+ checkUnmatchedJSDocParameters(node);
65663
65736
  ts.forEach(node.parameters, checkParameter);
65664
65737
  if (node.type) {
65665
65738
  checkSourceElement(node.type);
@@ -66941,28 +67014,6 @@ var ts;
66941
67014
  }
66942
67015
  function checkJSDocParameterTag(node) {
66943
67016
  checkSourceElement(node.typeExpression);
66944
- if (!ts.getParameterSymbolFromJSDoc(node)) {
66945
- var decl = ts.getHostSignatureFromJSDoc(node);
66946
- if (decl) {
66947
- var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
66948
- if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
66949
- return;
66950
- }
66951
- if (!containsArgumentsReference(decl)) {
66952
- if (ts.isQualifiedName(node.name)) {
66953
- error(node.name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(node.name), ts.entityNameToString(node.name.left));
66954
- }
66955
- else {
66956
- error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
66957
- }
66958
- }
66959
- else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
66960
- node.typeExpression && node.typeExpression.type &&
66961
- !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
66962
- error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 160 ? node.name.right : node.name));
66963
- }
66964
- }
66965
- }
66966
67017
  }
66967
67018
  function checkJSDocPropertyTag(node) {
66968
67019
  checkSourceElement(node.typeExpression);
@@ -67563,7 +67614,8 @@ var ts;
67563
67614
  checkComputedPropertyName(node.propertyName);
67564
67615
  }
67565
67616
  var parent = node.parent.parent;
67566
- var parentType = getTypeForBindingElementParent(parent);
67617
+ var parentCheckMode = node.dotDotDotToken ? 32 : 0;
67618
+ var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
67567
67619
  var name = node.propertyName || node.name;
67568
67620
  if (parentType && !ts.isBindingPattern(name)) {
67569
67621
  var exprType = getLiteralTypeFromPropertyName(name);
@@ -68527,7 +68579,7 @@ var ts;
68527
68579
  var declaration = catchClause.variableDeclaration;
68528
68580
  var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
68529
68581
  if (typeNode) {
68530
- var type = getTypeForVariableLikeDeclaration(declaration, false);
68582
+ var type = getTypeForVariableLikeDeclaration(declaration, false, 0);
68531
68583
  if (type && !(type.flags & 3)) {
68532
68584
  grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
68533
68585
  }
@@ -68645,6 +68697,45 @@ var ts;
68645
68697
  error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]);
68646
68698
  }
68647
68699
  }
68700
+ function checkUnmatchedJSDocParameters(node) {
68701
+ var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
68702
+ if (!ts.length(jsdocParameters))
68703
+ return;
68704
+ var isJs = ts.isInJSFile(node);
68705
+ var parameters = new ts.Set();
68706
+ var excludedParameters = new ts.Set();
68707
+ ts.forEach(node.parameters, function (_a, index) {
68708
+ var name = _a.name;
68709
+ if (ts.isIdentifier(name)) {
68710
+ parameters.add(name.escapedText);
68711
+ }
68712
+ if (ts.isBindingPattern(name)) {
68713
+ excludedParameters.add(index);
68714
+ }
68715
+ });
68716
+ var containsArguments = containsArgumentsReference(node);
68717
+ if (containsArguments) {
68718
+ var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
68719
+ if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
68720
+ lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
68721
+ errorOrSuggestion(isJs, lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
68722
+ }
68723
+ }
68724
+ else {
68725
+ ts.forEach(jsdocParameters, function (_a, index) {
68726
+ var name = _a.name;
68727
+ if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
68728
+ return;
68729
+ }
68730
+ if (ts.isQualifiedName(name)) {
68731
+ errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
68732
+ }
68733
+ else {
68734
+ errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
68735
+ }
68736
+ });
68737
+ }
68738
+ }
68648
68739
  function checkTypeParameters(typeParameterDeclarations) {
68649
68740
  if (typeParameterDeclarations) {
68650
68741
  var seenDefault = false;
@@ -69521,7 +69612,7 @@ var ts;
69521
69612
  var isAmbientExternalModule = ts.isAmbientModule(node);
69522
69613
  var contextErrorMessage = isAmbientExternalModule
69523
69614
  ? 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;
69615
+ : ts.Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module;
69525
69616
  if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
69526
69617
  return;
69527
69618
  }
@@ -69722,6 +69813,9 @@ var ts;
69722
69813
  var name = ts.idText(node.kind === 269 ? node.propertyName || node.name : node.name);
69723
69814
  addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
69724
69815
  }
69816
+ if (isType && node.kind === 264 && ts.hasEffectiveModifier(node, 1)) {
69817
+ error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
69818
+ }
69725
69819
  break;
69726
69820
  }
69727
69821
  case 274: {
@@ -69802,7 +69896,7 @@ var ts;
69802
69896
  }
69803
69897
  }
69804
69898
  function checkImportDeclaration(node) {
69805
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
69899
+ 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
69900
  return;
69807
69901
  }
69808
69902
  if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
@@ -69833,7 +69927,7 @@ var ts;
69833
69927
  checkAssertClause(node);
69834
69928
  }
69835
69929
  function checkImportEqualsDeclaration(node) {
69836
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
69930
+ 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
69931
  return;
69838
69932
  }
69839
69933
  checkGrammarDecoratorsAndModifiers(node);
@@ -69867,7 +69961,7 @@ var ts;
69867
69961
  }
69868
69962
  }
69869
69963
  function checkExportDeclaration(node) {
69870
- if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
69964
+ 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
69965
  return;
69872
69966
  }
69873
69967
  if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
@@ -70985,7 +71079,7 @@ var ts;
70985
71079
  return errorType;
70986
71080
  }
70987
71081
  if (ts.isBindingPattern(node)) {
70988
- return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
71082
+ return getTypeForVariableLikeDeclaration(node.parent, true, 0) || errorType;
70989
71083
  }
70990
71084
  if (isInRightSideOfImportOrExportAssignment(node)) {
70991
71085
  var symbol = getSymbolAtLocation(node);
@@ -94311,9 +94405,9 @@ var ts;
94311
94405
  ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
94312
94406
  ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
94313
94407
  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,
94408
+ ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
94315
94409
  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,
94410
+ ts.Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module.code,
94317
94411
  ts.Diagnostics.An_import_declaration_cannot_have_modifiers.code,
94318
94412
  ts.Diagnostics.An_object_member_cannot_be_declared_optional.code,
94319
94413
  ts.Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element.code,
@@ -95211,7 +95305,7 @@ var ts;
95211
95305
  ts.Debug.assert(!!sourceFile.bindDiagnostics);
95212
95306
  var isJs = sourceFile.scriptKind === 1 || sourceFile.scriptKind === 2;
95213
95307
  var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options);
95214
- var isPlainJs = isJs && !sourceFile.checkJsDirective && options.checkJs === undefined;
95308
+ var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs);
95215
95309
  var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
95216
95310
  var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4
95217
95311
  || sourceFile.scriptKind === 5 || isPlainJs || isCheckJs || sourceFile.scriptKind === 7);