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/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20211014";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20211018";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -129,21 +129,24 @@ var ts;
129
129
  return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
130
130
  }
131
131
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
132
- })(NativeCollections = ts.NativeCollections || (ts.NativeCollections = {}));
133
- })(ts || (ts = {}));
134
- /* @internal */
135
- var ts;
136
- (function (ts) {
132
+ })(NativeCollections || (NativeCollections = {}));
133
+ /* @internal */
134
+ ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
135
+ /* @internal */
136
+ ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
137
+ /* @internal */
137
138
  function getCollectionImplementation(name, nativeFactory, shimFactory) {
138
139
  var _a;
139
140
  // NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it.
140
- var constructor = (_a = ts.NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](getIterator);
141
+ var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator);
141
142
  if (constructor)
142
143
  return constructor;
143
144
  throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");
144
145
  }
145
- ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
146
- ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
146
+ })(ts || (ts = {}));
147
+ /* @internal */
148
+ var ts;
149
+ (function (ts) {
147
150
  function getIterator(iterable) {
148
151
  if (iterable) {
149
152
  if (isArray(iterable))
@@ -7823,6 +7826,11 @@ var ts;
7823
7826
  }
7824
7827
  return sys;
7825
7828
  })();
7829
+ /*@internal*/
7830
+ function setSys(s) {
7831
+ ts.sys = s;
7832
+ }
7833
+ ts.setSys = setSys;
7826
7834
  if (ts.sys && ts.sys.getEnvironmentVariable) {
7827
7835
  setCustomPollingValues(ts.sys);
7828
7836
  ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
@@ -9388,7 +9396,7 @@ var ts;
9388
9396
  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}"),
9389
9397
  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."),
9390
9398
  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}'."),
9391
- 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."),
9399
+ 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."),
9392
9400
  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."),
9393
9401
  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."),
9394
9402
  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."),
@@ -9450,7 +9458,7 @@ var ts;
9450
9458
  Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
9451
9459
  Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
9452
9460
  Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."),
9453
- Convert_to_ES6_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES6_module_95017", "Convert to ES6 module"),
9461
+ Convert_to_ES_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES_module_95017", "Convert to ES module"),
9454
9462
  Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"),
9455
9463
  Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
9456
9464
  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}'"),
@@ -35965,16 +35973,21 @@ var ts;
35965
35973
  var pos = getNodePos();
35966
35974
  parseExpected(129 /* AssertKeyword */);
35967
35975
  var openBracePosition = scanner.getTokenPos();
35968
- parseExpected(18 /* OpenBraceToken */);
35969
- var multiLine = scanner.hasPrecedingLineBreak();
35970
- var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true);
35971
- if (!parseExpected(19 /* CloseBraceToken */)) {
35972
- var lastError = ts.lastOrUndefined(parseDiagnostics);
35973
- if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
35974
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
35976
+ if (parseExpected(18 /* OpenBraceToken */)) {
35977
+ var multiLine = scanner.hasPrecedingLineBreak();
35978
+ var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true);
35979
+ if (!parseExpected(19 /* CloseBraceToken */)) {
35980
+ var lastError = ts.lastOrUndefined(parseDiagnostics);
35981
+ if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
35982
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
35983
+ }
35975
35984
  }
35985
+ return finishNode(factory.createAssertClause(elements, multiLine), pos);
35986
+ }
35987
+ else {
35988
+ var elements = createNodeArray([], getNodePos(), /*end*/ undefined, /*hasTrailingComma*/ false);
35989
+ return finishNode(factory.createAssertClause(elements, /*multiLine*/ false), pos);
35976
35990
  }
35977
- return finishNode(factory.createAssertClause(elements, multiLine), pos);
35978
35991
  }
35979
35992
  function tokenAfterImportDefinitelyProducesImportDeclaration() {
35980
35993
  return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */;
@@ -36869,8 +36882,9 @@ var ts;
36869
36882
  return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start);
36870
36883
  }
36871
36884
  function parseSeeTag(start, tagName, indent, indentText) {
36872
- var isLink = lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; });
36873
- var nameExpression = isLink ? undefined : parseJSDocNameReference();
36885
+ var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
36886
+ || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; });
36887
+ var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
36874
36888
  var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
36875
36889
  return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
36876
36890
  }
@@ -57814,7 +57828,7 @@ var ts;
57814
57828
  return false;
