@typescript-deploys/pr-build 4.5.0-pr-46250-2 → 4.5.0-pr-46464-7

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/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20211007";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20211022";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -323,21 +323,24 @@ var ts;
323
323
  return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
324
324
  }
325
325
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
326
- })(NativeCollections = ts.NativeCollections || (ts.NativeCollections = {}));
327
- })(ts || (ts = {}));
328
- /* @internal */
329
- var ts;
330
- (function (ts) {
326
+ })(NativeCollections || (NativeCollections = {}));
327
+ /* @internal */
328
+ ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
329
+ /* @internal */
330
+ ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
331
+ /* @internal */
331
332
  function getCollectionImplementation(name, nativeFactory, shimFactory) {
332
333
  var _a;
333
334
  // NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it.
334
- var constructor = (_a = ts.NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](getIterator);
335
+ var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator);
335
336
  if (constructor)
336
337
  return constructor;
337
338
  throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");
338
339
  }
339
- ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
340
- ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
340
+ })(ts || (ts = {}));
341
+ /* @internal */
342
+ var ts;
343
+ (function (ts) {
341
344
  function getIterator(iterable) {
342
345
  if (iterable) {
343
346
  if (isArray(iterable))
@@ -8017,6 +8020,11 @@ var ts;
8017
8020
  }
8018
8021
  return sys;
8019
8022
  })();
8023
+ /*@internal*/
8024
+ function setSys(s) {
8025
+ ts.sys = s;
8026
+ }
8027
+ ts.setSys = setSys;
8020
8028
  if (ts.sys && ts.sys.getEnvironmentVariable) {
8021
8029
  setCustomPollingValues(ts.sys);
8022
8030
  ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
@@ -9527,6 +9535,7 @@ var ts;
9527
9535
  If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_declare_module_1: diag(7058, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058", "If the '{0}' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module '{1}';`"),
9528
9536
  This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."),
9529
9537
  This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."),
9538
+ A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."),
9530
9539
  You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
9531
9540
  You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
9532
9541
  import_can_only_be_used_in_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."),
@@ -9582,7 +9591,7 @@ var ts;
9582
9591
  Circularity_detected_while_resolving_configuration_Colon_0: diag(18000, ts.DiagnosticCategory.Error, "Circularity_detected_while_resolving_configuration_Colon_0_18000", "Circularity detected while resolving configuration: {0}"),
9583
9592
  The_files_list_in_config_file_0_is_empty: diag(18002, ts.DiagnosticCategory.Error, "The_files_list_in_config_file_0_is_empty_18002", "The 'files' list in config file '{0}' is empty."),
9584
9593
  No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: diag(18003, ts.DiagnosticCategory.Error, "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'."),
9585
- File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module: diag(80001, ts.DiagnosticCategory.Suggestion, "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001", "File is a CommonJS module; it may be converted to an ES6 module."),
9594
+ File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module: diag(80001, ts.DiagnosticCategory.Suggestion, "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001", "File is a CommonJS module; it may be converted to an ES module."),
9586
9595
  This_constructor_function_may_be_converted_to_a_class_declaration: diag(80002, ts.DiagnosticCategory.Suggestion, "This_constructor_function_may_be_converted_to_a_class_declaration_80002", "This constructor function may be converted to a class declaration."),
9587
9596
  Import_may_be_converted_to_a_default_import: diag(80003, ts.DiagnosticCategory.Suggestion, "Import_may_be_converted_to_a_default_import_80003", "Import may be converted to a default import."),
9588
9597
  JSDoc_types_may_be_moved_to_TypeScript_types: diag(80004, ts.DiagnosticCategory.Suggestion, "JSDoc_types_may_be_moved_to_TypeScript_types_80004", "JSDoc types may be moved to TypeScript types."),
@@ -9644,7 +9653,7 @@ var ts;
9644
9653
  Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
9645
9654
  Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
9646
9655
  Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."),
9647
- Convert_to_ES6_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES6_module_95017", "Convert to ES6 module"),
9656
+ Convert_to_ES_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES_module_95017", "Convert to ES module"),
9648
9657
  Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"),
9649
9658
  Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
9650
9659
  Add_definite_assignment_assertion_to_property_0: diag(95020, ts.DiagnosticCategory.Message, "Add_definite_assignment_assertion_to_property_0_95020", "Add definite assignment assertion to property '{0}'"),
@@ -20178,7 +20187,7 @@ var ts;
20178
20187
  includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
20179
20188
  includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
20180
20189
  excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
20181
- basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames)
20190
+ basePaths: getBasePaths(absolutePath, includes, useCaseSensitiveFileNames)
20182
20191
  };
20183
20192
  }
20184
20193
  ts.getFileMatcherPatterns = getFileMatcherPatterns;
@@ -20200,20 +20209,20 @@ var ts;
20200
20209
  var visited = new ts.Map();
20201
20210
  var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
20202
20211
  for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) {
20203
- var basePath = _a[_i];
20204
- if (directoryExists(basePath)) {
20205
- visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth);
20212
+ var absoluteBasePath = _a[_i];
20213
+ if (directoryExists(absoluteBasePath)) {
20214
+ visitDirectory(absoluteBasePath, depth);
20206
20215
  }
20207
20216
  }
20208
20217
  return ts.flatten(results);
20209
- function visitDirectory(path, absolutePath, depth) {
20218
+ function visitDirectory(absolutePath, depth) {
20210
20219
  var canonicalPath = toCanonical(realpath(absolutePath));
20211
20220
  if (visited.has(canonicalPath))
20212
20221
  return;
20213
20222
  visited.set(canonicalPath, true);
20214
- var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories;
20223
+ var _a = getFileSystemEntries(absolutePath), files = _a.files, directories = _a.directories;
20215
20224
  var _loop_1 = function (current) {
20216
- var name = ts.combinePaths(path, current);
20225
+ var name = ts.combinePaths(absolutePath, current);
20217
20226
  var absoluteName = ts.combinePaths(absolutePath, current);
20218
20227
  if (extensions && !ts.fileExtensionIsOneOf(name, extensions))
20219
20228
  return "continue";
@@ -20241,11 +20250,10 @@ var ts;
20241
20250
  }
20242
20251
  for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) {
20243
20252
  var current = _d[_c];
20244
- var name = ts.combinePaths(path, current);
20245
20253
  var absoluteName = ts.combinePaths(absolutePath, current);
20246
20254
  if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
20247
20255
  (!excludeRegex || !excludeRegex.test(absoluteName))) {
20248
- visitDirectory(name, absoluteName, depth);
20256
+ visitDirectory(absoluteName, depth);
20249
20257
  }
20250
20258
  }
20251
20259
  }
@@ -20253,10 +20261,11 @@ var ts;
20253
20261
  ts.matchFiles = matchFiles;
20254
20262
  /**
20255
20263
  * Computes the unique non-wildcard base paths amongst the provided include patterns.
20264
+ * @returns Absolute directory paths
20256
20265
  */
20257
- function getBasePaths(path, includes, useCaseSensitiveFileNames) {
20266
+ function getBasePaths(absoluteTsconfigPath, includes, useCaseSensitiveFileNames) {
20258
20267
  // Storage for our results in the form of literal paths (e.g. the paths as written by the user).
20259
- var basePaths = [path];
20268
+ var basePaths = [absoluteTsconfigPath];
20260
20269
  if (includes) {
20261
20270
  // Storage for literal base paths amongst the include patterns.
20262
20271
  var includeBasePaths = [];
@@ -20264,14 +20273,14 @@ var ts;
20264
20273
  var include = includes_1[_i];
20265
20274
  // We also need to check the relative paths by converting them to absolute and normalizing
20266
20275
  // in case they escape the base path (e.g "..\somedirectory")
20267
- var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include));
20276
+ var absoluteIncludePath = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(absoluteTsconfigPath, include));
20268
20277
  // Append the literal and canonical candidate base paths.
20269
- includeBasePaths.push(getIncludeBasePath(absolute));
20278
+ includeBasePaths.push(getIncludeBasePath(absoluteIncludePath));
20270
20279
  }
20271
20280
  // Sort the offsets array using either the literal or canonical path representations.
20272
20281
  includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames));
20273
20282
  var _loop_2 = function (includeBasePath) {
20274
- if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) {
20283
+ if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, absoluteTsconfigPath, !useCaseSensitiveFileNames); })) {
20275
20284
  basePaths.push(includeBasePath);
20276
20285
  }
20277
20286
  };
@@ -23091,24 +23100,26 @@ var ts;
23091
23100
  : node;
23092
23101
  }
23093
23102
  // @api
23094
- function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) {
23103
+ function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) {
23095
23104
  var node = createBaseNode(194 /* MappedType */);
23096
23105
  node.readonlyToken = readonlyToken;
23097
23106
  node.typeParameter = typeParameter;
23098
23107
  node.nameType = nameType;
23099
23108
  node.questionToken = questionToken;
23100
23109
  node.type = type;
23110
+ node.members = members && createNodeArray(members);
23101
23111
  node.transformFlags = 1 /* ContainsTypeScript */;
23102
23112
  return node;
23103
23113
  }
23104
23114
  // @api
23105
- function updateMappedTypeNode(node, readonlyToken, typeParameter, nameType, questionToken, type) {
23115
+ function updateMappedTypeNode(node, readonlyToken, typeParameter, nameType, questionToken, type, members) {
23106
23116
  return node.readonlyToken !== readonlyToken
23107
23117
  || node.typeParameter !== typeParameter
23108
23118
  || node.nameType !== nameType
23109
23119
  || node.questionToken !== questionToken
23110
23120
  || node.type !== type
23111
- ? update(createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), node)
23121
+ || node.members !== members
23122
+ ? update(createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), node)
23112
23123
  : node;
23113
23124
  }
23114
23125
  // @api
@@ -29981,7 +29992,8 @@ var ts;
29981
29992
  visitNode(cbNode, node.typeParameter) ||
29982
29993
  visitNode(cbNode, node.nameType) ||
29983
29994
  visitNode(cbNode, node.questionToken) ||
29984
- visitNode(cbNode, node.type);
29995
+ visitNode(cbNode, node.type) ||
29996
+ visitNodes(cbNode, cbNodes, node.members);
29985
29997
  case 195 /* LiteralType */:
29986
29998
  return visitNode(cbNode, node.literal);
29987
29999
  case 196 /* NamedTupleMember */:
@@ -32871,8 +32883,9 @@ var ts;
32871
32883
  }
32872
32884
  var type = parseTypeAnnotation();
32873
32885
  parseSemicolon();
32886
+ var members = parseList(4 /* TypeMembers */, parseTypeMember);
32874
32887
  parseExpected(19 /* CloseBraceToken */);
32875
- return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), pos);
32888
+ return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos);
32876
32889
  }
32877
32890
  function parseTupleElementType() {
32878
32891
  var pos = getNodePos();
@@ -36159,16 +36172,21 @@ var ts;
36159
36172
  var pos = getNodePos();
36160
36173
  parseExpected(129 /* AssertKeyword */);
36161
36174
  var openBracePosition = scanner.getTokenPos();
36162
- parseExpected(18 /* OpenBraceToken */);
36163
- var multiLine = scanner.hasPrecedingLineBreak();
36164
- var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true);
36165
- if (!parseExpected(19 /* CloseBraceToken */)) {
36166
- var lastError = ts.lastOrUndefined(parseDiagnostics);
36167
- if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
36168
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
36175
+ if (parseExpected(18 /* OpenBraceToken */)) {
36176
+ var multiLine = scanner.hasPrecedingLineBreak();
36177
+ var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true);
36178
+ if (!parseExpected(19 /* CloseBraceToken */)) {
36179
+ var lastError = ts.lastOrUndefined(parseDiagnostics);
36180
+ if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
36181
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
36182
+ }
36169
36183
  }
36184
+ return finishNode(factory.createAssertClause(elements, multiLine), pos);
36185
+ }
36186
+ else {
36187
+ var elements = createNodeArray([], getNodePos(), /*end*/ undefined, /*hasTrailingComma*/ false);
36188
+ return finishNode(factory.createAssertClause(elements, /*multiLine*/ false), pos);
36170
36189
  }
36171
- return finishNode(factory.createAssertClause(elements, multiLine), pos);
36172
36190
  }
36173
36191
  function tokenAfterImportDefinitelyProducesImportDeclaration() {
36174
36192
  return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */;
@@ -37063,8 +37081,9 @@ var ts;
37063
37081
  return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start);
37064
37082
  }
37065
37083
  function parseSeeTag(start, tagName, indent, indentText) {
37066
- var isLink = lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; });
37067
- var nameExpression = isLink ? undefined : parseJSDocNameReference();
37084
+ var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
37085
+ || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; });
37086
+ var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
37068
37087
  var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
37069
37088
  return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
37070
37089
  }
@@ -38153,7 +38172,7 @@ var ts;
38153
38172
  var ts;
38154
38173
  (function (ts) {
38155
38174
  /* @internal */
38156
- ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" };
38175
+ ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean", defaultValueDescription: "false" };
38157
38176
  var jsxOptionMap = new ts.Map(ts.getEntries({
38158
38177
  "preserve": 1 /* Preserve */,
38159
38178
  "react-native": 3 /* ReactNative */,
@@ -38290,6 +38309,7 @@ var ts;
38290
38309
  type: "boolean",
38291
38310
  category: ts.Diagnostics.Watch_and_Build_Modes,
38292
38311
  description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
38312
+ defaultValueDescription: "false",
38293
38313
  },
38294
38314
  {
38295
38315
  name: "excludeDirectories",
@@ -38325,11 +38345,13 @@ var ts;
38325
38345
  showInSimplifiedHelpView: true,
38326
38346
  category: ts.Diagnostics.Command_line_Options,
38327
38347
  description: ts.Diagnostics.Print_this_message,
38348
+ defaultValueDescription: "false",
38328
38349
  },
38329
38350
  {
38330
38351
  name: "help",
38331
38352
  shortName: "?",
38332
- type: "boolean"
38353
+ type: "boolean",
38354
+ defaultValueDescription: "false",
38333
38355
  },
38334
38356
  {
38335
38357
  name: "watch",
@@ -38339,6 +38361,7 @@ var ts;
38339
38361
  isCommandLineOnly: true,
38340
38362
  category: ts.Diagnostics.Command_line_Options,
38341
38363
  description: ts.Diagnostics.Watch_input_files,
38364
+ defaultValueDescription: "false",
38342
38365
  },
38343
38366
  {
38344
38367
  name: "preserveWatchOutput",
@@ -38346,7 +38369,7 @@ var ts;
38346
38369
  showInSimplifiedHelpView: false,
38347
38370
  category: ts.Diagnostics.Output_Formatting,
38348
38371
  description: ts.Diagnostics.Disable_wiping_the_console_in_watch_mode,
38349
- defaultValueDescription: "n/a"
38372
+ defaultValueDescription: "false",
38350
38373
  },
38351
38374
  {
38352
38375
  name: "listFiles",
@@ -38359,7 +38382,8 @@ var ts;
38359
38382
  name: "explainFiles",
38360
38383
  type: "boolean",
38361
38384
  category: ts.Diagnostics.Compiler_Diagnostics,
38362
- description: ts.Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included
38385
+ description: ts.Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included,
38386
+ defaultValueDescription: "false",
38363
38387
  },
38364
38388
  {
38365
38389
  name: "listEmittedFiles",
@@ -38430,7 +38454,8 @@ var ts;
38430
38454
  affectsSemanticDiagnostics: true,
38431
38455
  affectsEmit: true,
38432
38456
  category: ts.Diagnostics.Watch_and_Build_Modes,
38433
- description: ts.Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
38457
+ description: ts.Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it,
38458
+ defaultValueDescription: "false",
38434
38459
  },
38435
38460
  {
38436
38461
  name: "locale",
@@ -38475,6 +38500,7 @@ var ts;
38475
38500
  showInSimplifiedHelpView: true,
38476
38501
  category: ts.Diagnostics.Command_line_Options,
38477
38502
  description: ts.Diagnostics.Show_all_compiler_options,
38503
+ defaultValueDescription: "false",
38478
38504
  },
38479
38505
  {
38480
38506
  name: "version",
@@ -38483,6 +38509,7 @@ var ts;
38483
38509
  showInSimplifiedHelpView: true,
38484
38510
  category: ts.Diagnostics.Command_line_Options,
38485
38511
  description: ts.Diagnostics.Print_the_compiler_s_version,
38512
+ defaultValueDescription: "false",
38486
38513
  },
38487
38514
  {
38488
38515
  name: "init",
@@ -38490,6 +38517,7 @@ var ts;
38490
38517
  showInSimplifiedHelpView: true,
38491
38518
  category: ts.Diagnostics.Command_line_Options,
38492
38519
  description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
38520
+ defaultValueDescription: "false",
38493
38521
  },
38494
38522
  {
38495
38523
  name: "project",
@@ -38507,7 +38535,8 @@ var ts;
38507
38535
  shortName: "b",
38508
38536
  showInSimplifiedHelpView: true,
38509
38537
  category: ts.Diagnostics.Command_line_Options,
38510
- description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
38538
+ description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date,
38539
+ defaultValueDescription: "false",
38511
38540
  },
38512
38541
  {
38513
38542
  name: "showConfig",
@@ -38515,7 +38544,8 @@ var ts;
38515
38544
  showInSimplifiedHelpView: true,
38516
38545
  category: ts.Diagnostics.Command_line_Options,
38517
38546
  isCommandLineOnly: true,
38518
- description: ts.Diagnostics.Print_the_final_configuration_instead_of_building
38547
+ description: ts.Diagnostics.Print_the_final_configuration_instead_of_building,
38548
+ defaultValueDescription: "false",
38519
38549
  },
38520
38550
  {
38521
38551
  name: "listFilesOnly",
@@ -38524,7 +38554,8 @@ var ts;
38524
38554
  affectsSemanticDiagnostics: true,
38525
38555
  affectsEmit: true,
38526
38556
  isCommandLineOnly: true,
38527
- description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing
38557
+ description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
38558
+ defaultValueDescription: "false",
38528
38559
  },
38529
38560
  // Basic
38530
38561
  ts.targetOptionDeclaration,
@@ -38644,7 +38675,6 @@ var ts;
38644
38675
  category: ts.Diagnostics.Emit,
38645
38676
  description: ts.Diagnostics.Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output,
38646
38677
  transpileOptionValue: undefined,
38647
- defaultValueDescription: "n/a"
38648
38678
  },
38649
38679
  {
38650
38680
  name: "outDir",
@@ -38655,7 +38685,6 @@ var ts;
38655
38685
  showInSimplifiedHelpView: true,
38656
38686
  category: ts.Diagnostics.Emit,
38657
38687
  description: ts.Diagnostics.Specify_an_output_folder_for_all_emitted_files,
38658
- defaultValueDescription: "n/a"
38659
38688
  },
38660
38689
  {
38661
38690
  name: "rootDir",
@@ -38812,6 +38841,7 @@ var ts;
38812
38841
  strictFlag: true,
38813
38842
  category: ts.Diagnostics.Type_Checking,
38814
38843
  description: ts.Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any,
38844
+ defaultValueDescription: "false",
38815
38845
  },
38816
38846
  {
38817
38847
  name: "alwaysStrict",
@@ -38844,7 +38874,8 @@ var ts;
38844
38874
  type: "boolean",
38845
38875
  affectsSemanticDiagnostics: true,
38846
38876
  category: ts.Diagnostics.Type_Checking,
38847
- description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined
38877
+ description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
38878
+ defaultValueDescription: "false",
38848
38879
  },
38849
38880
  {
38850
38881
  name: "noImplicitReturns",
@@ -38860,21 +38891,24 @@ var ts;
38860
38891
  affectsBindDiagnostics: true,
38861
38892
  affectsSemanticDiagnostics: true,
38862
38893
  category: ts.Diagnostics.Type_Checking,
38863
- description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements
38894
+ description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
38895
+ defaultValueDescription: "false",
38864
38896
  },
38865
38897
  {
38866
38898
  name: "noUncheckedIndexedAccess",
38867
38899
  type: "boolean",
38868
38900
  affectsSemanticDiagnostics: true,
38869
38901
  category: ts.Diagnostics.Type_Checking,
38870
- description: ts.Diagnostics.Include_undefined_in_index_signature_results
38902
+ description: ts.Diagnostics.Include_undefined_in_index_signature_results,
38903
+ defaultValueDescription: "false",
38871
38904
  },
38872
38905
  {
38873
38906
  name: "noImplicitOverride",
38874
38907
  type: "boolean",
38875
38908
  affectsSemanticDiagnostics: true,
38876
38909
  category: ts.Diagnostics.Type_Checking,
38877
- description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier
38910
+ description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
38911
+ defaultValueDescription: "false",
38878
38912
  },
38879
38913
  {
38880
38914
  name: "noPropertyAccessFromIndexSignature",
@@ -38983,7 +39017,7 @@ var ts;
38983
39017
  type: "boolean",
38984
39018
  category: ts.Diagnostics.Interop_Constraints,
38985
39019
  description: ts.Diagnostics.Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node,
38986
- defaultValueDescription: "n/a"
39020
+ defaultValueDescription: "false",
38987
39021
  },
38988
39022
  {
38989
39023
  name: "allowUmdGlobalAccess",
@@ -39032,7 +39066,8 @@ var ts;
39032
39066
  type: "boolean",
39033
39067
  affectsSemanticDiagnostics: true,
39034
39068
  category: ts.Diagnostics.Language_and_Environment,
39035
- description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators
39069
+ description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
39070
+ defaultValueDescription: "false",
39036
39071
  },
39037
39072
  {
39038
39073
  name: "emitDecoratorMetadata",
@@ -39040,7 +39075,8 @@ var ts;
39040
39075
  affectsSemanticDiagnostics: true,
39041
39076
  affectsEmit: true,
39042
39077
  category: ts.Diagnostics.Language_and_Environment,
39043
- description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files
39078
+ description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
39079
+ defaultValueDescription: "false",
39044
39080
  },
39045
39081
  // Advanced
39046
39082
  {
@@ -39083,7 +39119,6 @@ var ts;
39083
39119
  category: ts.Diagnostics.Backwards_Compatibility,
39084
39120
  paramType: ts.Diagnostics.FILE,
39085
39121
  transpileOptionValue: undefined,
39086
- defaultValueDescription: "n/a",
39087
39122
  description: ts.Diagnostics.Deprecated_setting_Use_outFile_instead,
39088
39123
  },
39089
39124
  {
@@ -39164,6 +39199,7 @@ var ts;
39164
39199
  affectsEmit: true,
39165
39200
  category: ts.Diagnostics.Emit,
39166
39201
  description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
39202
+ defaultValueDescription: "false",
39167
39203
  },
39168
39204
  {
39169
39205
  name: "disableSizeLimit",
@@ -39178,21 +39214,24 @@ var ts;
39178
39214
  type: "boolean",
39179
39215
  isTSConfigOnly: true,
39180
39216
  category: ts.Diagnostics.Projects,
39181
- description: ts.Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects
39217
+ description: ts.Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects,
39218
+ defaultValueDescription: "false",
39182
39219
  },
39183
39220
  {
39184
39221
  name: "disableSolutionSearching",
39185
39222
  type: "boolean",
39186
39223
  isTSConfigOnly: true,
39187
39224
  category: ts.Diagnostics.Projects,
39188
- description: ts.Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing
39225
+ description: ts.Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing,
39226
+ defaultValueDescription: "false",
39189
39227
  },
39190
39228
  {
39191
39229
  name: "disableReferencedProjectLoad",
39192
39230
  type: "boolean",
39193
39231
  isTSConfigOnly: true,
39194
39232
  category: ts.Diagnostics.Projects,
39195
- description: ts.Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript
39233
+ description: ts.Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript,
39234
+ defaultValueDescription: "false",
39196
39235
  },
39197
39236
  {
39198
39237
  name: "noImplicitUseStrict",
@@ -39225,7 +39264,7 @@ var ts;
39225
39264
  affectsEmit: true,
39226
39265
  category: ts.Diagnostics.Emit,
39227
39266
  description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
39228
- defaultValueDescription: "n/a"
39267
+ defaultValueDescription: "false",
39229
39268
  },
39230
39269
  {
39231
39270
  name: "declarationDir",
@@ -39236,7 +39275,6 @@ var ts;
39236
39275
  category: ts.Diagnostics.Emit,
39237
39276
  transpileOptionValue: undefined,
39238
39277
  description: ts.Diagnostics.Specify_the_output_directory_for_generated_declaration_files,
39239
- defaultValueDescription: "n/a"
39240
39278
  },
39241
39279
  {
39242
39280
  name: "skipLibCheck",
@@ -39318,6 +39356,7 @@ var ts;
39318
39356
  affectsEmit: true,
39319
39357
  category: ts.Diagnostics.Emit,
39320
39358
  description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
39359
+ defaultValueDescription: "false",
39321
39360
  },
39322
39361
  {
39323
39362
  name: "keyofStringsOnly",
@@ -39365,27 +39404,31 @@ var ts;
39365
39404
  shortName: "v",
39366
39405
  category: ts.Diagnostics.Command_line_Options,
39367
39406
  description: ts.Diagnostics.Enable_verbose_logging,
39368
- type: "boolean"
39407
+ type: "boolean",
39408
+ defaultValueDescription: "false",
39369
39409
  },
39370
39410
  {
39371
39411
  name: "dry",
39372
39412
  shortName: "d",
39373
39413
  category: ts.Diagnostics.Command_line_Options,
39374
39414
  description: ts.Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
39375
- type: "boolean"
39415
+ type: "boolean",
39416
+ defaultValueDescription: "false",
39376
39417
  },
39377
39418
  {
39378
39419
  name: "force",
39379
39420
  shortName: "f",
39380
39421
  category: ts.Diagnostics.Command_line_Options,
39381
39422
  description: ts.Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
39382
- type: "boolean"
39423
+ type: "boolean",
39424
+ defaultValueDescription: "false",
39383
39425
  },
39384
39426
  {
39385
39427
  name: "clean",
39386
39428
  category: ts.Diagnostics.Command_line_Options,
39387
39429
  description: ts.Diagnostics.Delete_the_outputs_of_all_projects,
39388
- type: "boolean"
39430
+ type: "boolean",
39431
+ defaultValueDescription: "false",
39389
39432
  }
39390
39433
  ];
39391
39434
  /* @internal */
@@ -39398,10 +39441,12 @@ var ts;
39398
39441
  */
39399
39442
  name: "enableAutoDiscovery",
39400
39443
  type: "boolean",
39444
+ defaultValueDescription: "false",
39401
39445
  },
39402
39446
  {
39403
39447
  name: "enable",
39404
39448
  type: "boolean",
39449
+ defaultValueDescription: "false",
39405
39450
  },
39406
39451
  {
39407
39452
  name: "include",
@@ -39422,6 +39467,7 @@ var ts;
39422
39467
  {
39423
39468
  name: "disableFilenameBasedTypeAcquisition",
39424
39469
  type: "boolean",
39470
+ defaultValueDescription: "false",
39425
39471
  },
39426
39472
  ];
39427
39473
  /*@internal*/
@@ -49687,7 +49733,8 @@ var ts;
49687
49733
  ((_d = ts.findAncestor(location, ts.isExportDeclaration)) === null || _d === void 0 ? void 0 : _d.moduleSpecifier) ||
49688
49734
  ((_e = (ts.isModuleDeclaration(location) ? location : location.parent && ts.isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)) === null || _e === void 0 ? void 0 : _e.name) ||
49689
49735
  ((_f = (ts.isLiteralImportTypeNode(location) ? location : undefined)) === null || _f === void 0 ? void 0 : _f.argument.literal);
49690
- var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : undefined); // TODO: GH#18217
49736
+ var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
49737
+ var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode); // TODO: GH#18217
49691
49738
  var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
49692
49739
  var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
49693
49740
  if (sourceFile) {
@@ -51113,7 +51160,7 @@ var ts;
51113
51160
  var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode);
51114
51161
  var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined;
51115
51162
  var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context);
51116
- var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode);
51163
+ var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
51117
51164
  context.approximateLength += 10;
51118
51165
  return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
51119
51166
  }
@@ -58007,7 +58054,7 @@ var ts;
58007
58054
  return false;
58008
58055
  switch (node.kind) {
58009
58056
  case 79 /* Identifier */:
58010
- return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol;
58057
+ return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol;
58011
58058
  case 166 /* PropertyDeclaration */:
58012
58059
  case 168 /* MethodDeclaration */:
58013
58060
  case 171 /* GetAccessor */:
@@ -60546,12 +60593,6 @@ var ts;
60546
60593
  }
60547
60594
  return type[cache] = type;
60548
60595
  }
60549
- function isConditionalTypeAlwaysTrueDisregardingInferTypes(type) {
60550
- var extendsInferParamMapper = type.root.inferTypeParameters && createTypeMapper(type.root.inferTypeParameters, ts.map(type.root.inferTypeParameters, function () { return wildcardType; }));
60551
- var checkType = type.checkType;
60552
- var extendsType = type.extendsType;
60553
- return isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(instantiateType(extendsType, extendsInferParamMapper)));
60554
- }
60555
60596
  function getSimplifiedConditionalType(type, writing) {
60556
60597
  var checkType = type.checkType;
60557
60598
  var extendsType = type.extendsType;
@@ -60860,6 +60901,10 @@ var ts;
60860
60901
  }
60861
60902
  return result;
60862
60903
  }
60904
+ function isDistributionDependent(root) {
60905
+ return root.isDistributive && (isTypeParameterPossiblyReferenced(root.checkType, root.node.trueType) ||
60906
+ isTypeParameterPossiblyReferenced(root.checkType, root.node.falseType));
60907
+ }
60863
60908
  function getTypeFromConditionalTypeNode(node) {
60864
60909
  var links = getNodeLinks(node);
60865
60910
  if (!links.resolvedType) {
@@ -64009,32 +64054,28 @@ var ts;
64009
64054
  }
64010
64055
  }
64011
64056
  else if (target.flags & 16777216 /* Conditional */) {
64012
- var c = target;
64013
- // Check if the conditional is always true or always false but still deferred for distribution purposes
64014
- var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
64015
- var skipFalse = !skipTrue && isConditionalTypeAlwaysTrueDisregardingInferTypes(c);
64016
- // Instantiate with a replacement mapper if the conditional is distributive, replacing the check type with a clone of itself,
64017
- // this way {x: string | number, y: string | number} -> (T extends T ? { x: T, y: T } : never) appropriately _fails_ when
64018
- // T = string | number (since that will end up distributing and producing `{x: string, y: string} | {x: number, y: number}`,
64019
- // to which `{x: string | number, y: string | number}` isn't assignable)
64020
- var distributionMapper = void 0;
64021
- var checkVar = getActualTypeVariable(c.root.checkType);
64022
- if (c.root.isDistributive && checkVar.flags & 262144 /* TypeParameter */) {
64023
- var newParam = cloneTypeParameter(checkVar);
64024
- distributionMapper = prependTypeMapping(checkVar, newParam, c.mapper);
64025
- newParam.mapper = distributionMapper;
64026
- }
64027
- // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
64028
- var expanding = isDeeplyNestedType(target, targetStack, targetDepth);
64029
- var localResult = expanding ? 3 /* Maybe */ : undefined;
64030
- if (skipTrue || expanding || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false))) {
64031
- if (!skipFalse && !expanding) {
64032
- localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
64033
- }
64034
- }
64035
- if (localResult) {
64057
+ // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
64058
+ // conditional type and bail out with a Ternary.Maybe result.
64059
+ if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
64036
64060
  resetErrorInfo(saveErrorInfo);
64037
- return localResult;
64061
+ return 3 /* Maybe */;
64062
+ }
64063
+ var c = target;
64064
+ // We check for a relationship to a conditional type target only when the conditional type has no
64065
+ // 'infer' positions and is not distributive or is distributive but doesn't reference the check type
64066
+ // parameter in either of the result types.
64067
+ if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
64068
+ // Check if the conditional is always true or always false but still deferred for distribution purposes.
64069
+ var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
64070
+ var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
64071
+ // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
64072
+ if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
64073
+ result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
64074
+ if (result) {
64075
+ resetErrorInfo(saveErrorInfo);
64076
+ return result;
64077
+ }
64078
+ }
64038
64079
  }
64039
64080
  }
64040
64081
  else if (target.flags & 134217728 /* TemplateLiteral */) {
@@ -64105,33 +64146,34 @@ var ts;
64105
64146
  }
64106
64147
  }
64107
64148
  else if (source.flags & 16777216 /* Conditional */) {
64149
+ // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
64150
+ // conditional type and bail out with a Ternary.Maybe result.
64151
+ if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
64152
+ resetErrorInfo(saveErrorInfo);
64153
+ return 3 /* Maybe */;
64154
+ }
64108
64155
  if (target.flags & 16777216 /* Conditional */) {
64109
- // If one of the conditionals under comparison seems to be infinitely expanding, stop comparing it - back out, try
64110
- // the constraint, and failing that, give up trying to relate the two. This is the only way we can handle recursive conditional
64111
- // types, which might expand forever.
64112
- if (!isDeeplyNestedType(source, sourceStack, sourceDepth) && !isDeeplyNestedType(target, targetStack, targetDepth)) {
64113
- // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
64114
- // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
64115
- // and Y1 is related to Y2.
64116
- var sourceParams = source.root.inferTypeParameters;
64117
- var sourceExtends = source.extendsType;
64118
- var mapper = void 0;
64119
- if (sourceParams) {
64120
- // If the source has infer type parameters, we instantiate them in the context of the target
64121
- var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker);
64122
- inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
64123
- sourceExtends = instantiateType(sourceExtends, ctx.mapper);
64124
- mapper = ctx.mapper;
64125
- }
64126
- if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
64127
- (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) {
64128
- if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) {
64129
- result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
64130
- }
64131
- if (result) {
64132
- resetErrorInfo(saveErrorInfo);
64133
- return result;
64134
- }
64156
+ // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
64157
+ // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
64158
+ // and Y1 is related to Y2.
64159
+ var sourceParams = source.root.inferTypeParameters;
64160
+ var sourceExtends = source.extendsType;
64161
+ var mapper = void 0;
64162
+ if (sourceParams) {
64163
+ // If the source has infer type parameters, we instantiate them in the context of the target
64164
+ var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker);
64165
+ inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
64166
+ sourceExtends = instantiateType(sourceExtends, ctx.mapper);
64167
+ mapper = ctx.mapper;
64168
+ }
64169
+ if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
64170
+ (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) {
64171
+ if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) {
64172
+ result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
64173
+ }
64174
+ if (result) {
64175
+ resetErrorInfo(saveErrorInfo);
64176
+ return result;
64135
64177
  }
64136
64178
  }
64137
64179
  }
@@ -64146,17 +64188,13 @@ var ts;
64146
64188
  }
64147
64189
  }
64148
64190
  }
64149
- // We'll repeatedly decompose source side conditionals if they're recursive - check if we've already recured on the constraint a lot and, if so, bail
64150
- // on the comparison.
64151
- if (!isDeeplyNestedType(source, sourceStack, sourceDepth)) {
64152
- // conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
64153
- // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
64154
- var defaultConstraint = getDefaultConstraintOfConditionalType(source);
64155
- if (defaultConstraint) {
64156
- if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
64157
- resetErrorInfo(saveErrorInfo);
64158
- return result;
64159
- }
64191
+ // conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
64192
+ // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
64193
+ var defaultConstraint = getDefaultConstraintOfConditionalType(source);
64194
+ if (defaultConstraint) {
64195
+ if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
64196
+ resetErrorInfo(saveErrorInfo);
64197
+ return result;
64160
64198
  }
64161
64199
  }
64162
64200
  }
@@ -65265,14 +65303,15 @@ var ts;
65265
65303
  // `type A<T> = null extends T ? [A<NonNullable<T>>] : [T]`
65266
65304
  // has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`
65267
65305
  // in such cases we need to terminate the expansion, and we do so here.
65268
- function isDeeplyNestedType(type, stack, depth) {
65269
- if (depth >= 5) {
65306
+ function isDeeplyNestedType(type, stack, depth, maxDepth) {
65307
+ if (maxDepth === void 0) { maxDepth = 5; }
65308
+ if (depth >= maxDepth) {
65270
65309
  var identity_1 = getRecursionIdentity(type);
65271
65310
  var count = 0;
65272
65311
  for (var i = 0; i < depth; i++) {
65273
65312
  if (getRecursionIdentity(stack[i]) === identity_1) {
65274
65313
  count++;
65275
- if (count >= 5) {
65314
+ if (count >= maxDepth) {
65276
65315
  return true;
65277
65316
  }
65278
65317
  }
@@ -67183,17 +67222,16 @@ var ts;
67183
67222
  var inferredType = void 0;
67184
67223
  var signature = context.signature;
67185
67224
  if (signature) {
67186
- var inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined;
67225
+ var inferredCovariantType_1 = inference.candidates ? getCovariantInference(inference, signature) : undefined;
67187
67226
  if (inference.contraCandidates) {
67188
- var inferredContravariantType = getContravariantInference(inference);
67189
67227
  // If we have both co- and contra-variant inferences, we prefer the contra-variant inference
67190
- // unless the co-variant inference is a subtype and not 'never'.
67191
- inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072 /* Never */) &&
67192
- isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ?
67193
- inferredCovariantType : inferredContravariantType;
67228
+ // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'.
67229
+ inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) &&
67230
+ ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ?
67231
+ inferredCovariantType_1 : getContravariantInference(inference);
67194
67232
  }
67195
- else if (inferredCovariantType) {
67196
- inferredType = inferredCovariantType;
67233
+ else if (inferredCovariantType_1) {
67234
+ inferredType = inferredCovariantType_1;
67197
67235
  }
67198
67236
  else if (context.flags & 1 /* NoDefault */) {
67199
67237
  // We use silentNeverType as the wildcard that signals no inferences.
@@ -67492,8 +67530,9 @@ var ts;
67492
67530
  // constituent types keyed by the literal types of the property by that name in each constituent type.
67493
67531
  function getKeyPropertyName(unionType) {
67494
67532
  var types = unionType.types;
67495
- // We only construct maps for large unions with non-primitive constituents.
67496
- if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */) {
67533
+ // We only construct maps for unions with many non-primitive constituents.
67534
+ if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */ ||
67535
+ ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) {
67497
67536
  return undefined;
67498
67537
  }
67499
67538
  if (unionType.keyPropertyName === undefined) {
@@ -67526,7 +67565,7 @@ var ts;
67526
67565
  var keyPropertyName = getKeyPropertyName(unionType);
67527
67566
  var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 294 /* PropertyAssignment */ &&
67528
67567
  p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); });
67529
- var propType = propNode && getTypeOfExpression(propNode.initializer);
67568
+ var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer);
67530
67569
  return propType && getConstituentTypeForKeyType(unionType, propType);
67531
67570
  }
67532
67571
  function isOrContainsMatchingReference(source, target) {
@@ -70761,7 +70800,7 @@ var ts;
70761
70800
  return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 294 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
70762
70801
  }
70763
70802
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
70764
- return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 284 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
70803
+ return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 284 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType);
70765
70804
  }
70766
70805
  // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily
70767
70806
  // be "pushed" onto a node using the contextualType property.
@@ -71316,6 +71355,10 @@ var ts;
71316
71355
  function checkComputedPropertyName(node) {
71317
71356
  var links = getNodeLinks(node.expression);
71318
71357
  if (!links.resolvedType) {
71358
+ if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent))
71359
+ && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */) {
71360
+ return links.resolvedType = errorType;
71361
+ }
71319
71362
  links.resolvedType = checkExpression(node.expression);
71320
71363
  // The computed property name of a non-static class field within a loop must be stored in a block-scoped binding.
71321
71364
  // (It needs to be bound at class evaluation time.)
@@ -72785,7 +72828,7 @@ var ts;
72785
72828
  if (relatedInfo) {
72786
72829
  ts.addRelatedInfo(resultDiagnostic, relatedInfo);
72787
72830
  }
72788
- addErrorOrSuggestion(!isUncheckedJS, resultDiagnostic);
72831
+ addErrorOrSuggestion(!isUncheckedJS || errorInfo.code !== ts.Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code, resultDiagnostic);
72789
72832
  }
72790
72833
  function containerSeemsToBeEmptyDomElement(containingType) {
72791
72834
  return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) &&
@@ -77315,6 +77358,7 @@ var ts;
77315
77358
  var parent = node.parent;
77316
77359
  return ts.isAssertionExpression(parent) && ts.isConstTypeReference(parent.type) ||
77317
77360
  ts.isJSDocTypeAssertion(parent) && ts.isConstTypeReference(ts.getJSDocTypeAssertionType(parent)) ||
77361
+ ts.isComputedPropertyName(parent) ||
77318
77362
  (ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isSpreadElement(parent)) && isConstContext(parent) ||
77319
77363
  (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent) || ts.isTemplateSpan(parent)) && isConstContext(parent.parent);
77320
77364
  }
