typescript 4.5.0-dev.20211014 → 4.5.0-dev.20211018

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-dev.20211014";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20211018";
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"))
@@ -9582,7 +9590,7 @@ var ts;
9582
9590
  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
9591
  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
9592
  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."),
9593
+ 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
9594
  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
9595
  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
9596
  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 +9652,7 @@ var ts;
9644
9652
  Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
9645
9653
  Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
9646
9654
  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"),
9655
+ Convert_to_ES_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES_module_95017", "Convert to ES module"),
9648
9656
  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
9657
  Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
9650
9658
  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}'"),
@@ -36159,16 +36167,21 @@ var ts;
36159
36167
  var pos = getNodePos();
36160
36168
  parseExpected(129 /* AssertKeyword */);
36161
36169
  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));
36170
+ if (parseExpected(18 /* OpenBraceToken */)) {
36171
+ var multiLine = scanner.hasPrecedingLineBreak();
36172
+ var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true);
36173
+ if (!parseExpected(19 /* CloseBraceToken */)) {
36174
+ var lastError = ts.lastOrUndefined(parseDiagnostics);
36175
+ if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
36176
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
36177
+ }
36169
36178
  }
36179
+ return finishNode(factory.createAssertClause(elements, multiLine), pos);
36180
+ }
36181
+ else {
36182
+ var elements = createNodeArray([], getNodePos(), /*end*/ undefined, /*hasTrailingComma*/ false);
36183
+ return finishNode(factory.createAssertClause(elements, /*multiLine*/ false), pos);
36170
36184
  }
36171
- return finishNode(factory.createAssertClause(elements, multiLine), pos);
36172
36185
  }
36173
36186
  function tokenAfterImportDefinitelyProducesImportDeclaration() {
36174
36187
  return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */;
@@ -37063,8 +37076,9 @@ var ts;
37063
37076
  return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start);
37064
37077
  }
37065
37078
  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();
37079
+ var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
37080
+ || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; });
37081
+ var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
37068
37082
  var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
37069
37083
  return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
37070
37084
  }
@@ -58008,7 +58022,7 @@ var ts;
58008
58022
  return false;
58009
58023
  switch (node.kind) {
58010
58024
  case 79 /* Identifier */:
58011
- return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol;
58025
+ return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol;
58012
58026
  case 166 /* PropertyDeclaration */:
58013
58027
  case 168 /* MethodDeclaration */:
58014
58028
  case 171 /* GetAccessor */:
@@ -67532,7 +67546,7 @@ var ts;
67532
67546
  var keyPropertyName = getKeyPropertyName(unionType);
67533
67547
  var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 294 /* PropertyAssignment */ &&
67534
67548
  p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); });
67535
- var propType = propNode && getTypeOfExpression(propNode.initializer);
67549
+ var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer);
67536
67550
  return propType && getConstituentTypeForKeyType(unionType, propType);
67537
67551
  }
67538
67552
  function isOrContainsMatchingReference(source, target) {
@@ -70767,7 +70781,7 @@ var ts;
70767
70781
  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);
70768
70782
  }
70769
70783
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
70770
- 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);
70784
+ 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);
70771
70785
  }
70772
70786
  // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily
70773
70787
  // be "pushed" onto a node using the contextualType property.
@@ -95033,51 +95047,25 @@ var ts;
95033
95047
  return tagTransform(node.openingFragment, node.children, isChild, /*location*/ node);
95034
95048
  }
95035
95049
  function convertJsxChildrenToChildrenPropObject(children) {
95050
+ var prop = convertJsxChildrenToChildrenPropAssignment(children);
95051
+ return prop && factory.createObjectLiteralExpression([prop]);
95052
+ }
95053
+ function convertJsxChildrenToChildrenPropAssignment(children) {
95036
95054
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95037
95055
  if (ts.length(nonWhitespaceChildren) === 1) {
95038
95056
  var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
95039
- return result_13 && factory.createObjectLiteralExpression([
95040
- factory.createPropertyAssignment("children", result_13)
95041
- ]);
95057
+ return result_13 && factory.createPropertyAssignment("children", result_13);
95042
95058
  }
95043
95059
  var result = ts.mapDefined(children, transformJsxChildToExpression);
95044
- return !result.length ? undefined : factory.createObjectLiteralExpression([
95045
- factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result))
95046
- ]);
95060
+ return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
95047
95061
  }