57815
57829
  switch (node.kind) {
57816
57830
  case 79 /* Identifier */:
57817
- return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol;
57831
+ return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol;
57818
57832
  case 166 /* PropertyDeclaration */:
57819
57833
  case 168 /* MethodDeclaration */:
57820
57834
  case 171 /* GetAccessor */:
@@ -67338,7 +67352,7 @@ var ts;
67338
67352
  var keyPropertyName = getKeyPropertyName(unionType);
67339
67353
  var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 294 /* PropertyAssignment */ &&
67340
67354
  p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); });
67341
- var propType = propNode && getTypeOfExpression(propNode.initializer);
67355
+ var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer);
67342
67356
  return propType && getConstituentTypeForKeyType(unionType, propType);
67343
67357
  }
67344
67358
  function isOrContainsMatchingReference(source, target) {
@@ -70573,7 +70587,7 @@ var ts;
70573
70587
  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);
70574
70588
  }
70575
70589
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
70576
- 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);
70590
+ 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);
70577
70591
  }
70578
70592
  // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily
70579
70593
  // be "pushed" onto a node using the contextualType property.
@@ -94839,51 +94853,25 @@ var ts;
94839
94853
  return tagTransform(node.openingFragment, node.children, isChild, /*location*/ node);
94840
94854
  }
94841
94855
  function convertJsxChildrenToChildrenPropObject(children) {
94856
+ var prop = convertJsxChildrenToChildrenPropAssignment(children);
94857
+ return prop && factory.createObjectLiteralExpression([prop]);
94858
+ }
94859
+ function convertJsxChildrenToChildrenPropAssignment(children) {
94842
94860
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
94843
94861
  if (ts.length(nonWhitespaceChildren) === 1) {
94844
94862
  var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
94845
- return result_13 && factory.createObjectLiteralExpression([
94846
- factory.createPropertyAssignment("children", result_13)
94847
- ]);
94863
+ return result_13 && factory.createPropertyAssignment("children", result_13);
94848
94864
  }
94849
94865
  var result = ts.mapDefined(children, transformJsxChildToExpression);
94850
- return !result.length ? undefined : factory.createObjectLiteralExpression([
94851
- factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result))
94852
- ]);
94866
+ return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
94853
94867
  }
94854
94868
  function visitJsxOpeningLikeElementJSX(node, children, isChild, location) {
94855
94869
  var tagName = getTagName(node);
94856
- var objectProperties;
94870
+ var childrenProp = children && children.length ? convertJsxChildrenToChildrenPropAssignment(children) : undefined;
94857
94871
  var keyAttr = ts.find(node.attributes.properties, function (p) { return !!p.name && ts.isIdentifier(p.name) && p.name.escapedText === "key"; });
94858
94872
  var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
94859
- var segments = [];
94860
- if (attrs.length) {
94861
- // Map spans of JsxAttribute nodes into object literals and spans
94862
- // of JsxSpreadAttribute nodes into expressions.
94863
- segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
94864
- ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
94865
- : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
94866
- if (ts.isJsxSpreadAttribute(attrs[0])) {
94867
- // We must always emit at least one object literal before a spread
94868
- // argument.factory.createObjectLiteral
94869
- segments.unshift(factory.createObjectLiteralExpression());
94870
- }
94871
- }
94872
- if (children && children.length) {
94873
- var result = convertJsxChildrenToChildrenPropObject(children);
94874
- if (result) {
94875
- segments.push(result);
94876
- }
94877
- }
94878
- if (segments.length === 0) {
94879
- objectProperties = factory.createObjectLiteralExpression([]);
94880
- // When there are no attributes, React wants {}
94881
- }
94882
- else {
94883
- // Either emit one big object literal (no spread attribs), or
94884
- // a call to the __assign helper.
94885
- objectProperties = ts.singleOrUndefined(segments) || emitHelpers().createAssignHelper(segments);
94886
- }
94873
+ var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs, childrenProp) :
94874
+ factory.createObjectLiteralExpression(childrenProp ? [childrenProp] : ts.emptyArray); // When there are no attributes, React wants {}
94887
94875
  return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location);
94888
94876
  }
94889
94877
  function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) {
@@ -94912,38 +94900,9 @@ var ts;
94912
94900
  }
