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/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.5";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20211014";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20211018";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  function tryGetNativeMap() {
@@ -80,19 +80,19 @@ var ts;
80
80
  return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
81
81
  }
82
82
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
83
- })(NativeCollections = ts.NativeCollections || (ts.NativeCollections = {}));
84
- })(ts || (ts = {}));
85
- var ts;
86
- (function (ts) {
83
+ })(NativeCollections || (NativeCollections = {}));
84
+ ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
85
+ ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
87
86
  function getCollectionImplementation(name, nativeFactory, shimFactory) {
88
87
  var _a;
89
- var constructor = (_a = ts.NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](getIterator);
88
+ var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator);
90
89
  if (constructor)
91
90
  return constructor;
92
91
  throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");
93
92
  }
94
- ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
95
- ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
93
+ })(ts || (ts = {}));
94
+ var ts;
95
+ (function (ts) {
96
96
  function getIterator(iterable) {
97
97
  if (iterable) {
98
98
  if (isArray(iterable))
@@ -5052,6 +5052,10 @@ var ts;
5052
5052
  }
5053
5053
  return sys;
5054
5054
  })();
5055
+ function setSys(s) {
5056
+ ts.sys = s;
5057
+ }
5058
+ ts.setSys = setSys;
5055
5059
  if (ts.sys && ts.sys.getEnvironmentVariable) {
5056
5060
  setCustomPollingValues(ts.sys);
5057
5061
  ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
@@ -6614,7 +6618,7 @@ var ts;
6614
6618
  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}"),
6615
6619
  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."),
6616
6620
  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}'."),
6617
- 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."),
6621
+ 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."),
6618
6622
  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."),
6619
6623
  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."),
6620
6624
  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."),
@@ -6676,7 +6680,7 @@ var ts;
6676
6680
  Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
6677
6681
  Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
6678
6682
  Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."),
6679
- Convert_to_ES6_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES6_module_95017", "Convert to ES6 module"),
6683
+ Convert_to_ES_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES_module_95017", "Convert to ES module"),
6680
6684
  Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"),
6681
6685
  Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
6682
6686
  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}'"),
@@ -29016,16 +29020,21 @@ var ts;
29016
29020
  var pos = getNodePos();
29017
29021
  parseExpected(129);
29018
29022
  var openBracePosition = scanner.getTokenPos();
29019
- parseExpected(18);
29020
- var multiLine = scanner.hasPrecedingLineBreak();
29021
- var elements = parseDelimitedList(24, parseAssertEntry, true);
29022
- if (!parseExpected(19)) {
29023
- var lastError = ts.lastOrUndefined(parseDiagnostics);
29024
- if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
29025
- ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
29023
+ if (parseExpected(18)) {
29024
+ var multiLine = scanner.hasPrecedingLineBreak();
29025
+ var elements = parseDelimitedList(24, parseAssertEntry, true);
29026
+ if (!parseExpected(19)) {
29027
+ var lastError = ts.lastOrUndefined(parseDiagnostics);
29028
+ if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
29029
+ ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
29030
+ }
29026
29031
  }
29032
+ return finishNode(factory.createAssertClause(elements, multiLine), pos);
29033
+ }
29034
+ else {
29035
+ var elements = createNodeArray([], getNodePos(), undefined, false);
29036
+ return finishNode(factory.createAssertClause(elements, false), pos);
29027
29037
  }
29028
- return finishNode(factory.createAssertClause(elements, multiLine), pos);
29029
29038
  }
29030
29039
  function tokenAfterImportDefinitelyProducesImportDeclaration() {
29031
29040
  return token() === 41 || token() === 18;
@@ -29792,8 +29801,9 @@ var ts;
29792
29801
  return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start);
29793
29802
  }
29794
29803
  function parseSeeTag(start, tagName, indent, indentText) {
29795
- var isLink = lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; });
29796
- var nameExpression = isLink ? undefined : parseJSDocNameReference();
29804
+ var isMarkdownOrJSDocLink = token() === 22
29805
+ || lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; });
29806
+ var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
29797
29807
  var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
29798
29808
  return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
29799
29809
  }
@@ -47847,7 +47857,7 @@ var ts;
47847
47857
  return false;
47848
47858
  switch (node.kind) {
47849
47859
  case 79:
47850
- return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol;
47860
+ return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol;
47851
47861
  case 166:
47852
47862
  case 168:
47853
47863
  case 171:
@@ -56190,7 +56200,7 @@ var ts;
56190
56200
  var keyPropertyName = getKeyPropertyName(unionType);
56191
56201
  var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 294 &&
56192
56202
  p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); });
56193
- var propType = propNode && getTypeOfExpression(propNode.initializer);
56203
+ var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer);
56194
56204
  return propType && getConstituentTypeForKeyType(unionType, propType);
56195
56205
  }
56196
56206
  function isOrContainsMatchingReference(source, target) {
@@ -58966,7 +58976,7 @@ var ts;
58966
58976
  return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 294 && 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) && !!((_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);
58967
58977
  }
58968
58978
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
58969
- return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 284 && 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) && !!((_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);
58979
+ return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 284 && 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) && !!((_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);
58970
58980
  }
58971
58981
  function getApparentTypeOfContextualType(node, contextFlags) {
58972
58982
  var contextualType = ts.isObjectLiteralMethod(node) ?
@@ -79227,44 +79237,25 @@ var ts;
79227
79237
  return tagTransform(node.openingFragment, node.children, isChild, node);
79228
79238
  }