95048
95062
  function visitJsxOpeningLikeElementJSX(node, children, isChild, location) {
95049
95063
  var tagName = getTagName(node);
95050
- var objectProperties;
95064
+ var childrenProp = children && children.length ? convertJsxChildrenToChildrenPropAssignment(children) : undefined;
95051
95065
  var keyAttr = ts.find(node.attributes.properties, function (p) { return !!p.name && ts.isIdentifier(p.name) && p.name.escapedText === "key"; });
95052
95066
  var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
95053
- var segments = [];
95054
- if (attrs.length) {
95055
- // Map spans of JsxAttribute nodes into object literals and spans
95056
- // of JsxSpreadAttribute nodes into expressions.
95057
- segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
95058
- ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
95059
- : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
95060
- if (ts.isJsxSpreadAttribute(attrs[0])) {
95061
- // We must always emit at least one object literal before a spread
95062
- // argument.factory.createObjectLiteral
95063
- segments.unshift(factory.createObjectLiteralExpression());
95064
- }
95065
- }
95066
- if (children && children.length) {
95067
- var result = convertJsxChildrenToChildrenPropObject(children);
95068
- if (result) {
95069
- segments.push(result);
95070
- }
95071
- }
95072
- if (segments.length === 0) {
95073
- objectProperties = factory.createObjectLiteralExpression([]);
95074
- // When there are no attributes, React wants {}
95075
- }
95076
- else {
95077
- // Either emit one big object literal (no spread attribs), or
95078
- // a call to the __assign helper.
95079
- objectProperties = ts.singleOrUndefined(segments) || emitHelpers().createAssignHelper(segments);
95080
- }
95067
+ var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs, childrenProp) :
95068
+ factory.createObjectLiteralExpression(childrenProp ? [childrenProp] : ts.emptyArray); // When there are no attributes, React wants {}
95081
95069
  return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location);
95082
95070
  }
95083
95071
  function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) {
@@ -95106,38 +95094,9 @@ var ts;
95106
95094
  }
95107
95095
  function visitJsxOpeningLikeElementCreateElement(node, children, isChild, location) {
95108
95096
  var tagName = getTagName(node);
95109
- var objectProperties;
95110
95097
  var attrs = node.attributes.properties;
95111
- if (attrs.length === 0) {
95112
- objectProperties = factory.createNull();
95113
- // When there are no attributes, React wants "null"
95114
- }
95115
- else {
95116
- var target = ts.getEmitScriptTarget(compilerOptions);
95117
- if (target && target >= 5 /* ES2018 */) {
95118
- objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
95119
- return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement);
95120
- })));
95121
- }
95122
- else {
95123
- // Map spans of JsxAttribute nodes into object literals and spans
95124
- // of JsxSpreadAttribute nodes into expressions.
95125
- var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
95126
- ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
95127
- : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
95128
- if (ts.isJsxSpreadAttribute(attrs[0])) {
95129
- // We must always emit at least one object literal before a spread
95130
- // argument.factory.createObjectLiteral
95131
- segments.unshift(factory.createObjectLiteralExpression());
95132
- }
95133
- // Either emit one big object literal (no spread attribs), or
95134
- // a call to the __assign helper.
95135
- objectProperties = ts.singleOrUndefined(segments);
95136
- if (!objectProperties) {
95137
- objectProperties = emitHelpers().createAssignHelper(segments);
95138
- }
95139
- }
95140
- }
95098
+ var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs) :
95099
+ factory.createNull(); // When there are no attributes, React wants "null"
95141
95100
  var callee = currentFileState.importSpecifier === undefined
95142
95101
  ? ts.createJsxFactoryExpression(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217
95143
95102
  node)
@@ -95170,6 +95129,36 @@ var ts;
95170
95129
  function transformJsxSpreadAttributeToSpreadAssignment(node) {
95171
95130
  return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression));
95172
95131
  }
95132
+ function transformJsxAttributesToObjectProps(attrs, children) {
95133
+ var target = ts.getEmitScriptTarget(compilerOptions);
95134
+ return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) :
95135
+ transformJsxAttributesToExpression(attrs, children);
95136
+ }
95137
+ function transformJsxAttributesToProps(attrs, children) {
95138
+ var props = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
95139
+ return ts.map(attrs, function (attr) { return isSpread ? transformJsxSpreadAttributeToSpreadAssignment(attr) : transformJsxAttributeToObjectLiteralElement(attr); });
95140
+ }));
95141
+ if (children) {
95142
+ props.push(children);
95143
+ }
95144
+ return props;
95145
+ }
95146
+ function transformJsxAttributesToExpression(attrs, children) {
95147
+ // Map spans of JsxAttribute nodes into object literals and spans
95148
+ // of JsxSpreadAttribute nodes into expressions.
95149
+ var expressions = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
95150
+ ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
95151
+ : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
95152
+ if (ts.isJsxSpreadAttribute(attrs[0])) {
95153
+ // We must always emit at least one object literal before a spread
95154
+ // argument.factory.createObjectLiteral
95155
+ expressions.unshift(factory.createObjectLiteralExpression());
95156
+ }
95157
+ if (children) {
95158
+ expressions.push(factory.createObjectLiteralExpression([children]));
95159
+ }
95160
+ return ts.singleOrUndefined(expressions) || emitHelpers().createAssignHelper(expressions);
95161
+ }
95173
95162
  function transformJsxSpreadAttributeToExpression(node) {
95174
95163
  return ts.visitNode(node.expression, visitor, ts.isExpression);
95175
95164
  }