@@ -78370,7 +78414,7 @@ var ts;
78370
78414
  ts.forEach(node.members, checkSourceElement);
78371
78415
  if (produceDiagnostics) {
78372
78416
  var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
78373
- checkIndexConstraints(type);
78417
+ checkIndexConstraints(type, type.symbol);
78374
78418
  checkTypeForDuplicateIndexSignatures(node);
78375
78419
  checkObjectTypeForDuplicateDeclarations(node);
78376
78420
  }
@@ -78465,6 +78509,7 @@ var ts;
78465
78509
  checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node);
78466
78510
  }
78467
78511
  function checkMappedType(node) {
78512
+ checkGrammarMappedType(node);
78468
78513
  checkSourceElement(node.typeParameter);
78469
78514
  checkSourceElement(node.nameType);
78470
78515
  checkSourceElement(node.type);
@@ -78481,6 +78526,12 @@ var ts;
78481
78526
  checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter));
78482
78527
  }
78483
78528
  }
78529
+ function checkGrammarMappedType(node) {
78530
+ var _a;
78531
+ if ((_a = node.members) === null || _a === void 0 ? void 0 : _a.length) {
78532
+ return grammarErrorOnNode(node.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods);
78533
+ }
78534
+ }
78484
78535
  function checkThisType(node) {
78485
78536
  getTypeFromThisTypeNode(node);
78486
78537
  }
