@typescript-deploys/pr-build 5.6.0-pr-59352-2 → 5.6.0-pr-59217-23

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
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.6";
21
- var version = `${versionMajorMinor}.0-insiders.20240719`;
21
+ var version = `${versionMajorMinor}.0-insiders.20240722`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -6124,6 +6124,7 @@ var Diagnostics = {
6124
6124
  Octal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_If_this_was_intended_as_an_escape_sequence_use_the_syntax_0_instead: diag(1536, 1 /* Error */, "Octal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_If_this_was_intended__1536", "Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '{0}' instead."),
6125
6125
  Decimal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class: diag(1537, 1 /* Error */, "Decimal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_1537", "Decimal escape sequences and backreferences are not allowed in a character class."),
6126
6126
  Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set: diag(1538, 1 /* Error */, "Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_se_1538", "Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set."),
6127
+ A_bigint_literal_cannot_be_used_as_a_property_name: diag(1539, 1 /* Error */, "A_bigint_literal_cannot_be_used_as_a_property_name_1539", "A 'bigint' literal cannot be used as a property name."),
6127
6128
  The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
6128
6129
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
6129
6130
  Call_signature_return_types_0_and_1_are_incompatible: diag(
@@ -6690,6 +6691,11 @@ var Diagnostics = {
6690
6691
  Import_0_conflicts_with_global_value_used_in_this_file_so_must_be_declared_with_a_type_only_import_when_isolatedModules_is_enabled: diag(2866, 1 /* Error */, "Import_0_conflicts_with_global_value_used_in_this_file_so_must_be_declared_with_a_type_only_import_w_2866", "Import '{0}' conflicts with global value used in this file, so must be declared with a type-only import when 'isolatedModules' is enabled."),
6691
6692
  Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun: diag(2867, 1 /* Error */, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_2867", "Cannot find name '{0}'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun`."),
6692
6693
  Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_and_then_add_bun_to_the_types_field_in_your_tsconfig: diag(2868, 1 /* Error */, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_2868", "Cannot find name '{0}'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types/bun` and then add 'bun' to the types field in your tsconfig."),
6694
+ Right_operand_of_is_unreachable_because_the_left_operand_is_never_nullish: diag(2869, 1 /* Error */, "Right_operand_of_is_unreachable_because_the_left_operand_is_never_nullish_2869", "Right operand of ?? is unreachable because the left operand is never nullish."),
6695
+ This_binary_expression_is_never_nullish_Are_you_missing_parentheses: diag(2870, 1 /* Error */, "This_binary_expression_is_never_nullish_Are_you_missing_parentheses_2870", "This binary expression is never nullish. Are you missing parentheses?"),
6696
+ This_expression_is_always_nullish: diag(2871, 1 /* Error */, "This_expression_is_always_nullish_2871", "This expression is always nullish."),
6697
+ This_kind_of_expression_is_always_truthy: diag(2872, 1 /* Error */, "This_kind_of_expression_is_always_truthy_2872", "This kind of expression is always truthy."),
6698
+ This_kind_of_expression_is_always_falsy: diag(2873, 1 /* Error */, "This_kind_of_expression_is_always_falsy_2873", "This kind of expression is always falsy."),
6693
6699
  Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
6694
6700
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
6695
6701
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -7365,9 +7371,11 @@ var Diagnostics = {
7365
7371
  Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6717, 3 /* Message */, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6717", "Require undeclared properties from index signatures to use element accesses."),
7366
7372
  Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types: diag(6718, 3 /* Message */, "Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types_6718", "Specify emit/checking behavior for imports that are only used for types."),
7367
7373
  Require_sufficient_annotation_on_exports_so_other_tools_can_trivially_generate_declaration_files: diag(6719, 3 /* Message */, "Require_sufficient_annotation_on_exports_so_other_tools_can_trivially_generate_declaration_files_6719", "Require sufficient annotation on exports so other tools can trivially generate declaration files."),
7374
+ Built_in_iterators_are_instantiated_with_a_TReturn_type_of_undefined_instead_of_any: diag(6720, 3 /* Message */, "Built_in_iterators_are_instantiated_with_a_TReturn_type_of_undefined_instead_of_any_6720", "Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'."),
7368
7375
  Default_catch_clause_variables_as_unknown_instead_of_any: diag(6803, 3 /* Message */, "Default_catch_clause_variables_as_unknown_instead_of_any_6803", "Default catch clause variables as 'unknown' instead of 'any'."),
7369
7376
  Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting: diag(6804, 3 /* Message */, "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804", "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."),
7370
7377
  Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported: diag(6805, 3 /* Message */, "Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported_6805", "Disable full type checking (only critical parse and emit errors will be reported)."),
7378
+ Check_side_effect_imports: diag(6806, 3 /* Message */, "Check_side_effect_imports_6806", "Check side effect imports."),
7371
7379
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
7372
7380
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
7373
7381
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -13532,6 +13540,7 @@ function tryGetTextOfPropertyName(name) {
13532
13540
  return ((_a = name.emitNode) == null ? void 0 : _a.autoGenerate) ? void 0 : name.escapedText;
13533
13541
  case 11 /* StringLiteral */:
13534
13542
  case 9 /* NumericLiteral */:
13543
+ case 10 /* BigIntLiteral */:
13535
13544
  case 15 /* NoSubstitutionTemplateLiteral */:
13536
13545
  return escapeLeadingUnderscores(name.text);
13537
13546
  case 167 /* ComputedPropertyName */:
@@ -15496,6 +15505,7 @@ function getPropertyNameForPropertyNameNode(name) {
15496
15505
  case 11 /* StringLiteral */:
15497
15506
  case 15 /* NoSubstitutionTemplateLiteral */:
15498
15507
  case 9 /* NumericLiteral */:
15508
+ case 10 /* BigIntLiteral */:
15499
15509
  return escapeLeadingUnderscores(name.text);
15500
15510
  case 167 /* ComputedPropertyName */:
15501
15511
  const nameExpression = name.expression;
@@ -17795,6 +17805,12 @@ var computedOptions = createComputedCompilerOptions({
17795
17805
  return getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
17796
17806
  }
17797
17807
  },
17808
+ strictBuiltinIteratorReturn: {
17809
+ dependencies: ["strict"],
17810
+ computeValue: (compilerOptions) => {
17811
+ return getStrictOptionValue(compilerOptions, "strictBuiltinIteratorReturn");
17812
+ }
17813
+ },
17798
17814
  alwaysStrict: {
17799
17815
  dependencies: ["strict"],
17800
17816
  computeValue: (compilerOptions) => {
@@ -19467,6 +19483,10 @@ function hasInferredType(node) {
19467
19483
  return false;
19468
19484
  }
19469
19485
  }
19486
+ function isSideEffectImport(node) {
19487
+ const ancestor = findAncestor(node, isImportDeclaration);
19488
+ return !!ancestor && !ancestor.importClause;
19489
+ }
19470
19490
 
19471
19491
  // src/compiler/factory/baseNodeFactory.ts
19472
19492
  function createBaseNodeFactory() {
@@ -29055,13 +29075,13 @@ var Parser;
29055
29075
  return createIdentifier(tokenIsIdentifierOrKeyword(token()));
29056
29076
  }
29057
29077
  function isLiteralPropertyName() {
29058
- return tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */ || token() === 9 /* NumericLiteral */;
29078
+ return tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */ || token() === 9 /* NumericLiteral */ || token() === 10 /* BigIntLiteral */;
29059
29079
  }
29060
29080
  function isImportAttributeName2() {
29061
29081
  return tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */;
29062
29082
  }
29063
29083
  function parsePropertyNameWorker(allowComputedPropertyNames) {
29064
- if (token() === 11 /* StringLiteral */ || token() === 9 /* NumericLiteral */) {
29084
+ if (token() === 11 /* StringLiteral */ || token() === 9 /* NumericLiteral */ || token() === 10 /* BigIntLiteral */) {
29065
29085
  const node = parseLiteralNode();
29066
29086
  node.text = internIdentifier(node.text);
29067
29087
  return node;
@@ -33288,7 +33308,7 @@ var Parser;
33288
33308
  if (isIndexSignature()) {
33289
33309
  return parseIndexSignatureDeclaration(pos, hasJSDoc, modifiers);
33290
33310
  }
33291
- if (tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */ || token() === 9 /* NumericLiteral */ || token() === 42 /* AsteriskToken */ || token() === 23 /* OpenBracketToken */) {
33311
+ if (tokenIsIdentifierOrKeyword(token()) || token() === 11 /* StringLiteral */ || token() === 9 /* NumericLiteral */ || token() === 10 /* BigIntLiteral */ || token() === 42 /* AsteriskToken */ || token() === 23 /* OpenBracketToken */) {
33292
33312
  const isAmbient = some(modifiers, isDeclareModifier);
33293
33313
  if (isAmbient) {
33294
33314
  for (const m of modifiers) {
@@ -35604,6 +35624,7 @@ var libEntries = [
35604
35624
  ["esnext.array", "lib.esnext.array.d.ts"],
35605
35625
  ["esnext.regexp", "lib.esnext.regexp.d.ts"],
35606
35626
  ["esnext.string", "lib.esnext.string.d.ts"],
35627
+ ["esnext.iterator", "lib.esnext.iterator.d.ts"],
35607
35628
  ["decorators", "lib.decorators.d.ts"],
35608
35629
  ["decorators.legacy", "lib.decorators.legacy.d.ts"]
35609
35630
  ];
@@ -36255,6 +36276,16 @@ var commandOptionsWithoutBuild = [
36255
36276
  description: Diagnostics.Check_for_class_properties_that_are_declared_but_not_set_in_the_constructor,
36256
36277
  defaultValueDescription: Diagnostics.false_unless_strict_is_set
36257
36278
  },
36279
+ {
36280
+ name: "strictBuiltinIteratorReturn",
36281
+ type: "boolean",
36282
+ affectsSemanticDiagnostics: true,
36283
+ affectsBuildInfo: true,
36284
+ strictFlag: true,
36285
+ category: Diagnostics.Type_Checking,
36286
+ description: Diagnostics.Built_in_iterators_are_instantiated_with_a_TReturn_type_of_undefined_instead_of_any,
36287
+ defaultValueDescription: Diagnostics.false_unless_strict_is_set
36288
+ },
36258
36289
  {
36259
36290
  name: "noImplicitThis",
36260
36291
  type: "boolean",
@@ -36530,6 +36561,15 @@ var commandOptionsWithoutBuild = [
36530
36561
  category: Diagnostics.Modules,
36531
36562
  description: Diagnostics.Conditions_to_set_in_addition_to_the_resolver_specific_defaults_when_resolving_imports
36532
36563
  },
36564
+ {
36565
+ name: "noUncheckedSideEffectImports",
36566
+ type: "boolean",
36567
+ affectsSemanticDiagnostics: true,
36568
+ affectsBuildInfo: true,
36569
+ category: Diagnostics.Modules,
36570
+ description: Diagnostics.Check_side_effect_imports,
36571
+ defaultValueDescription: false
36572
+ },
36533
36573
  // Source Maps
36534
36574
  {
36535
36575
  name: "sourceRoot",
@@ -45282,10 +45322,12 @@ function createTypeChecker(host) {
45282
45322
  var strictFunctionTypes = getStrictOptionValue(compilerOptions, "strictFunctionTypes");
45283
45323
  var strictBindCallApply = getStrictOptionValue(compilerOptions, "strictBindCallApply");
45284
45324
  var strictPropertyInitialization = getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
45325
+ var strictBuiltinIteratorReturn = getStrictOptionValue(compilerOptions, "strictBuiltinIteratorReturn");
45285
45326
  var noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
45286
45327
  var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
45287
45328
  var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
45288
45329
  var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes;
45330
+ var noUncheckedSideEffectImports = !!compilerOptions.noUncheckedSideEffectImports;
45289
45331
  var checkBinaryExpression = createCheckBinaryExpression();
45290
45332
  var emitResolver = createResolver();
45291
45333
  var nodeBuilder = createNodeBuilder();
@@ -45614,13 +45656,13 @@ function createTypeChecker(host) {
45614
45656
  /*reportErrors*/
45615
45657
  false
45616
45658
  ),
45617
- getAsyncIterableType: () => {
45659
+ getAnyAsyncIterableType: () => {
45618
45660
  const type = getGlobalAsyncIterableType(
45619
45661
  /*reportErrors*/
45620
45662
  false
45621
45663
  );
45622
45664
  if (type === emptyGenericType) return void 0;
45623
- return type;
45665
+ return createTypeReference(type, [anyType, anyType, anyType]);
45624
45666
  },
45625
45667
  isSymbolAccessible,
45626
45668
  isArrayType,
@@ -46092,8 +46134,6 @@ function createTypeChecker(host) {
46092
46134
  }
46093
46135
  };
46094
46136
  var anyIterationTypes = createIterationTypes(anyType, anyType, anyType);
46095
- var anyIterationTypesExceptNext = createIterationTypes(anyType, anyType, unknownType);
46096
- var defaultIterationTypes = createIterationTypes(neverType, anyType, undefinedType);
46097
46137
  var asyncIterationTypesResolver = {
46098
46138
  iterableCacheKey: "iterationTypesOfAsyncIterable",
46099
46139
  iteratorCacheKey: "iterationTypesOfAsyncIterator",
@@ -46101,6 +46141,7 @@ function createTypeChecker(host) {
46101
46141
  getGlobalIteratorType: getGlobalAsyncIteratorType,
46102
46142
  getGlobalIterableType: getGlobalAsyncIterableType,
46103
46143
  getGlobalIterableIteratorType: getGlobalAsyncIterableIteratorType,
46144
+ getGlobalBuiltinIteratorType: getGlobalBuiltinAsyncIteratorType,
46104
46145
  getGlobalGeneratorType: getGlobalAsyncGeneratorType,
46105
46146
  resolveIterationType: (type, errorNode) => getAwaitedType(type, errorNode, Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member),
46106
46147
  mustHaveANextMethodDiagnostic: Diagnostics.An_async_iterator_must_have_a_next_method,
@@ -46114,6 +46155,7 @@ function createTypeChecker(host) {
46114
46155
  getGlobalIteratorType,
46115
46156
  getGlobalIterableType,
46116
46157
  getGlobalIterableIteratorType,
46158
+ getGlobalBuiltinIteratorType,
46117
46159
  getGlobalGeneratorType,
46118
46160
  resolveIterationType: (type, _errorNode) => type,
46119
46161
  mustHaveANextMethodDiagnostic: Diagnostics.An_iterator_must_have_a_next_method,
@@ -46152,12 +46194,14 @@ function createTypeChecker(host) {
46152
46194
  var deferredGlobalIterableType;
46153
46195
  var deferredGlobalIteratorType;
46154
46196
  var deferredGlobalIterableIteratorType;
46197
+ var deferredGlobalBuiltinIteratorType;
46155
46198
  var deferredGlobalGeneratorType;
46156
46199
  var deferredGlobalIteratorYieldResultType;
46157
46200
  var deferredGlobalIteratorReturnResultType;
46158
46201
  var deferredGlobalAsyncIterableType;
46159
46202
  var deferredGlobalAsyncIteratorType;
46160
46203
  var deferredGlobalAsyncIterableIteratorType;
46204
+ var deferredGlobalBuiltinAsyncIteratorType;
46161
46205
  var deferredGlobalAsyncGeneratorType;
46162
46206
  var deferredGlobalTemplateStringsArrayType;
46163
46207
  var deferredGlobalImportMetaType;
@@ -48270,7 +48314,7 @@ function createTypeChecker(host) {
48270
48314
  }
48271
48315
  return getMergedSymbol(sourceFile.symbol);
48272
48316
  }
48273
- if (errorNode && moduleNotFoundError) {
48317
+ if (errorNode && moduleNotFoundError && !isSideEffectImport(errorNode)) {
48274
48318
  error(errorNode, Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
48275
48319
  }
48276
48320
  return void 0;
@@ -48355,6 +48399,9 @@ function createTypeChecker(host) {
48355
48399
  }
48356
48400
  }
48357
48401
  function errorOnImplicitAnyModule(isError, errorNode, sourceFile, mode, { packageId, resolvedFileName }, moduleReference) {
48402
+ if (isSideEffectImport(errorNode)) {
48403
+ return;
48404
+ }
48358
48405
  let errorInfo;
48359
48406
  if (!isExternalModuleNameRelative(moduleReference) && packageId) {
48360
48407
  errorInfo = createModuleNotFoundChain(sourceFile, host, moduleReference, mode, packageId.name);
@@ -50183,7 +50230,35 @@ function createTypeChecker(host) {
50183
50230
  }
50184
50231
  let typeArgumentNodes;
50185
50232
  if (typeArguments.length > 0) {
50186
- const typeParameterCount = (type2.target.typeParameters || emptyArray).length;
50233
+ let typeParameterCount = 0;
50234
+ if (type2.target.typeParameters) {
50235
+ typeParameterCount = Math.min(type2.target.typeParameters.length, typeArguments.length);
50236
+ if (isReferenceToType(type2, getGlobalIterableType(
50237
+ /*reportErrors*/
50238
+ false
50239
+ )) || isReferenceToType(type2, getGlobalIterableIteratorType(
50240
+ /*reportErrors*/
50241
+ false
50242
+ )) || isReferenceToType(type2, getGlobalAsyncIterableType(
50243
+ /*reportErrors*/
50244
+ false
50245
+ )) || isReferenceToType(type2, getGlobalAsyncIterableIteratorType(
50246
+ /*reportErrors*/
50247
+ false
50248
+ ))) {
50249
+ if (!type2.node || !isTypeReferenceNode(type2.node) || !type2.node.typeArguments || type2.node.typeArguments.length < typeParameterCount) {
50250
+ while (typeParameterCount > 0) {
50251
+ const typeArgument = typeArguments[typeParameterCount - 1];
50252
+ const typeParameter = type2.target.typeParameters[typeParameterCount - 1];
50253
+ const defaultType = getDefaultFromTypeParameter(typeParameter);
50254
+ if (!defaultType || !isTypeIdenticalTo(typeArgument, defaultType)) {
50255
+ break;
50256
+ }
50257
+ typeParameterCount--;
50258
+ }
50259
+ }
50260
+ }
50261
+ }
50187
50262
  typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
50188
50263
  }
50189
50264
  const flags = context.flags;
@@ -55628,6 +55703,9 @@ function createTypeChecker(host) {
55628
55703
  links.instantiations = /* @__PURE__ */ new Map();
55629
55704
  links.instantiations.set(getTypeListId(typeParameters), type);
55630
55705
  }
55706
+ if (type === intrinsicMarkerType && symbol.escapedName === "BuiltinIteratorReturn") {
55707
+ type = strictBuiltinIteratorReturn ? undefinedType : anyType;
55708
+ }
55631
55709
  } else {
55632
55710
  type = errorType;
55633
55711
  if (declaration.kind === 340 /* JSDocEnumTag */) {
@@ -58905,7 +58983,7 @@ function createTypeChecker(host) {
58905
58983
  return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType(
58906
58984
  "AsyncIterable",
58907
58985
  /*arity*/
58908
- 1,
58986
+ 3,
58909
58987
  reportErrors2
58910
58988
  )) || emptyGenericType;
58911
58989
  }
@@ -58921,7 +58999,15 @@ function createTypeChecker(host) {
58921
58999
  return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType(
58922
59000
  "AsyncIterableIterator",
58923
59001
  /*arity*/
58924
- 1,
59002
+ 3,
59003
+ reportErrors2
59004
+ )) || emptyGenericType;
59005
+ }
59006
+ function getGlobalBuiltinAsyncIteratorType(reportErrors2) {
59007
+ return deferredGlobalBuiltinAsyncIteratorType || (deferredGlobalBuiltinAsyncIteratorType = getGlobalType(
59008
+ "BuiltinAsyncIterator",
59009
+ /*arity*/
59010
+ 3,
58925
59011
  reportErrors2
58926
59012
  )) || emptyGenericType;
58927
59013
  }
@@ -58937,7 +59023,7 @@ function createTypeChecker(host) {
58937
59023
  return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType(
58938
59024
  "Iterable",
58939
59025
  /*arity*/
58940
- 1,
59026
+ 3,
58941
59027
  reportErrors2
58942
59028
  )) || emptyGenericType;
58943
59029
  }
@@ -58953,7 +59039,15 @@ function createTypeChecker(host) {
58953
59039
  return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType(
58954
59040
  "IterableIterator",
58955
59041
  /*arity*/
58956
- 1,
59042
+ 3,
59043
+ reportErrors2
59044
+ )) || emptyGenericType;
59045
+ }
59046
+ function getGlobalBuiltinIteratorType(reportErrors2) {
59047
+ return deferredGlobalBuiltinIteratorType || (deferredGlobalBuiltinIteratorType = getGlobalType(
59048
+ "BuiltinIterator",
59049
+ /*arity*/
59050
+ 3,
58957
59051
  reportErrors2
58958
59052
  )) || emptyGenericType;
58959
59053
  }
@@ -59135,7 +59229,7 @@ function createTypeChecker(host) {
59135
59229
  return createTypeFromGenericGlobalType(getGlobalIterableType(
59136
59230
  /*reportErrors*/
59137
59231
  true
59138
- ), [iteratedType]);
59232
+ ), [iteratedType, voidType, undefinedType]);
59139
59233
  }
59140
59234
  function createArrayType(elementType, readonly) {
59141
59235
  return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]);
@@ -60495,12 +60589,13 @@ function createTypeChecker(host) {
60495
60589
  }
60496
60590
  if (accessNode) {
60497
60591
  const indexNode = getIndexNodeForAccessExpression(accessNode);
60498
- if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
60592
+ if (indexNode.kind !== 10 /* BigIntLiteral */ && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
60499
60593
  error(indexNode, Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
60500
60594
  } else if (indexType.flags & (4 /* String */ | 8 /* Number */)) {
60501
60595
  error(indexNode, Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
60502
60596
  } else {
60503
- error(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
60597
+ const typeString = indexNode.kind === 10 /* BigIntLiteral */ ? "bigint" : typeToString(indexType);
60598
+ error(indexNode, Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeString);
60504
60599
  }
60505
60600
  }
60506
60601
  if (isTypeAny(indexType)) {
@@ -67796,9 +67891,6 @@ function createTypeChecker(host) {
67796
67891
  function recombineUnknownType(type) {
67797
67892
  return type === unknownUnionType ? unknownType : type;
67798
67893
  }
67799
- function getUnknownIfMaybeUnknown(type) {
67800
- return strictNullChecks && type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
67801
- }
67802
67894
  function getTypeWithDefault(type, defaultExpression) {
67803
67895
  return defaultExpression ? getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) : type;
67804
67896
  }
@@ -76613,24 +76705,14 @@ function createTypeChecker(host) {
76613
76705
  void 0
76614
76706
  ) || unknownType;
76615
76707
  if (globalGeneratorType === emptyGenericType) {
76616
- const globalType = resolver.getGlobalIterableIteratorType(
76708
+ const globalIterableIteratorType = resolver.getGlobalIterableIteratorType(
76617
76709
  /*reportErrors*/
76618
76710
  false
76619
76711
  );
76620
- const iterationTypes = globalType !== emptyGenericType ? getIterationTypesOfGlobalIterableType(globalType, resolver) : void 0;
76621
- const iterableIteratorReturnType = iterationTypes ? iterationTypes.returnType : anyType;
76622
- const iterableIteratorNextType = iterationTypes ? iterationTypes.nextType : undefinedType;
76623
- if (isTypeAssignableTo(returnType, iterableIteratorReturnType) && isTypeAssignableTo(iterableIteratorNextType, nextType)) {
76624
- if (globalType !== emptyGenericType) {
76625
- return createTypeFromGenericGlobalType(globalType, [yieldType]);
76626
- }
76627
- resolver.getGlobalIterableIteratorType(
76628
- /*reportErrors*/
76629
- true
76630
- );
76631
- return emptyObjectType;
76712
+ if (globalIterableIteratorType !== emptyGenericType) {
76713
+ return createTypeFromGenericGlobalType(globalIterableIteratorType, [yieldType, returnType, nextType]);
76632
76714
  }
76633
- resolver.getGlobalGeneratorType(
76715
+ resolver.getGlobalIterableIteratorType(
76634
76716
  /*reportErrors*/
76635
76717
  true
76636
76718
  );
@@ -77609,7 +77691,7 @@ function createTypeChecker(host) {
77609
77691
  setLastResult(state, checkExpression(node.right, checkMode));
77610
77692
  return state;
77611
77693
  }
77612
- checkGrammarNullishCoalesceWithLogicalExpression(node);
77694
+ checkNullishCoalesceOperands(node);
77613
77695
  const operator = node.operatorToken.kind;
77614
77696
  if (operator === 64 /* EqualsToken */ && (node.left.kind === 210 /* ObjectLiteralExpression */ || node.left.kind === 209 /* ArrayLiteralExpression */)) {
77615
77697
  state.skip = true;
@@ -77642,7 +77724,9 @@ function createTypeChecker(host) {
77642
77724
  if (operator === 56 /* AmpersandAmpersandToken */ || isIfStatement(parent)) {
77643
77725
  checkTestingKnownTruthyCallableOrAwaitableOrEnumMemberType(node.left, leftType, isIfStatement(parent) ? parent.thenStatement : void 0);
77644
77726
  }
77645
- checkTruthinessOfType(leftType, node.left);
77727
+ if (isBinaryLogicalOperator(operator)) {
77728
+ checkTruthinessOfType(leftType, node.left);
77729
+ }
77646
77730
  }
77647
77731
  }
77648
77732
  }
@@ -77699,7 +77783,7 @@ function createTypeChecker(host) {
77699
77783
  state.typeStack[state.stackIndex + 1] = type;
77700
77784
  }
77701
77785
  }
77702
- function checkGrammarNullishCoalesceWithLogicalExpression(node) {
77786
+ function checkNullishCoalesceOperands(node) {
77703
77787
  const { left, operatorToken, right } = node;
77704
77788
  if (operatorToken.kind === 61 /* QuestionQuestionToken */) {
77705
77789
  if (isBinaryExpression(left) && (left.operatorToken.kind === 57 /* BarBarToken */ || left.operatorToken.kind === 56 /* AmpersandAmpersandToken */)) {
@@ -77708,15 +77792,65 @@ function createTypeChecker(host) {
77708
77792
  if (isBinaryExpression(right) && (right.operatorToken.kind === 57 /* BarBarToken */ || right.operatorToken.kind === 56 /* AmpersandAmpersandToken */)) {
77709
77793
  grammarErrorOnNode(right, Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, tokenToString(right.operatorToken.kind), tokenToString(operatorToken.kind));
77710
77794
  }
77795
+ const leftTarget = skipOuterExpressions(left, 15 /* All */);
77796
+ const nullishSemantics = getSyntacticNullishnessSemantics(leftTarget);
77797
+ if (nullishSemantics !== 3 /* Sometimes */) {
77798
+ if (node.parent.kind === 226 /* BinaryExpression */) {
77799
+ error(leftTarget, Diagnostics.This_binary_expression_is_never_nullish_Are_you_missing_parentheses);
77800
+ } else {
77801
+ if (nullishSemantics === 1 /* Always */) {
77802
+ error(leftTarget, Diagnostics.This_expression_is_always_nullish);
77803
+ } else {
77804
+ error(leftTarget, Diagnostics.Right_operand_of_is_unreachable_because_the_left_operand_is_never_nullish);
77805
+ }
77806
+ }
77807
+ }
77711
77808
  }
77712
77809
  }
77810
+ function getSyntacticNullishnessSemantics(node) {
77811
+ switch (node.kind) {
77812
+ case 223 /* AwaitExpression */:
77813
+ case 213 /* CallExpression */:
77814
+ case 212 /* ElementAccessExpression */:
77815
+ case 214 /* NewExpression */:
77816
+ case 211 /* PropertyAccessExpression */:
77817
+ case 229 /* YieldExpression */:
77818
+ return 3 /* Sometimes */;
77819
+ case 226 /* BinaryExpression */:
77820
+ switch (node.operatorToken.kind) {
77821
+ case 64 /* EqualsToken */:
77822
+ case 61 /* QuestionQuestionToken */:
77823
+ case 78 /* QuestionQuestionEqualsToken */:
77824
+ case 57 /* BarBarToken */:
77825
+ case 76 /* BarBarEqualsToken */:
77826
+ case 56 /* AmpersandAmpersandToken */:
77827
+ case 77 /* AmpersandAmpersandEqualsToken */:
77828
+ return 3 /* Sometimes */;
77829
+ }
77830
+ return 2 /* Never */;
77831
+ case 216 /* TypeAssertionExpression */:
77832
+ case 234 /* AsExpression */:
77833
+ case 217 /* ParenthesizedExpression */:
77834
+ return getSyntacticNullishnessSemantics(node.expression);
77835
+ case 227 /* ConditionalExpression */:
77836
+ return getSyntacticNullishnessSemantics(node.whenTrue) | getSyntacticNullishnessSemantics(node.whenFalse);
77837
+ case 106 /* NullKeyword */:
77838
+ return 1 /* Always */;
77839
+ case 80 /* Identifier */:
77840
+ if (getResolvedSymbol(node) === undefinedSymbol) {
77841
+ return 1 /* Always */;
77842
+ }
77843
+ return 3 /* Sometimes */;
77844
+ }
77845
+ return 2 /* Never */;
77846
+ }
77713
77847
  function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) {
77714
77848
  const operator = operatorToken.kind;
77715
77849
  if (operator === 64 /* EqualsToken */ && (left.kind === 210 /* ObjectLiteralExpression */ || left.kind === 209 /* ArrayLiteralExpression */)) {
77716
77850
  return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 110 /* ThisKeyword */);
77717
77851
  }
77718
77852
  let leftType;
77719
- if (isLogicalOrCoalescingBinaryOperator(operator)) {
77853
+ if (isBinaryLogicalOperator(operator)) {
77720
77854
  leftType = checkTruthinessExpression(left, checkMode);
77721
77855
  } else {
77722
77856
  leftType = checkExpression(left, checkMode);
@@ -77867,8 +78001,8 @@ function createTypeChecker(host) {
77867
78001
  case 33 /* LessThanEqualsToken */:
77868
78002
  case 34 /* GreaterThanEqualsToken */:
77869
78003
  if (checkForDisallowedESSymbolOperand(operator)) {
77870
- leftType = getBaseTypeOfLiteralTypeForComparison(checkNonNullType(getUnknownIfMaybeUnknown(leftType), left));
77871
- rightType = getBaseTypeOfLiteralTypeForComparison(checkNonNullType(getUnknownIfMaybeUnknown(rightType), right));
78004
+ leftType = getBaseTypeOfLiteralTypeForComparison(checkNonNullType(leftType, left));
78005
+ rightType = getBaseTypeOfLiteralTypeForComparison(checkNonNullType(rightType, right));
77872
78006
  reportOperatorErrorUnless((left2, right2) => {
77873
78007
  if (isTypeAny(left2) || isTypeAny(right2)) {
77874
78008
  return true;
@@ -81070,6 +81204,9 @@ function createTypeChecker(host) {
81070
81204
  checkAliasSymbol(node);
81071
81205
  return;
81072
81206
  }
81207
+ if (node.name.kind === 10 /* BigIntLiteral */) {
81208
+ error(node.name, Diagnostics.A_bigint_literal_cannot_be_used_as_a_property_name);
81209
+ }
81073
81210
  const type = convertAutoToAny(getTypeOfSymbol(symbol));
81074
81211
  if (node === symbol.valueDeclaration) {
81075
81212
  const initializer = hasOnlyExpressionInitializer(node) && getEffectiveInitializer(node);
@@ -81319,9 +81456,54 @@ function createTypeChecker(host) {
81319
81456
  function checkTruthinessOfType(type, node) {
81320
81457
  if (type.flags & 16384 /* Void */) {
81321
81458
  error(node, Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
81459
+ } else {
81460
+ const semantics = getSyntacticTruthySemantics(node);
81461
+ if (semantics !== 3 /* Sometimes */) {
81462
+ error(
81463
+ node,
81464
+ semantics === 1 /* Always */ ? Diagnostics.This_kind_of_expression_is_always_truthy : Diagnostics.This_kind_of_expression_is_always_falsy
81465
+ );
81466
+ }
81322
81467
  }
81323
81468
  return type;
81324
81469
  }
81470
+ function getSyntacticTruthySemantics(node) {
81471
+ switch (node.kind) {
81472
+ case 9 /* NumericLiteral */:
81473
+ if (node.text === "0" || node.text === "1") {
81474
+ return 3 /* Sometimes */;
81475
+ }
81476
+ return 1 /* Always */;
81477
+ case 209 /* ArrayLiteralExpression */:
81478
+ case 219 /* ArrowFunction */:
81479
+ case 10 /* BigIntLiteral */:
81480
+ case 231 /* ClassExpression */:
81481
+ case 218 /* FunctionExpression */:
81482
+ case 284 /* JsxElement */:
81483
+ case 285 /* JsxSelfClosingElement */:
81484
+ case 210 /* ObjectLiteralExpression */:
81485
+ case 14 /* RegularExpressionLiteral */:
81486
+ return 1 /* Always */;
81487
+ case 222 /* VoidExpression */:
81488
+ case 106 /* NullKeyword */:
81489
+ return 2 /* Never */;
81490
+ case 15 /* NoSubstitutionTemplateLiteral */:
81491
+ case 11 /* StringLiteral */:
81492
+ return !!node.text ? 1 /* Always */ : 2 /* Never */;
81493
+ case 216 /* TypeAssertionExpression */:
81494
+ case 234 /* AsExpression */:
81495
+ case 217 /* ParenthesizedExpression */:
81496
+ return getSyntacticTruthySemantics(node.expression);
81497
+ case 227 /* ConditionalExpression */:
81498
+ return getSyntacticTruthySemantics(node.whenTrue) | getSyntacticTruthySemantics(node.whenFalse);
81499
+ case 80 /* Identifier */:
81500
+ if (getResolvedSymbol(node) === undefinedSymbol) {
81501
+ return 2 /* Never */;
81502
+ }
81503
+ return 3 /* Sometimes */;
81504
+ }
81505
+ return 3 /* Sometimes */;
81506
+ }
81325
81507
  function checkTruthinessExpression(node, checkMode) {
81326
81508
  return checkTruthinessOfType(checkExpression(node, checkMode), node);
81327
81509
  }
@@ -81704,41 +81886,17 @@ function createTypeChecker(host) {
81704
81886
  function getIterationTypesOfIterableCached(type, resolver) {
81705
81887
  return getCachedIterationTypes(type, resolver.iterableCacheKey);
81706
81888
  }
81707
- function getIterationTypesOfGlobalIterableType(globalType, resolver) {
81708
- const globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) || getIterationTypesOfIterableSlow(
81709
- globalType,
81710
- resolver,
81711
- /*errorNode*/
81712
- void 0,
81713
- /*errorOutputContainer*/
81714
- void 0,
81715
- /*noCache*/
81716
- false
81717
- );
81718
- return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
81719
- }
81720
81889
  function getIterationTypesOfIterableFast(type, resolver) {
81721
- let globalType;
81722
- if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(
81890
+ if (isReferenceToType(type, resolver.getGlobalIterableType(
81723
81891
  /*reportErrors*/
81724
81892
  false
81725
- )) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(
81893
+ )) || isReferenceToType(type, resolver.getGlobalBuiltinIteratorType(
81726
81894
  /*reportErrors*/
81727
81895
  false
81728
- ))) {
81729
- const [yieldType] = getTypeArguments(type);
81730
- const { returnType, nextType } = getIterationTypesOfGlobalIterableType(globalType, resolver);
81731
- return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(resolver.resolveIterationType(
81732
- yieldType,
81733
- /*errorNode*/
81734
- void 0
81735
- ) || yieldType, resolver.resolveIterationType(
81736
- returnType,
81737
- /*errorNode*/
81738
- void 0
81739
- ) || returnType, nextType));
81740
- }
81741
- if (isReferenceToType(type, resolver.getGlobalGeneratorType(
81896
+ )) || isReferenceToType(type, resolver.getGlobalIterableIteratorType(
81897
+ /*reportErrors*/
81898
+ false
81899
+ )) || isReferenceToType(type, resolver.getGlobalGeneratorType(
81742
81900
  /*reportErrors*/
81743
81901
  false
81744
81902
  ))) {
@@ -81783,10 +81941,10 @@ function createTypeChecker(host) {
81783
81941
  !!getAwaitedTypeOfPromise(type) || !allowAsyncIterables && isForOfStatement(errorNode.parent) && errorNode.parent.expression === errorNode && getGlobalAsyncIterableType(
81784
81942
  /*reportErrors*/
81785
81943
  false
81786
- ) !== emptyGenericType && isTypeAssignableTo(type, getGlobalAsyncIterableType(
81944
+ ) !== emptyGenericType && isTypeAssignableTo(type, createTypeFromGenericGlobalType(getGlobalAsyncIterableType(
81787
81945
  /*reportErrors*/
81788
81946
  false
81789
- ))
81947
+ ), [anyType, anyType, anyType]))
81790
81948
  );
81791
81949
  return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
81792
81950
  }
@@ -81816,26 +81974,13 @@ function createTypeChecker(host) {
81816
81974
  return getCachedIterationTypes(type, resolver.iteratorCacheKey);
81817
81975
  }
81818
81976
  function getIterationTypesOfIteratorFast(type, resolver) {
81819
- const globalType = resolver.getGlobalIterableIteratorType(
81977
+ if (isReferenceToType(type, resolver.getGlobalBuiltinIteratorType(
81820
81978
  /*reportErrors*/
81821
81979
  false
81822
- );
81823
- if (isReferenceToType(type, globalType)) {
81824
- const [yieldType] = getTypeArguments(type);
81825
- const globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || getIterationTypesOfIteratorSlow(
81826
- globalType,
81827
- resolver,
81828
- /*errorNode*/
81829
- void 0,
81830
- /*errorOutputContainer*/
81831
- void 0,
81832
- /*noCache*/
81833
- false
81834
- );
81835
- const { returnType, nextType } = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
81836
- return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
81837
- }
81838
- if (isReferenceToType(type, resolver.getGlobalIteratorType(
81980
+ )) || isReferenceToType(type, resolver.getGlobalIterableIteratorType(
81981
+ /*reportErrors*/
81982
+ false
81983
+ )) || isReferenceToType(type, resolver.getGlobalIteratorType(
81839
81984
  /*reportErrors*/
81840
81985
  false
81841
81986
  )) || isReferenceToType(type, resolver.getGlobalGeneratorType(
@@ -81912,7 +82057,7 @@ function createTypeChecker(host) {
81912
82057
  }
81913
82058
  const methodType = method && !(methodName === "next" && method.flags & 16777216 /* Optional */) ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */) : void 0;
81914
82059
  if (isTypeAny(methodType)) {
81915
- return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext;
82060
+ return anyIterationTypes;
81916
82061
  }
81917
82062
  const methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : emptyArray;
81918
82063
  if (methodSignatures.length === 0) {
@@ -83050,7 +83195,9 @@ function createTypeChecker(host) {
83050
83195
  checkExportsOnMergedDeclarations(node);
83051
83196
  checkTypeParameters(node.typeParameters);
83052
83197
  if (node.type.kind === 141 /* IntrinsicKeyword */) {
83053
- if (!intrinsicTypeKinds.has(node.name.escapedText) || length(node.typeParameters) !== 1) {
83198
+ const typeParameterCount = length(node.typeParameters);
83199
+ const valid = typeParameterCount === 0 ? node.name.escapedText === "BuiltinIteratorReturn" : typeParameterCount === 1 && intrinsicTypeKinds.has(node.name.escapedText);
83200
+ if (!valid) {
83054
83201
  error(node.type, Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types);
83055
83202
  }
83056
83203
  } else {
@@ -83690,6 +83837,8 @@ function createTypeChecker(host) {
83690
83837
  }
83691
83838
  }
83692
83839
  }
83840
+ } else if (noUncheckedSideEffectImports && !importClause) {
83841
+ void resolveExternalModuleName(node, node.moduleSpecifier);
83693
83842
  }
83694
83843
  }
83695
83844
  checkImportAttributes(node);
@@ -86967,6 +87116,13 @@ function createTypeChecker(host) {
86967
87116
  if (name.kind === 9 /* NumericLiteral */) {
86968
87117
  checkGrammarNumericLiteral(name);
86969
87118
  }
87119
+ if (name.kind === 10 /* BigIntLiteral */) {
87120
+ addErrorOrSuggestion(
87121
+ /*isError*/
87122
+ true,
87123
+ createDiagnosticForNode(name, Diagnostics.A_bigint_literal_cannot_be_used_as_a_property_name)
87124
+ );
87125
+ }
86970
87126
  currentKind = 4 /* PropertyAssignment */;
86971
87127
  break;
86972
87128
  case 174 /* MethodDeclaration */:
@@ -90524,7 +90680,7 @@ function createDestructuringPropertyAccess(flattenContext, value, propertyName)
90524
90680
  propertyName
90525
90681
  );
90526
90682
  return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
90527
- } else if (isStringOrNumericLiteralLike(propertyName)) {
90683
+ } else if (isStringOrNumericLiteralLike(propertyName) || isBigIntLiteral(propertyName)) {
90528
90684
  const argumentExpression = factory2.cloneNode(propertyName);
90529
90685
  return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
90530
90686
  } else {