@@ -113303,7 +113292,7 @@ var ts;
113303
113292
  break;
113304
113293
  case ts.FileIncludeKind.TypeReferenceDirective:
113305
113294
  (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
113306
- 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;
113295
+ 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;
113307
113296
  break;
113308
113297
  case ts.FileIncludeKind.LibReferenceDirective:
113309
113298
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -124765,14 +124754,14 @@ var ts;
124765
124754
  return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!(s.externalModuleIndicator || s.commonJsModuleIndicator); });
124766
124755
  }
124767
124756
  ts.programContainsModules = programContainsModules;
124768
- function programContainsEs6Modules(program) {
124757
+ function programContainsEsModules(program) {
124769
124758
  return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!s.externalModuleIndicator; });
124770
124759
  }
124771
- ts.programContainsEs6Modules = programContainsEs6Modules;
124772
- function compilerOptionsIndicateEs6Modules(compilerOptions) {
124760
+ ts.programContainsEsModules = programContainsEsModules;
124761
+ function compilerOptionsIndicateEsModules(compilerOptions) {
124773
124762
  return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit;
124774
124763
  }
124775
- ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules;
124764
+ ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules;
124776
124765
  function createModuleSpecifierResolutionHost(program, host) {
124777
124766
  // Mix in `getSymlinkCache` from Program when host doesn't have it
124778
124767
  // in order for non-Project hosts to have a symlinks cache.
@@ -129902,11 +129891,11 @@ var ts;
129902
129891
  // If not already a module, must have modules enabled.
129903
129892
  if (!preferences.includeCompletionsForModuleExports)
129904
129893
  return false;
129905
- // If already using ES6 modules, OK to continue using them.
129894
+ // If already using ES modules, OK to continue using them.
129906
129895
  if (sourceFile.externalModuleIndicator || sourceFile.commonJsModuleIndicator)
129907
129896
  return true;
129908
129897
  // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK.
129909
- if (ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()))
129898
+ if (ts.compilerOptionsIndicateEsModules(program.getCompilerOptions()))
129910
129899
  return true;
129911
129900
  // If some file is using ES6 modules, assume that it's OK to add more.
129912
129901
  return ts.programContainsModules(program);
@@ -140197,10 +140186,12 @@ var ts;
140197
140186
  program.getSemanticDiagnostics(sourceFile, cancellationToken);
140198
140187
  var diags = [];
140199
140188
  var checker = program.getTypeChecker();
140200
- if (sourceFile.commonJsModuleIndicator &&
140201
- (ts.programContainsEs6Modules(program) || ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) &&
140189
+ var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]);
140190
+ if (!isCommonJSFile &&
140191
+ sourceFile.commonJsModuleIndicator &&
140192
+ (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) &&
140202
140193
  containsTopLevelCommonjs(sourceFile)) {
140203
- diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module));
140194
+ diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module));
140204
140195
  }
140205
140196
  var isJsFile = ts.isSourceFileJS(sourceFile);
140206
140197
  visitedNestedConvertibleFunctions.clear();
@@ -140249,7 +140240,7 @@ var ts;
140249
140240
  }
140250
140241
  }
140251
140242
  ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics;