@@ -81426,7 +81477,7 @@ var ts;
81426
81477
  checkBlock(node.finallyBlock);
81427
81478
  }
81428
81479
  }
81429
- function checkIndexConstraints(type, isStaticIndex) {
81480
+ function checkIndexConstraints(type, symbol, isStaticIndex) {
81430
81481
  var indexInfos = getIndexInfosOfType(type);
81431
81482
  if (indexInfos.length === 0) {
81432
81483
  return;
@@ -81437,15 +81488,15 @@ var ts;
81437
81488
  checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop));
81438
81489
  }
81439
81490
  }
81440
- var typeDeclaration = type.symbol.valueDeclaration;
81491
+ var typeDeclaration = symbol.valueDeclaration;
81441
81492
  if (typeDeclaration && ts.isClassLike(typeDeclaration)) {
81442
81493
  for (var _b = 0, _c = typeDeclaration.members; _b < _c.length; _b++) {
81443
81494
  var member = _c[_b];
81444
81495
  // Only process instance properties with computed names here. Static properties cannot be in conflict with indexers,
81445
81496
  // and properties with literal names were already checked.
81446
81497
  if (!ts.isStatic(member) && !hasBindableName(member)) {
81447
- var symbol = getSymbolOfNode(member);
81448
- checkIndexConstraintForProperty(type, symbol, getTypeOfExpression(member.name.expression), getNonMissingTypeOfSymbol(symbol));
81498
+ var symbol_3 = getSymbolOfNode(member);
81499
+ checkIndexConstraintForProperty(type, symbol_3, getTypeOfExpression(member.name.expression), getNonMissingTypeOfSymbol(symbol_3));
81449
81500
  }
81450
81501
  }
81451
81502
  }