79229
79239
  function convertJsxChildrenToChildrenPropObject(children) {
79240
+ var prop = convertJsxChildrenToChildrenPropAssignment(children);
79241
+ return prop && factory.createObjectLiteralExpression([prop]);
79242
+ }
79243
+ function convertJsxChildrenToChildrenPropAssignment(children) {
79230
79244
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
79231
79245
  if (ts.length(nonWhitespaceChildren) === 1) {
79232
79246
  var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
79233
- return result_13 && factory.createObjectLiteralExpression([
79234
- factory.createPropertyAssignment("children", result_13)
79235
- ]);
79247
+ return result_13 && factory.createPropertyAssignment("children", result_13);
79236
79248
  }
79237
79249
  var result = ts.mapDefined(children, transformJsxChildToExpression);
79238
- return !result.length ? undefined : factory.createObjectLiteralExpression([
79239
- factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result))
79240
- ]);
79250
+ return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
79241
79251
  }
79242
79252
  function visitJsxOpeningLikeElementJSX(node, children, isChild, location) {
79243
79253
  var tagName = getTagName(node);
79244
- var objectProperties;
79254
+ var childrenProp = children && children.length ? convertJsxChildrenToChildrenPropAssignment(children) : undefined;
79245
79255
  var keyAttr = ts.find(node.attributes.properties, function (p) { return !!p.name && ts.isIdentifier(p.name) && p.name.escapedText === "key"; });
79246
79256
  var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
79247
- var segments = [];
79248
- if (attrs.length) {
79249
- segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
79250
- ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
79251
- : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
79252
- if (ts.isJsxSpreadAttribute(attrs[0])) {
79253
- segments.unshift(factory.createObjectLiteralExpression());
79254
- }
79255
- }
79256
- if (children && children.length) {
79257
- var result = convertJsxChildrenToChildrenPropObject(children);
79258
- if (result) {
79259
- segments.push(result);
79260
- }
79261
- }
79262
- if (segments.length === 0) {
79263
- objectProperties = factory.createObjectLiteralExpression([]);
79264
- }
79265
- else {
79266
- objectProperties = ts.singleOrUndefined(segments) || emitHelpers().createAssignHelper(segments);
79267
- }
79257
+ var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs, childrenProp) :
79258
+ factory.createObjectLiteralExpression(childrenProp ? [childrenProp] : ts.emptyArray);
79268
79259
  return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location);
79269
79260
  }
79270
79261
  function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) {
@@ -79290,31 +79281,9 @@ var ts;
79290
79281
  }
79291
79282
  function visitJsxOpeningLikeElementCreateElement(node, children, isChild, location) {
79292
79283
  var tagName = getTagName(node);
79293
- var objectProperties;
79294
79284
  var attrs = node.attributes.properties;
79295
- if (attrs.length === 0) {
79296
- objectProperties = factory.createNull();
79297
- }
79298
- else {
79299
- var target = ts.getEmitScriptTarget(compilerOptions);
79300
- if (target && target >= 5) {
79301
- objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
79302
- return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement);
79303
- })));
79304
- }
79305
- else {
79306
- var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
79307
- ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
79308
- : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
79309
- if (ts.isJsxSpreadAttribute(attrs[0])) {
79310
- segments.unshift(factory.createObjectLiteralExpression());
79311
- }
79312
- objectProperties = ts.singleOrUndefined(segments);
79313
- if (!objectProperties) {
79314
- objectProperties = emitHelpers().createAssignHelper(segments);
79315
- }
79316
- }
79317
- }
79285
+ var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs) :
79286
+ factory.createNull();
79318
79287
  var callee = currentFileState.importSpecifier === undefined
79319
79288
  ? ts.createJsxFactoryExpression(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, node)
79320
79289
  : getImplicitImportForName("createElement");
@@ -79344,6 +79313,32 @@ var ts;
79344
79313
  function transformJsxSpreadAttributeToSpreadAssignment(node) {
79345
79314
  return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression));
79346
79315
  }
79316
+ function transformJsxAttributesToObjectProps(attrs, children) {
79317
+ var target = ts.getEmitScriptTarget(compilerOptions);
79318
+ return target && target >= 5 ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) :
79319
+ transformJsxAttributesToExpression(attrs, children);
79320
+ }
79321
+ function transformJsxAttributesToProps(attrs, children) {
79322
+ var props = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
79323
+ return ts.map(attrs, function (attr) { return isSpread ? transformJsxSpreadAttributeToSpreadAssignment(attr) : transformJsxAttributeToObjectLiteralElement(attr); });
79324
+ }));
79325
+ if (children) {
79326
+ props.push(children);
79327
+ }
79328
+ return props;
79329
+ }
79330
+ function transformJsxAttributesToExpression(attrs, children) {
79331
+ var expressions = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
79332
+ ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
79333
+ : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
79334
+ if (ts.isJsxSpreadAttribute(attrs[0])) {
79335
+ expressions.unshift(factory.createObjectLiteralExpression());
79336
+ }
79337
+ if (children) {
79338
+ expressions.push(factory.createObjectLiteralExpression([children]));
79339
+ }
79340
+ return ts.singleOrUndefined(expressions) || emitHelpers().createAssignHelper(expressions);
79341
+ }
79347
79342
  function transformJsxSpreadAttributeToExpression(node) {
79348
79343
  return ts.visitNode(node.expression, visitor, ts.isExpression);
79349
79344
  }
@@ -93286,7 +93281,7 @@ var ts;
93286
93281
  break;
93287
93282
  case ts.FileIncludeKind.TypeReferenceDirective:
93288
93283
  (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
93289
- 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;
93284
+ 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;
93290
93285
  break;
93291
93286
  case ts.FileIncludeKind.LibReferenceDirective:
93292
93287
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);