140252
- // convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
140243
+ // convertToEsModule only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
140253
140244
  function containsTopLevelCommonjs(sourceFile) {
140254
140245
  return sourceFile.statements.some(function (statement) {
140255
140246
  switch (statement.kind) {
@@ -147443,11 +147434,11 @@ var ts;
147443
147434
  var codefix;
147444
147435
  (function (codefix) {
147445
147436
  codefix.registerCodeFix({
147446
- errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module.code],
147437
+ errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module.code],
147447
147438
  getCodeActions: function (context) {
147448
147439
  var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences;
147449
147440
  var changes = ts.textChanges.ChangeTracker.with(context, function (changes) {
147450
- var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, ts.getEmitScriptTarget(program.getCompilerOptions()), ts.getQuotePreference(sourceFile, preferences));
147441
+ var moduleExportsChangedToDefault = convertFileToEsModule(sourceFile, program.getTypeChecker(), changes, ts.getEmitScriptTarget(program.getCompilerOptions()), ts.getQuotePreference(sourceFile, preferences));
147451
147442
  if (moduleExportsChangedToDefault) {
147452
147443
  for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
147453
147444
  var importingFile = _a[_i];
@@ -147456,7 +147447,7 @@ var ts;
147456
147447
  }
147457
147448
  });
147458
147449
  // No support for fix-all since this applies to the whole file at once anyway.
147459
- return [codefix.createCodeFixActionWithoutFixAll("convertToEs6Module", changes, ts.Diagnostics.Convert_to_ES6_module)];
147450
+ return [codefix.createCodeFixActionWithoutFixAll("convertToEsModule", changes, ts.Diagnostics.Convert_to_ES_module)];
147460
147451
  },
147461
147452
  });
147462
147453
  function fixImportOfModuleExports(importingFile, exportingFile, changes, quotePreference) {
@@ -147480,7 +147471,7 @@ var ts;
147480
147471
  }
147481
147472
  }
147482
147473
  /** @returns Whether we converted a `module.exports =` to a default export. */
147483
- function convertFileToEs6Module(sourceFile, checker, changes, target, quotePreference) {
147474
+ function convertFileToEsModule(sourceFile, checker, changes, target, quotePreference) {
147484
147475
  var identifiers = { original: collectFreeIdentifiers(sourceFile), additional: new ts.Set() };
147485
147476
  var exports = collectExportRenames(sourceFile, checker, identifiers);
147486
147477
  convertExportsAccesses(sourceFile, exports, changes);
@@ -147613,7 +147604,7 @@ var ts;
147613
147604
  // `const a = require("b").c` --> `import { c as a } from "./b";
147614
147605
  return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]);
147615
147606
  default:
147616
- return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind);
147607
+ return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind);
147617
147608
  }
147618
147609
  }
147619
147610
  function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) {
@@ -147798,7 +147789,7 @@ var ts;
147798
147789
  case 79 /* Identifier */:
147799
147790
  return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference);
147800
147791
  default:
147801
- return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind);
147792
+ return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind);
147802
147793
  }
147803
147794
  }
147804
147795
  /**
@@ -148839,9 +148830,12 @@ var ts;
148839
148830
  }));
148840
148831
  return { fixes: fixes, symbolName: symbolName };
148841
148832
  }
148833
+ function jsxModeNeedsExplicitImport(jsx) {
148834
+ return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
148835
+ }
148842
148836
  function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
148843
148837
  var parent = symbolToken.parent;
148844
- if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && compilerOptions.jsx !== 4 /* ReactJSX */ && compilerOptions.jsx !== 5 /* ReactJSXDev */) {
148838
+ if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
148845
148839
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
148846
148840
  if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) {
148847
148841
  return jsxNamespace;
@@ -156956,17 +156950,17 @@ var ts;
156956
156950
  deleteMovedStatements(oldFile, toMove.ranges, changes);
156957
156951
  return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true);
156958
156952
  }
156959
- var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator;
156953
+ var useEsModuleSyntax = !!oldFile.externalModuleIndicator;
156960
156954
  var quotePreference = ts.getQuotePreference(oldFile, preferences);
156961
- var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, quotePreference);
156955
+ var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEsModuleSyntax, quotePreference);
156962
156956
  if (importsFromNewFile) {
156963
156957
  ts.insertImports(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true);
156964
156958
  }
156965
156959
  deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
156966
156960
  deleteMovedStatements(oldFile, toMove.ranges, changes);
156967
156961
  updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName);
156968
- var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference);
156969
- var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax);
156962
+ var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference);
156963
+ var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax);
156970
156964
  if (imports.length && body.length) {
156971
156965
  return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [
156972
156966
  4 /* NewLineTrivia */
@@ -157213,7 +157207,7 @@ var ts;
157213
157207
  break;
157214
157208
  }
157215
157209
  }
157216
- function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference) {
157210
+ function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference) {
157217
157211
  var copiedOldImports = [];
157218
157212
  for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) {
157219
157213
  var oldStatement = _a[_i];
@@ -157238,7 +157232,7 @@ var ts;
157238
157232
  continue;
157239
157233
  var top = getTopLevelDeclarationStatement(decl);
157240
157234
  if (markSeenTop(top)) {
157241
- addExportToChanges(oldFile, top, name, changes, useEs6ModuleSyntax);
157235
+ addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
157242
157236
  }
157243
157237
  if (ts.hasSyntacticModifier(decl, 512 /* Default */)) {
157244
157238
  oldFileDefault = name;
@@ -157248,7 +157242,7 @@ var ts;
157248
157242
  }
157249
157243
  }
157250
157244
  });
157251
- ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax, quotePreference));
157245
+ ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEsModuleSyntax, quotePreference));
157252
157246
  return copiedOldImports;
157253
157247
  }
157254
157248
  function makeUniqueModuleName(moduleName, extension, inDirectory, host) {