@@ -81761,8 +81812,8 @@ var ts;
81761
81812
  }
81762
81813
  }
81763
81814
  if (produceDiagnostics) {
81764
- checkIndexConstraints(type);
81765
- checkIndexConstraints(staticType, /*isStaticIndex*/ true);
81815
+ checkIndexConstraints(type, symbol);
81816
+ checkIndexConstraints(staticType, symbol, /*isStaticIndex*/ true);
81766
81817
  checkTypeForDuplicateIndexSignatures(node);
81767
81818
  checkPropertyInitialization(node);
81768
81819
  }
@@ -82153,7 +82204,7 @@ var ts;
82153
82204
  var baseType = _a[_i];
82154
82205
  checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1);
82155
82206
  }
82156
- checkIndexConstraints(type);
82207
+ checkIndexConstraints(type, symbol);
82157
82208
  }
82158
82209
  }
82159
82210
  checkObjectTypeForDuplicateDeclarations(node);
@@ -86344,6 +86395,9 @@ var ts;
86344
86395
  }
86345
86396
  }
86346
86397
  function checkGrammarProperty(node) {
86398
+ if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) {
86399
+ return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods);
86400
+ }
86347
86401
  if (ts.isClassLike(node.parent)) {
86348
86402
  if (ts.isStringLiteral(node.name) && node.name.text === "constructor") {
86349
86403
  return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor);
@@ -86363,7 +86417,7 @@ var ts;
86363
86417
  return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer);