94913
94901
  function visitJsxOpeningLikeElementCreateElement(node, children, isChild, location) {
94914
94902
  var tagName = getTagName(node);
94915
- var objectProperties;
94916
94903
  var attrs = node.attributes.properties;
94917
- if (attrs.length === 0) {
94918
- objectProperties = factory.createNull();
94919
- // When there are no attributes, React wants "null"
94920
- }
94921
- else {
94922
- var target = ts.getEmitScriptTarget(compilerOptions);
94923
- if (target && target >= 5 /* ES2018 */) {
94924
- objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
94925
- return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement);
94926
- })));
94927
- }
94928
- else {
94929
- // Map spans of JsxAttribute nodes into object literals and spans
94930
- // of JsxSpreadAttribute nodes into expressions.
94931
- var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
94932
- ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
94933
- : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
94934
- if (ts.isJsxSpreadAttribute(attrs[0])) {
94935
- // We must always emit at least one object literal before a spread
94936
- // argument.factory.createObjectLiteral
94937
- segments.unshift(factory.createObjectLiteralExpression());
94938
- }
94939
- // Either emit one big object literal (no spread attribs), or
94940
- // a call to the __assign helper.
94941
- objectProperties = ts.singleOrUndefined(segments);
94942
- if (!objectProperties) {
94943
- objectProperties = emitHelpers().createAssignHelper(segments);
94944
- }
94945
- }
94946
- }
94904
+ var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs) :
94905
+ factory.createNull(); // When there are no attributes, React wants "null"
94947
94906
  var callee = currentFileState.importSpecifier === undefined
94948
94907
  ? ts.createJsxFactoryExpression(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217
94949
94908
  node)
@@ -94976,6 +94935,36 @@ var ts;
94976
94935
  function transformJsxSpreadAttributeToSpreadAssignment(node) {
94977
94936
  return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression));
94978
94937
  }
94938
+ function transformJsxAttributesToObjectProps(attrs, children) {
94939
+ var target = ts.getEmitScriptTarget(compilerOptions);
94940
+ return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) :
94941
+ transformJsxAttributesToExpression(attrs, children);
94942
+ }
94943
+ function transformJsxAttributesToProps(attrs, children) {
94944
+ var props = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
94945
+ return ts.map(attrs, function (attr) { return isSpread ? transformJsxSpreadAttributeToSpreadAssignment(attr) : transformJsxAttributeToObjectLiteralElement(attr); });
94946
+ }));
94947
+ if (children) {
94948
+ props.push(children);
94949
+ }
94950
+ return props;
94951
+ }
94952
+ function transformJsxAttributesToExpression(attrs, children) {
94953
+ // Map spans of JsxAttribute nodes into object literals and spans
94954
+ // of JsxSpreadAttribute nodes into expressions.
94955
+ var expressions = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
94956
+ ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
94957
+ : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
94958
+ if (ts.isJsxSpreadAttribute(attrs[0])) {
94959
+ // We must always emit at least one object literal before a spread
94960
+ // argument.factory.createObjectLiteral
94961
+ expressions.unshift(factory.createObjectLiteralExpression());
94962
+ }
94963
+ if (children) {
94964
+ expressions.push(factory.createObjectLiteralExpression([children]));
94965
+ }
94966
+ return ts.singleOrUndefined(expressions) || emitHelpers().createAssignHelper(expressions);
94967
+ }
94979
94968
  function transformJsxSpreadAttributeToExpression(node) {
94980
94969
  return ts.visitNode(node.expression, visitor, ts.isExpression);
94981
94970
  }
@@ -113109,7 +113098,7 @@ var ts;
113109
113098
  break;
113110
113099
  case ts.FileIncludeKind.TypeReferenceDirective:
113111
113100
  (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
113112
- 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;
113101
+ 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;
113113
113102
  break;
113114
113103
  case ts.FileIncludeKind.LibReferenceDirective:
113115
113104
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -124183,14 +124172,14 @@ var ts;
124183
124172
  return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!(s.externalModuleIndicator || s.commonJsModuleIndicator); });
124184
124173
  }
124185
124174
  ts.programContainsModules = programContainsModules;
124186
- function programContainsEs6Modules(program) {
124175
+ function programContainsEsModules(program) {
124187
124176
  return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!s.externalModuleIndicator; });
124188
124177
  }