86364
86418
  }
86365
86419
  }
86366
- else if (node.parent.kind === 181 /* TypeLiteral */) {
86420
+ else if (ts.isTypeLiteralNode(node.parent)) {
86367
86421
  if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) {
86368
86422
  return true;
86369
86423
  }
@@ -87040,7 +87094,7 @@ var ts;
87040
87094
  return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode));
87041
87095
  case 194 /* MappedType */:
87042
87096
  ts.Debug.type(node);
87043
- return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
87097
+ return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement));
87044
87098
  case 195 /* LiteralType */:
87045
87099
  ts.Debug.type(node);
87046
87100
  return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression));
@@ -95027,51 +95081,25 @@ var ts;
95027
95081
  return tagTransform(node.openingFragment, node.children, isChild, /*location*/ node);
95028
95082
  }
95029
95083
  function convertJsxChildrenToChildrenPropObject(children) {
95084
+ var prop = convertJsxChildrenToChildrenPropAssignment(children);
95085
+ return prop && factory.createObjectLiteralExpression([prop]);
95086
+ }
95087
+ function convertJsxChildrenToChildrenPropAssignment(children) {
95030
95088
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95031
95089
  if (ts.length(nonWhitespaceChildren) === 1) {
95032
95090
  var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
95033
- return result_13 && factory.createObjectLiteralExpression([
95034
- factory.createPropertyAssignment("children", result_13)
95035
- ]);
95091
+ return result_13 && factory.createPropertyAssignment("children", result_13);
95036
95092
  }
95037
95093
  var result = ts.mapDefined(children, transformJsxChildToExpression);
95038
- return !result.length ? undefined : factory.createObjectLiteralExpression([
95039
- factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result))
95040
- ]);
95094
+ return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
95041
95095
  }
95042
95096
  function visitJsxOpeningLikeElementJSX(node, children, isChild, location) {
95043
95097
  var tagName = getTagName(node);
95044
- var objectProperties;
95098
+ var childrenProp = children && children.length ? convertJsxChildrenToChildrenPropAssignment(children) : undefined;
95045
95099
  var keyAttr = ts.find(node.attributes.properties, function (p) { return !!p.name && ts.isIdentifier(p.name) && p.name.escapedText === "key"; });
95046
95100
  var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
95047
- var segments = [];
95048
- if (attrs.length) {
95049
- // Map spans of JsxAttribute nodes into object literals and spans
95050
- // of JsxSpreadAttribute nodes into expressions.
95051
- segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
95052
- ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
95053
- : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
95054
- if (ts.isJsxSpreadAttribute(attrs[0])) {
95055
- // We must always emit at least one object literal before a spread
95056
- // argument.factory.createObjectLiteral
95057
- segments.unshift(factory.createObjectLiteralExpression());
95058
- }
95059
- }
95060
- if (children && children.length) {
95061
- var result = convertJsxChildrenToChildrenPropObject(children);
95062
- if (result) {
95063
- segments.push(result);
95064
- }
95065
- }
95066
- if (segments.length === 0) {
95067
- objectProperties = factory.createObjectLiteralExpression([]);
95068
- // When there are no attributes, React wants {}
95069
- }
95070
- else {
95071
- // Either emit one big object literal (no spread attribs), or
95072
- // a call to the __assign helper.
95073
- objectProperties = ts.singleOrUndefined(segments) || emitHelpers().createAssignHelper(segments);
95074
- }
95101
+ var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs, childrenProp) :
95102
+ factory.createObjectLiteralExpression(childrenProp ? [childrenProp] : ts.emptyArray); // When there are no attributes, React wants {}
95075
95103
  return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location);
95076
95104
  }
95077
95105
  function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) {
@@ -95100,38 +95128,9 @@ var ts;
95100
95128
  }
95101
95129
  function visitJsxOpeningLikeElementCreateElement(node, children, isChild, location) {
95102
95130
  var tagName = getTagName(node);
95103
- var objectProperties;
95104
95131
  var attrs = node.attributes.properties;
95105
- if (attrs.length === 0) {
95106
- objectProperties = factory.createNull();
95107
- // When there are no attributes, React wants "null"
95108
- }
95109
- else {
95110
- var target = ts.getEmitScriptTarget(compilerOptions);
95111
- if (target && target >= 5 /* ES2018 */) {
95112
- objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
95113
- return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement);
95114
- })));
95115
- }
95116
- else {
95117
- // Map spans of JsxAttribute nodes into object literals and spans
95118
- // of JsxSpreadAttribute nodes into expressions.
95119
- var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
95120
- ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
95121
- : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
95122
- if (ts.isJsxSpreadAttribute(attrs[0])) {
95123
- // We must always emit at least one object literal before a spread
95124
- // argument.factory.createObjectLiteral
95125
- segments.unshift(factory.createObjectLiteralExpression());
95126
- }
95127
- // Either emit one big object literal (no spread attribs), or
95128
- // a call to the __assign helper.
95129
- objectProperties = ts.singleOrUndefined(segments);
95130
- if (!objectProperties) {
95131
- objectProperties = emitHelpers().createAssignHelper(segments);
95132
- }
95133
- }
95134
- }
95132
+ var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs) :
95133
+ factory.createNull(); // When there are no attributes, React wants "null"
95135
95134
  var callee = currentFileState.importSpecifier === undefined
95136
95135
  ? ts.createJsxFactoryExpression(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217
95137
95136
  node)
@@ -95164,6 +95163,36 @@ var ts;
95164
95163
  function transformJsxSpreadAttributeToSpreadAssignment(node) {
95165
95164
  return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression));
95166
95165
  }
95166
+ function transformJsxAttributesToObjectProps(attrs, children) {
95167
+ var target = ts.getEmitScriptTarget(compilerOptions);
95168
+ return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) :
95169
+ transformJsxAttributesToExpression(attrs, children);
95170
+ }
95171
+ function transformJsxAttributesToProps(attrs, children) {
95172
+ var props = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
95173
+ return ts.map(attrs, function (attr) { return isSpread ? transformJsxSpreadAttributeToSpreadAssignment(attr) : transformJsxAttributeToObjectLiteralElement(attr); });
95174
+ }));
95175
+ if (children) {
95176
+ props.push(children);
95177
+ }
95178
+ return props;
95179
+ }
95180
+ function transformJsxAttributesToExpression(attrs, children) {
95181
+ // Map spans of JsxAttribute nodes into object literals and spans
95182
+ // of JsxSpreadAttribute nodes into expressions.
95183
+ var expressions = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
95184
+ ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
95185
+ : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
95186
+ if (ts.isJsxSpreadAttribute(attrs[0])) {
95187
+ // We must always emit at least one object literal before a spread
95188
+ // argument.factory.createObjectLiteral
95189
+ expressions.unshift(factory.createObjectLiteralExpression());
95190
+ }
95191
+ if (children) {
95192
+ expressions.push(factory.createObjectLiteralExpression([children]));
95193
+ }
95194
+ return ts.singleOrUndefined(expressions) || emitHelpers().createAssignHelper(expressions);
95195
+ }
95167
95196
  function transformJsxSpreadAttributeToExpression(node) {
95168
95197
  return ts.visitNode(node.expression, visitor, ts.isExpression);
95169
95198
  }