124189
- ts.programContainsEs6Modules = programContainsEs6Modules;
124190
- function compilerOptionsIndicateEs6Modules(compilerOptions) {
124178
+ ts.programContainsEsModules = programContainsEsModules;
124179
+ function compilerOptionsIndicateEsModules(compilerOptions) {
124191
124180
  return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit;
124192
124181
  }
124193
- ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules;
124182
+ ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules;
124194
124183
  function createModuleSpecifierResolutionHost(program, host) {
124195
124184
  // Mix in `getSymlinkCache` from Program when host doesn't have it
124196
124185
  // in order for non-Project hosts to have a symlinks cache.
@@ -129320,11 +129309,11 @@ var ts;
129320
129309
  // If not already a module, must have modules enabled.
129321
129310
  if (!preferences.includeCompletionsForModuleExports)
129322
129311
  return false;
129323
- // If already using ES6 modules, OK to continue using them.
129312
+ // If already using ES modules, OK to continue using them.
129324
129313
  if (sourceFile.externalModuleIndicator || sourceFile.commonJsModuleIndicator)
129325
129314
  return true;
129326
129315
  // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK.
129327
- if (ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()))
129316
+ if (ts.compilerOptionsIndicateEsModules(program.getCompilerOptions()))
129328
129317
  return true;
129329
129318
  // If some file is using ES6 modules, assume that it's OK to add more.
129330
129319
  return ts.programContainsModules(program);
@@ -139615,10 +139604,12 @@ var ts;
139615
139604
  program.getSemanticDiagnostics(sourceFile, cancellationToken);
139616
139605
  var diags = [];
139617
139606
  var checker = program.getTypeChecker();
139618
- if (sourceFile.commonJsModuleIndicator &&
139619
- (ts.programContainsEs6Modules(program) || ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) &&
139607
+ var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]);
139608
+ if (!isCommonJSFile &&
139609
+ sourceFile.commonJsModuleIndicator &&
139610
+ (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) &&
139620
139611
  containsTopLevelCommonjs(sourceFile)) {
139621
- diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module));
139612
+ diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module));
139622
139613
  }
139623
139614
  var isJsFile = ts.isSourceFileJS(sourceFile);
139624
139615
  visitedNestedConvertibleFunctions.clear();
@@ -139667,7 +139658,7 @@ var ts;
139667
139658
  }
139668
139659
  }
139669
139660
  ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics;
139670
- // convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
139661
+ // convertToEsModule only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
139671
139662
  function containsTopLevelCommonjs(sourceFile) {
139672
139663
  return sourceFile.statements.some(function (statement) {
139673
139664
  switch (statement.kind) {
@@ -146861,11 +146852,11 @@ var ts;
146861
146852
  var codefix;
146862
146853
  (function (codefix) {
146863
146854
  codefix.registerCodeFix({
146864
- errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module.code],
146855
+ errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module.code],
146865
146856
  getCodeActions: function (context) {
146866
146857
  var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences;
146867
146858
  var changes = ts.textChanges.ChangeTracker.with(context, function (changes) {
146868
- var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, ts.getEmitScriptTarget(program.getCompilerOptions()), ts.getQuotePreference(sourceFile, preferences));
146859
+ var moduleExportsChangedToDefault = convertFileToEsModule(sourceFile, program.getTypeChecker(), changes, ts.getEmitScriptTarget(program.getCompilerOptions()), ts.getQuotePreference(sourceFile, preferences));
146869
146860
  if (moduleExportsChangedToDefault) {
146870
146861
  for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
146871
146862
  var importingFile = _a[_i];
@@ -146874,7 +146865,7 @@ var ts;
146874
146865
  }
146875
146866
  });
146876
146867
  // No support for fix-all since this applies to the whole file at once anyway.
146877
- return [codefix.createCodeFixActionWithoutFixAll("convertToEs6Module", changes, ts.Diagnostics.Convert_to_ES6_module)];
146868
+ return [codefix.createCodeFixActionWithoutFixAll("convertToEsModule", changes, ts.Diagnostics.Convert_to_ES_module)];
146878
146869
  },
146879
146870
  });
146880
146871
  function fixImportOfModuleExports(importingFile, exportingFile, changes, quotePreference) {
@@ -146898,7 +146889,7 @@ var ts;
146898
146889
  }
146899
146890
  }
146900
146891
  /** @returns Whether we converted a `module.exports =` to a default export. */
146901
- function convertFileToEs6Module(sourceFile, checker, changes, target, quotePreference) {
146892
+ function convertFileToEsModule(sourceFile, checker, changes, target, quotePreference) {
146902
146893
  var identifiers = { original: collectFreeIdentifiers(sourceFile), additional: new ts.Set() };
146903
146894
  var exports = collectExportRenames(sourceFile, checker, identifiers);
146904
146895
  convertExportsAccesses(sourceFile, exports, changes);
@@ -147031,7 +147022,7 @@ var ts;
147031
147022
  // `const a = require("b").c` --> `import { c as a } from "./b";
147032
147023
  return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]);
147033
147024
  default:
147034
- return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind);
147025
+ return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind);
147035
147026
  }