@@ -98579,78 +98608,17 @@ var ts;
98579
98608
  * @param node A TemplateExpression node.
98580
98609
  */
98581
98610
  function visitTemplateExpression(node) {
98582
- var expressions = [];
98583
- addTemplateHead(expressions, node);
98584
- addTemplateSpans(expressions, node);
98585
- // createAdd will check if each expression binds less closely than binary '+'.
98586
- // If it does, it wraps the expression in parentheses. Otherwise, something like
98587
- // `abc${ 1 << 2 }`
98588
- // becomes
98589
- // "abc" + 1 << 2 + ""
98590
- // which is really
98591
- // ("abc" + 1) << (2 + "")
98592
- // rather than
98593
- // "abc" + (1 << 2) + ""
98594
- var expression = ts.reduceLeft(expressions, factory.createAdd);
98595
- if (ts.nodeIsSynthesized(expression)) {
98596
- ts.setTextRange(expression, node);
98597
- }
98598
- return expression;
98599
- }
98600
- /**
98601
- * Gets a value indicating whether we need to include the head of a TemplateExpression.
98602
- *
98603
- * @param node A TemplateExpression node.
98604
- */
98605
- function shouldAddTemplateHead(node) {
98606
- // If this expression has an empty head literal and the first template span has a non-empty
98607
- // literal, then emitting the empty head literal is not necessary.
98608
- // `${ foo } and ${ bar }`
98609
- // can be emitted as
98610
- // foo + " and " + bar
98611
- // This is because it is only required that one of the first two operands in the emit
98612
- // output must be a string literal, so that the other operand and all following operands
98613
- // are forced into strings.
98614
- //
98615
- // If the first template span has an empty literal, then the head must still be emitted.
98616
- // `${ foo }${ bar }`
98617
- // must still be emitted as
98618
- // "" + foo + bar
98619
- // There is always atleast one templateSpan in this code path, since
98620
- // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral()
98621
- ts.Debug.assert(node.templateSpans.length !== 0);
98622
- return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
98623
- }
98624
- /**
98625
- * Adds the head of a TemplateExpression to an array of expressions.
98626
- *
98627
- * @param expressions An array of expressions.
98628
- * @param node A TemplateExpression node.
98629
- */
98630
- function addTemplateHead(expressions, node) {
98631
- if (!shouldAddTemplateHead(node)) {
98632
- return;
98633
- }
98634
- expressions.push(factory.createStringLiteral(node.head.text));
98635
- }
98636
- /**
98637
- * Visits and adds the template spans of a TemplateExpression to an array of expressions.
98638
- *
98639
- * @param expressions An array of expressions.
98640
- * @param node A TemplateExpression node.
98641
- */
98642
- function addTemplateSpans(expressions, node) {
98611
+ var expression = factory.createStringLiteral(node.head.text);
98643
98612
  for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
98644
98613
  var span = _a[_i];
98645
- expressions.push(ts.visitNode(span.expression, visitor, ts.isExpression));
98646
- // Only emit if the literal is non-empty.
98647
- // The binary '+' operator is left-associative, so the first string concatenation
98648
- // with the head will force the result up to this point to be a string.
98649
- // Emitting a '+ ""' has no semantic effect for middles and tails.
98650
- if (span.literal.text.length !== 0) {
98651
- expressions.push(factory.createStringLiteral(span.literal.text));
98614
+ var args = [ts.visitNode(span.expression, visitor, ts.isExpression)];
98615
+ if (span.literal.text.length > 0) {
98616
+ args.push(factory.createStringLiteral(span.literal.text));
98652
98617
  }
98618
+ expression = factory.createCallExpression(factory.createPropertyAccessExpression(expression, "concat"),
98619
+ /*typeArguments*/ undefined, args);
98653
98620
  }
98621
+ return ts.setTextRange(expression, node);
98654
98622
  }
98655
98623
  /**
98656
98624
  * Visits the `super` keyword
@@ -113358,7 +113326,7 @@ var ts;
113358
113326
  break;
113359
113327
  case ts.FileIncludeKind.TypeReferenceDirective:
113360
113328
  (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
113361
- packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), getModeForResolutionAtIndex(file, index))) === null || _g === void 0 ? void 0 : _g.packageId;
113329
+ packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
113362
113330
  break;
113363
113331
  case ts.FileIncludeKind.LibReferenceDirective:
113364
113332
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -120356,6 +120324,9 @@ var ts;
120356
120324
  sourceFilesCache.set(path, false);
120357
120325
  }
120358
120326
  }
120327
+ if (sourceFile) {
120328
+ sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
120329
+ }
120359
120330
  return sourceFile;
120360
120331
  }
120361
120332
  return hostSourceFile.sourceFile;
@@ -124817,14 +124788,14 @@ var ts;
124817
124788
  return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!(s.externalModuleIndicator || s.commonJsModuleIndicator); });
124818
124789
  }
124819
124790
  ts.programContainsModules = programContainsModules;
124820
- function programContainsEs6Modules(program) {
124791
+ function programContainsEsModules(program) {
124821
124792
  return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!s.externalModuleIndicator; });
124822
124793
  }
124823
- ts.programContainsEs6Modules = programContainsEs6Modules;
124824
- function compilerOptionsIndicateEs6Modules(compilerOptions) {
124794
+ ts.programContainsEsModules = programContainsEsModules;
124795
+ function compilerOptionsIndicateEsModules(compilerOptions) {
124825
124796
  return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit;
124826
124797
  }
124827
- ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules;
124798
+ ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules;
124828
124799
  function createModuleSpecifierResolutionHost(program, host) {
124829
124800
  // Mix in `getSymlinkCache` from Program when host doesn't have it
124830
124801
  // in order for non-Project hosts to have a symlinks cache.
@@ -125211,9 +125182,9 @@ var ts;
125211
125182
  return displayPart(text, ts.SymbolDisplayPartKind.linkText);
125212
125183
  }
125213
125184
  ts.linkTextPart = linkTextPart;
125214
- function linkNamePart(name, target) {
125185
+ function linkNamePart(text, target) {
125215
125186
  return {
125216
- text: ts.getTextOfNode(name),
125187
+ text: text,
125217
125188
  kind: ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.linkName],
125218
125189
  target: {
125219
125190
  fileName: ts.getSourceFileOfNode(target).fileName,
@@ -125238,20 +125209,41 @@ var ts;
125238
125209
  }
125239
125210
  else {
125240
125211
  var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name);
125212
+ var suffix = findLinkNameEnd(link.text);
125213
+ var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix);
125214
+ var text = link.text.slice(suffix);
125241
125215
  var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]);
125242
125216
  if (decl) {
125243
- parts.push(linkNamePart(link.name, decl));
125244
- if (link.text)
125245
- parts.push(linkTextPart(link.text));
125217
+ parts.push(linkNamePart(name, decl));
125218
+ if (text)
125219
+ parts.push(linkTextPart(text));
125246
125220
  }
125247
125221
  else {
125248
- parts.push(linkTextPart(ts.getTextOfNode(link.name) + " " + link.text));
125222
+ parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
125249
125223
  }
125250
125224
  }
125251
125225
  parts.push(linkPart("}"));
125252
125226
  return parts;
125253
125227
  }
125254
125228
  ts.buildLinkParts = buildLinkParts;
125229
+ function findLinkNameEnd(text) {
125230
+ if (text.indexOf("()") === 0)
125231
+ return 2;
125232
+ if (text[0] !== "<")
125233
+ return 0;
125234
+ var brackets = 0;
125235
+ var i = 0;
125236
+ while (i < text.length) {
125237
+ if (text[i] === "<")
125238
+ brackets++;
125239
+ if (text[i] === ">")
125240
+ brackets--;
125241
+ i++;
125242
+ if (!brackets)
125243
+ return i;
125244
+ }
125245
+ return 0;
125246
+ }
125255
125247
  var carriageReturnLineFeed = "\r\n";
125256
125248
  /**
125257
125249
  * The default is CRLF.
@@ -126163,11 +126155,12 @@ var ts;
126163
126155
  : ts.getNameForExportedSymbol(namedSymbol, scriptTarget);
126164
126156
  var moduleName = ts.stripQuotes(moduleSymbol.name);
126165
126157
  var id = exportInfoId++;
126158
+ var target = ts.skipAlias(symbol, checker);
126166
126159
  var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol;
126167
126160
  var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
126168
126161
  if (!storedSymbol || !storedModuleSymbol)
126169
126162
  symbols.set(id, [symbol, moduleSymbol]);
126170
- exportInfo.add(key(importedName, symbol, moduleName, checker), {
126163
+ exportInfo.add(key(importedName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
126171
126164
  id: id,
126172
126165
  symbolTableKey: symbolTableKey,
126173
126166
  symbolName: importedName,
@@ -126175,16 +126168,16 @@ var ts;
126175
126168
  moduleFile: moduleFile,
126176
126169
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
126177
126170
  exportKind: exportKind,
126178
- targetFlags: ts.skipAlias(symbol, checker).flags,
126171
+ targetFlags: target.flags,
126179
126172
  isFromPackageJson: isFromPackageJson,
126180
126173
  symbol: storedSymbol,
126181
126174
  moduleSymbol: storedModuleSymbol,
126182
126175
  });
126183
126176
  },
126184
- get: function (importingFile, importedName, symbol, moduleName, checker) {
126177
+ get: function (importingFile, key) {
126185
126178
  if (importingFile !== usableByFileName)
126186
126179
  return;
126187
- var result = exportInfo.get(key(importedName, symbol, moduleName, checker));
126180
+ var result = exportInfo.get(key);
126188
126181
  return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo);
126189
126182
  },
126190
126183
  forEach: function (importingFile, action) {
@@ -126192,7 +126185,7 @@ var ts;
126192
126185
  return;
126193
126186
  exportInfo.forEach(function (info, key) {
126194
126187
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
126195
- action(info.map(rehydrateCachedInfo), symbolName, !!ambientModuleName);
126188
+ action(info.map(rehydrateCachedInfo), symbolName, !!ambientModuleName, key);
126196
126189
  });
126197
126190
  },
126198
126191
  releaseSymbols: function () {
@@ -126257,26 +126250,16 @@ var ts;
126257
126250
  isFromPackageJson: isFromPackageJson,
126258
126251
  };
126259
126252
  }
126260
- function key(importedName, symbol, moduleName, checker) {
126261
- var unquoted = ts.stripQuotes(moduleName);
126262
- var moduleKey = ts.isExternalModuleNameRelative(unquoted) ? "/" : unquoted;
126263
- var target = ts.skipAlias(symbol, checker);
126264
- return importedName + "|" + createSymbolKey(target) + "|" + moduleKey;
126253
+ function key(importedName, symbol, ambientModuleName, checker) {
126254
+ var moduleKey = ambientModuleName || "";
126255
+ return importedName + "|" + ts.getSymbolId(ts.skipAlias(symbol, checker)) + "|" + moduleKey;
126265
126256
  }
126266
126257
  function parseKey(key) {
126267
126258
  var symbolName = key.substring(0, key.indexOf("|"));
126268
126259
  var moduleKey = key.substring(key.lastIndexOf("|") + 1);
126269
- var ambientModuleName = moduleKey === "/" ? undefined : moduleKey;
126260
+ var ambientModuleName = moduleKey === "" ? undefined : moduleKey;
126270
126261
  return { symbolName: symbolName, ambientModuleName: ambientModuleName };
126271
126262
  }
126272
- function createSymbolKey(symbol) {
126273
- var key = symbol.name;
126274
- while (symbol.parent) {
126275
- key += "," + symbol.parent.name;
126276
- symbol = symbol.parent;
126277
- }
126278
- return key;
126279
- }
126280
126263
  function fileIsGlobalOnly(file) {
126281
126264
  return !file.commonJsModuleIndicator && !file.externalModuleIndicator && !file.moduleAugmentations && !file.ambientModuleNames;
126282
126265
  }
@@ -128621,20 +128604,19 @@ var ts;
128621
128604
  }
128622
128605
  }
128623
128606
  Completions.getCompletionsAtPosition = getCompletionsAtPosition;
128607
+ function completionEntryDataIsResolved(data) {
128608
+ return !!(data === null || data === void 0 ? void 0 : data.moduleSpecifier);
128609
+ }
128624
128610
  function continuePreviousIncompleteResponse(cache, file, location, program, host, preferences, cancellationToken) {
128625
- var _a;
128626
128611
  var previousResponse = cache.get();
128627
128612
  if (!previousResponse)
128628
128613
  return undefined;
128629
128614
  var lowerCaseTokenText = location.text.toLowerCase();
128630
128615
  var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
128631
- var checker = program.getTypeChecker();
128632
- var autoImportProvider = (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host);
128633
- var autoImportProviderChecker = autoImportProvider === null || autoImportProvider === void 0 ? void 0 : autoImportProvider.getTypeChecker();
128634
128616
  var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences,
128635
128617
  /*isForImportStatementCompletion*/ false, function (context) {
128636
128618
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
128637
- if (!entry.hasAction || !entry.source || !entry.data || entry.data.moduleSpecifier) {
128619
+ if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) {
128638
128620
  // Not an auto import or already resolved; keep as is
128639
128621
  return entry;
128640
128622
  }
@@ -128642,8 +128624,8 @@ var ts;
128642
128624
  // No longer matches typed characters; filter out
128643
128625
  return undefined;
128644
128626
  }