147036
147027
  }
147037
147028
  function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) {
@@ -147216,7 +147207,7 @@ var ts;
147216
147207
  case 79 /* Identifier */:
147217
147208
  return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference);
147218
147209
  default:
147219
- return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind);
147210
+ return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind);
147220
147211
  }
147221
147212
  }
147222
147213
  /**
@@ -148257,9 +148248,12 @@ var ts;
148257
148248
  }));
148258
148249
  return { fixes: fixes, symbolName: symbolName };
148259
148250
  }
148251
+ function jsxModeNeedsExplicitImport(jsx) {
148252
+ return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
148253
+ }
148260
148254
  function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
148261
148255
  var parent = symbolToken.parent;
148262
- if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && compilerOptions.jsx !== 4 /* ReactJSX */ && compilerOptions.jsx !== 5 /* ReactJSXDev */) {
148256
+ if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
148263
148257
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
148264
148258
  if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) {
148265
148259
  return jsxNamespace;
@@ -156374,17 +156368,17 @@ var ts;
156374
156368
  deleteMovedStatements(oldFile, toMove.ranges, changes);
156375
156369
  return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true);
156376
156370
  }
156377
- var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator;
156371
+ var useEsModuleSyntax = !!oldFile.externalModuleIndicator;
156378
156372
  var quotePreference = ts.getQuotePreference(oldFile, preferences);
156379
- var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, quotePreference);
156373
+ var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEsModuleSyntax, quotePreference);
156380
156374
  if (importsFromNewFile) {
156381
156375
  ts.insertImports(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true);
156382
156376
  }
156383
156377
  deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker);
156384
156378
  deleteMovedStatements(oldFile, toMove.ranges, changes);
156385
156379
  updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName);
156386
- var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference);
156387
- var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax);
156380
+ var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference);
156381
+ var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax);
156388
156382
  if (imports.length && body.length) {
156389
156383
  return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [
156390
156384
  4 /* NewLineTrivia */
@@ -156631,7 +156625,7 @@ var ts;
156631
156625
  break;
156632
156626
  }
156633
156627
  }
156634
- function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference) {
156628
+ function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference) {
156635
156629
  var copiedOldImports = [];
156636
156630
  for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) {
156637
156631
  var oldStatement = _a[_i];
@@ -156656,7 +156650,7 @@ var ts;
156656
156650
  continue;
156657
156651
  var top = getTopLevelDeclarationStatement(decl);
156658
156652
  if (markSeenTop(top)) {
156659
- addExportToChanges(oldFile, top, name, changes, useEs6ModuleSyntax);
156653
+ addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
156660
156654
  }
156661
156655
  if (ts.hasSyntacticModifier(decl, 512 /* Default */)) {
156662
156656
  oldFileDefault = name;
@@ -156666,7 +156660,7 @@ var ts;
156666
156660
  }
156667
156661
  }
156668
156662
  });
156669
- ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax, quotePreference));
156663
+ ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEsModuleSyntax, quotePreference));
156670
156664
  return copiedOldImports;
156671
156665
  }
156672
156666
  function makeUniqueModuleName(moduleName, extension, inDirectory, host) {
@@ -174377,7 +174371,7 @@ var ts;
174377
174371
  };
174378
174372
  // Do this after sys has been set as findArguments is going to work only then
174379
174373
  var sys = server.createWebSystem(webHost, args, function () { return server.findArgument("--executingFilePath") || location + ""; });
174380
- ts.sys = sys;
174374
+ ts.setSys(sys);
174381
174375
  var localeStr = server.findArgument("--locale");
174382
174376
  if (localeStr) {
174383
174377
  ts.validateLocaleAndSetLanguage(localeStr, sys);