128645
- var _a = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)), symbol = _a.symbol, origin = _a.origin;
128646
- var info = exportMap.get(file.path, entry.name, symbol, origin.moduleSymbol.name, origin.isFromPackageJson ? autoImportProviderChecker : checker);
128627
+ var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin;
128628
+ var info = exportMap.get(file.path, entry.data.exportMapKey);
128647
128629
  var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
128648
128630
  if (!result)
128649
128631
  return entry;
@@ -128944,13 +128926,54 @@ var ts;
128944
128926
  return text.replace(/\$/gm, "\\$");
128945
128927
  }
128946
128928
  function originToCompletionEntryData(origin) {
128947
- return {
128929
+ var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
128930
+ var isPackageJsonImport = origin.isFromPackageJson ? true : undefined;
128931
+ if (originIsResolvedExport(origin)) {
128932
+ var resolvedData = {
128933
+ exportName: origin.exportName,
128934
+ moduleSpecifier: origin.moduleSpecifier,
128935
+ ambientModuleName: ambientModuleName,
128936
+ fileName: origin.fileName,
128937
+ isPackageJsonImport: isPackageJsonImport,
128938
+ };
128939
+ return resolvedData;
128940
+ }
128941
+ var unresolvedData = {
128948
128942
  exportName: origin.exportName,
128943
+ exportMapKey: origin.exportMapKey,
128949
128944
  fileName: origin.fileName,
128950
128945
  ambientModuleName: origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name),
128951
128946
  isPackageJsonImport: origin.isFromPackageJson ? true : undefined,
128952
- moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined,
128953
128947
  };
128948
+ return unresolvedData;
128949
+ }
128950
+ function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) {
128951
+ var isDefaultExport = data.exportName === "default" /* Default */;
128952
+ var isFromPackageJson = !!data.isPackageJsonImport;
128953
+ if (completionEntryDataIsResolved(data)) {
128954
+ var resolvedOrigin = {
128955
+ kind: 32 /* ResolvedExport */,
128956
+ exportName: data.exportName,
128957
+ moduleSpecifier: data.moduleSpecifier,
128958
+ symbolName: completionName,
128959
+ fileName: data.fileName,
128960
+ moduleSymbol: moduleSymbol,
128961
+ isDefaultExport: isDefaultExport,
128962
+ isFromPackageJson: isFromPackageJson,
128963
+ };
128964
+ return resolvedOrigin;
128965
+ }
128966
+ var unresolvedOrigin = {
128967
+ kind: 4 /* Export */,
128968
+ exportName: data.exportName,
128969
+ exportMapKey: data.exportMapKey,
128970
+ symbolName: completionName,
128971
+ fileName: data.fileName,
128972
+ moduleSymbol: moduleSymbol,
128973
+ isDefaultExport: isDefaultExport,
128974
+ isFromPackageJson: isFromPackageJson,
128975
+ };
128976
+ return unresolvedOrigin;
128954
128977
  }
128955
128978
  function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, contextToken, origin, useSemicolons, options, preferences) {
128956
128979
  var _a, _b, _c;
@@ -129726,6 +129749,7 @@ var ts;
129726
129749
  }
129727
129750
  }
129728
129751
  function addPropertySymbol(symbol, insertAwait, insertQuestionDot) {
129752
+ var _a;
129729
129753
  // For a computed property with an accessible name like `Symbol.iterator`,
129730
129754
  // we'll add a completion for the *name* `Symbol` instead of for the property.
129731
129755
  // If this is e.g. [Symbol.iterator], add a completion for `Symbol`.
@@ -129739,19 +129763,33 @@ var ts;
129739
129763
  var index = symbols.length;
129740
129764
  symbols.push(firstAccessibleSymbol);
129741
129765
  var moduleSymbol = firstAccessibleSymbol.parent;
129742
- if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol)) {
129766
+ if (!moduleSymbol ||
129767
+ !ts.isExternalModuleSymbol(moduleSymbol) ||
129768
+ typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) {
129743
129769
  symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) };
129744
129770
  }
129745
129771
  else {
129746
- var origin = {
129747
- kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */),
129748
- moduleSymbol: moduleSymbol,
129749
- isDefaultExport: false,
129750
- symbolName: firstAccessibleSymbol.name,
129751
- exportName: firstAccessibleSymbol.name,
129752
- fileName: ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? ts.cast(moduleSymbol.valueDeclaration, ts.isSourceFile).fileName : undefined,
129753
- };
129754
- symbolToOriginInfoMap[index] = origin;
129772
+ var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined;
129773
+ var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{
129774
+ exportKind: 0 /* Named */,
129775
+ moduleFileName: fileName,
129776
+ isFromPackageJson: false,
129777
+ moduleSymbol: moduleSymbol,
129778
+ symbol: firstAccessibleSymbol,
129779
+ targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
129780
+ }], sourceFile, program, host, preferences) || {}).moduleSpecifier;
129781
+ if (moduleSpecifier) {
129782
+ var origin = {
129783
+ kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */),
129784
+ moduleSymbol: moduleSymbol,
129785
+ isDefaultExport: false,
129786
+ symbolName: firstAccessibleSymbol.name,
129787
+ exportName: firstAccessibleSymbol.name,
129788
+ fileName: fileName,
129789
+ moduleSpecifier: moduleSpecifier,
129790
+ };
129791
+ symbolToOriginInfoMap[index] = origin;
129792
+ }
129755
129793
  }
129756
129794
  }
129757
129795
  else if (preferences.includeCompletionsWithInsertText) {
@@ -129908,11 +129946,11 @@ var ts;
129908
129946
  // If not already a module, must have modules enabled.
129909
129947
  if (!preferences.includeCompletionsForModuleExports)
129910
129948
  return false;
129911
- // If already using ES6 modules, OK to continue using them.
129949
+ // If already using ES modules, OK to continue using them.
129912
129950
  if (sourceFile.externalModuleIndicator || sourceFile.commonJsModuleIndicator)
129913
129951
  return true;
129914
129952
  // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK.
129915
- if (ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()))
129953
+ if (ts.compilerOptionsIndicateEsModules(program.getCompilerOptions()))
129916
129954
  return true;
129917
129955
  // If some file is using ES6 modules, assume that it's OK to add more.
129918
129956
  return ts.programContainsModules(program);
@@ -129987,7 +130025,7 @@ var ts;
129987
130025
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
129988
130026
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
129989
130027
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
129990
- exportInfo.forEach(sourceFile.path, function (info, symbolName, isFromAmbientModule) {
130028
+ exportInfo.forEach(sourceFile.path, function (info, symbolName, isFromAmbientModule, exportMapKey) {
129991
130029
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
129992
130030
  return;
129993
130031
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
@@ -130012,6 +130050,7 @@ var ts;
130012
130050
  kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
130013
130051
  moduleSpecifier: moduleSpecifier,
130014
130052
  symbolName: symbolName,
130053
+ exportMapKey: exportMapKey,
130015
130054
  exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name,
130016
130055
  fileName: exportInfo_1.moduleFileName,
130017
130056
  isDefaultExport: isDefaultExport,
@@ -130835,18 +130874,7 @@ var ts;
130835
130874
  return undefined;
130836
130875
  var isDefaultExport = data.exportName === "default" /* Default */;
130837
130876
  symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol;
130838
- return {
130839
- symbol: symbol,
130840
- origin: {
130841
- kind: data.moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
130842
- moduleSymbol: moduleSymbol,
130843
- symbolName: name,
130844
- isDefaultExport: isDefaultExport,
130845
- exportName: data.exportName,
130846
- fileName: data.fileName,
130847
- isFromPackageJson: !!data.isPackageJsonImport,
130848
- }
130849
- };
130877
+ return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) };
130850
130878
  }
130851
130879
  function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, jsxIdentifierExpected) {
130852
130880
  var name = originIncludesSymbolName(origin) ? origin.symbolName : symbol.name;
@@ -140213,10 +140241,12 @@ var ts;
140213
140241
  program.getSemanticDiagnostics(sourceFile, cancellationToken);
140214
140242
  var diags = [];
140215
140243
  var checker = program.getTypeChecker();
140216
- if (sourceFile.commonJsModuleIndicator &&
140217
- (ts.programContainsEs6Modules(program) || ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) &&
140244
+ var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]);
140245
+ if (!isCommonJSFile &&
140246
+ sourceFile.commonJsModuleIndicator &&
140247
+ (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) &&
140218
140248
  containsTopLevelCommonjs(sourceFile)) {
140219
- diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module));
140249
+ diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module));
140220
140250
  }
140221
140251
  var isJsFile = ts.isSourceFileJS(sourceFile);
140222
140252
  visitedNestedConvertibleFunctions.clear();
@@ -140265,7 +140295,7 @@ var ts;
140265
140295
  }
140266
140296
  }
140267
140297
  ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics;
140268
- // convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
140298
+ // convertToEsModule only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
140269
140299
  function containsTopLevelCommonjs(sourceFile) {
140270
140300
  return sourceFile.statements.some(function (statement) {
140271
140301
  switch (statement.kind) {
@@ -147459,11 +147489,11 @@ var ts;
147459
147489
  var codefix;
147460
147490
  (function (codefix) {
147461
147491
  codefix.registerCodeFix({
147462
- errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module.code],
147492
+ errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module.code],
147463
147493
  getCodeActions: function (context) {
147464
147494
  var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences;
147465
147495
  var changes = ts.textChanges.ChangeTracker.with(context, function (changes) {
147466
- var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, ts.getEmitScriptTarget(program.getCompilerOptions()), ts.getQuotePreference(sourceFile, preferences));
147496
+ var moduleExportsChangedToDefault = convertFileToEsModule(sourceFile, program.getTypeChecker(), changes, ts.getEmitScriptTarget(program.getCompilerOptions()), ts.getQuotePreference(sourceFile, preferences));
147467
147497
  if (moduleExportsChangedToDefault) {
147468
147498
  for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
147469
147499
  var importingFile = _a[_i];
@@ -147472,7 +147502,7 @@ var ts;
147472
147502
  }
147473
147503
  });
147474
147504
  // No support for fix-all since this applies to the whole file at once anyway.
147475
- return [codefix.createCodeFixActionWithoutFixAll("convertToEs6Module", changes, ts.Diagnostics.Convert_to_ES6_module)];
147505
+ return [codefix.createCodeFixActionWithoutFixAll("convertToEsModule", changes, ts.Diagnostics.Convert_to_ES_module)];
147476
147506
  },
147477
147507
  });
147478
147508
  function fixImportOfModuleExports(importingFile, exportingFile, changes, quotePreference) {
@@ -147496,7 +147526,7 @@ var ts;
147496
147526
  }
147497
147527
  }
147498
147528
  /** @returns Whether we converted a `module.exports =` to a default export. */
147499
- function convertFileToEs6Module(sourceFile, checker, changes, target, quotePreference) {
147529
+ function convertFileToEsModule(sourceFile, checker, changes, target, quotePreference) {
147500
147530
  var identifiers = { original: collectFreeIdentifiers(sourceFile), additional: new ts.Set() };
147501
147531
  var exports = collectExportRenames(sourceFile, checker, identifiers);
147502
147532
  convertExportsAccesses(sourceFile, exports, changes);
@@ -147629,7 +147659,7 @@ var ts;
147629
147659
  // `const a = require("b").c` --> `import { c as a } from "./b";
147630
147660
  return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]);
147631
147661
  default:
147632
- return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind);
147662
+ return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind);
147633
147663
  }
147634
147664
  }
147635
147665
  function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) {
@@ -147814,7 +147844,7 @@ var ts;
147814
147844
  case 79 /* Identifier */:
147815
147845
  return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference);
147816
147846
  default:
147817
- return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind);
147847
+ return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind);
147818
147848
  }
147819
147849
  }
147820
147850
  /**
@@ -148134,7 +148164,11 @@ var ts;
148134
148164
  }
148135
148165
  function doChange(changes, sourceFile, _a) {
148136
148166
  var container = _a.container, typeNode = _a.typeNode, constraint = _a.constraint, name = _a.name;
148137
- changes.replaceNode(sourceFile, container, ts.factory.createMappedTypeNode(/*readonlyToken*/ undefined, ts.factory.createTypeParameterDeclaration(name, ts.factory.createTypeReferenceNode(constraint)), /*nameType*/ undefined, /*questionToken*/ undefined, typeNode));
148167
+ changes.replaceNode(sourceFile, container, ts.factory.createMappedTypeNode(
148168
+ /*readonlyToken*/ undefined, ts.factory.createTypeParameterDeclaration(name, ts.factory.createTypeReferenceNode(constraint)),
148169
+ /*nameType*/ undefined,
148170
+ /*questionToken*/ undefined, typeNode,
148171
+ /*members*/ undefined));
148138
148172
  }
148139
148173
  })(codefix = ts.codefix || (ts.codefix = {}));
148140
148174
  })(ts || (ts = {}));
@@ -148753,12 +148787,14 @@ var ts;
148753
148787
  }
148754
148788
  var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier;
148755
148789
  return fixes.reduce(function (best, fix) {
148790
+ // Takes true branch of conditional if `fix` is better than `best`
148756
148791
  return compareModuleSpecifiers(fix, best, sourceFile, program, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
148757
148792
  });
148758
148793
  }
148794
+ /** @returns `Comparison.LessThan` if `a` is better than `b`. */
148759
148795
  function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier) {
148760
148796
  if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
148761
- return ts.compareBooleans(allowsImportingSpecifier(a.moduleSpecifier), allowsImportingSpecifier(b.moduleSpecifier))
148797
+ return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
148762
148798
  || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
148763
148799
  || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
148764
148800
  }
@@ -148855,9 +148891,12 @@ var ts;
148855
148891
  }));
148856
148892
  return { fixes: fixes, symbolName: symbolName };
148857
148893
  }
148894
+ function jsxModeNeedsExplicitImport(jsx) {
148895
+ return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
148896
+ }
148858
148897
  function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
148859
148898
  var parent = symbolToken.parent;
148860
- if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && compilerOptions.jsx !== 4 /* ReactJSX */ && compilerOptions.jsx !== 5 /* ReactJSXDev */) {
148899
+ if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
148861
148900
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
148862
148901
  if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) {
148863
148902
  return jsxNamespace;
@@ -151407,7 +151446,8 @@ var ts;
151407
151446
  insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile);
151408
151447
  break;
151409
151448
  case 213 /* ArrowFunction */:
151410
- insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters);
151449
+ var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */;
151450
+ insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters);
151411
151451
  break;
151412
151452
  default:
151413
151453
  return;
@@ -153729,7 +153769,8 @@ var ts;
153729
153769
  var parameter = ts.first(indexSignature.parameters);
153730
153770
  var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type);
153731
153771
  var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(144 /* ReadonlyKeyword */) : undefined, mappedTypeParameter,
153732
- /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type);
153772
+ /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type,
153773
+ /*members*/ undefined);
153733
153774
  var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [
153734
153775
  mappedIntersectionType
153735
153776
  ], false), (otherMembers.length ? [ts.factory.createTypeLiteralNode(otherMembers)] : ts.emptyArray), true));
@@ -156972,17 +157013,17 @@ var ts;
156972
157013
  deleteMovedStatements(oldFile, toMove.ranges, changes);
156973
157014
  return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true);
156974
157015
  }
156975
- var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator;
157016
+ var useEsModuleSyntax = !!oldFile.externalModuleIndicator;
156976
157017
  var quotePreference = ts.getQuotePreference(oldFile, preferences);
156977
- var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, quotePreference);
157018
+ var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEsModuleSyntax, quotePreference);
156978
157019
  if (importsFromNewFile) {
156979
157020
  ts.insertImports(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true);
156980
157021
  }
156981
157022
  deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
156982
157023
  deleteMovedStatements(oldFile, toMove.ranges, changes);
156983
157024
  updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName);
156984
- var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference);
156985
- var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax);
157025
+ var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference);
157026
+ var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax);
156986
157027
  if (imports.length && body.length) {
156987
157028
  return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [
156988
157029
  4 /* NewLineTrivia */
@@ -157229,7 +157270,7 @@ var ts;
157229
157270
  break;
157230
157271
  }
157231
157272
  }
157232
- function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference) {
157273
+ function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference) {
157233
157274
  var copiedOldImports = [];
157234
157275
  for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) {
157235
157276
  var oldStatement = _a[_i];
@@ -157254,7 +157295,7 @@ var ts;
157254
157295
  continue;
157255
157296
  var top = getTopLevelDeclarationStatement(decl);
157256
157297
  if (markSeenTop(top)) {
157257
- addExportToChanges(oldFile, top, name, changes, useEs6ModuleSyntax);
157298
+ addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
157258
157299
  }
157259
157300
  if (ts.hasSyntacticModifier(decl, 512 /* Default */)) {
157260
157301
  oldFileDefault = name;
@@ -157264,7 +157305,7 @@ var ts;
157264
157305
  }
157265
157306
  }
157266
157307
  });
157267
- ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax, quotePreference));
157308
+ ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEsModuleSyntax, quotePreference));
157268
157309
  return copiedOldImports;
157269
157310
  }
157270
157311
  function makeUniqueModuleName(moduleName, extension, inDirectory, host) {