@typescript-deploys/pr-build 4.6.0-pr-47590-5 → 4.6.0-pr-45974-9

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
@@ -4885,18 +4885,6 @@ var ts;
4885
4885
  return getCanonicalFileName(nonCanonicalizedPath);
4886
4886
  }
4887
4887
  ts.toPath = toPath;
4888
- function normalizePathAndParts(path) {
4889
- path = normalizeSlashes(path);
4890
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
4891
- if (parts.length) {
4892
- var joinedParts = root + parts.join(ts.directorySeparator);
4893
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
4894
- }
4895
- else {
4896
- return { path: root, parts: parts };
4897
- }
4898
- }
4899
- ts.normalizePathAndParts = normalizePathAndParts;
4900
4888
  function removeTrailingDirectorySeparator(path) {
4901
4889
  if (hasTrailingDirectorySeparator(path)) {
4902
4890
  return path.substr(0, path.length - 1);
@@ -8747,8 +8735,6 @@ var ts;
8747
8735
  case 39:
8748
8736
  tokenValue = scanString(true);
8749
8737
  return token = 10;
8750
- case 96:
8751
- return token = scanTemplateAndSetTokenValue(false);
8752
8738
  default:
8753
8739
  return scan();
8754
8740
  }
@@ -10398,10 +10384,6 @@ var ts;
10398
10384
  || kind === 287;
10399
10385
  }
10400
10386
  ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression;
10401
- function isStringLiteralOrTemplateExpressionOrJsxExpression(node) {
10402
- return node.kind === 222 || isStringLiteralOrJsxExpression(node);
10403
- }
10404
- ts.isStringLiteralOrTemplateExpressionOrJsxExpression = isStringLiteralOrTemplateExpressionOrJsxExpression;
10405
10387
  function isJsxOpeningLikeElement(node) {
10406
10388
  var kind = node.kind;
10407
10389
  return kind === 279
@@ -27636,26 +27618,15 @@ var ts;
27636
27618
  }
27637
27619
  return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos);
27638
27620
  }
27639
- function parseJsxAttributeValue() {
27640
- if (token() !== 63) {
27641
- return undefined;
27642
- }
27643
- var jsxAttributeValueToken = scanJsxAttributeValue();
27644
- if (jsxAttributeValueToken === 10 || jsxAttributeValueToken === 14) {
27645
- return parseLiteralNode();
27646
- }
27647
- if (jsxAttributeValueToken === 15) {
27648
- return parseTemplateExpression(false);
27649
- }
27650
- return parseJsxExpression(true);
27651
- }
27652
27621
  function parseJsxAttribute() {
27653
27622
  if (token() === 18) {
27654
27623
  return parseJsxSpreadAttribute();
27655
27624
  }
27656
27625
  scanJsxIdentifier();
27657
27626
  var pos = getNodePos();
27658
- return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos);
27627
+ return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 ? undefined :
27628
+ scanJsxAttributeValue() === 10 ? parseLiteralNode() :
27629
+ parseJsxExpression(true)), pos);
27659
27630
  }
27660
27631
  function parseJsxSpreadAttribute() {
27661
27632
  var pos = getNodePos();
@@ -34051,7 +34022,7 @@ var ts;
34051
34022
  result_4 = searchResult && searchResult.value;
34052
34023
  }
34053
34024
  else {
34054
- var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
34025
+ var candidate = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName).path;
34055
34026
  result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true);
34056
34027
  }
34057
34028
  return resolvedTypeScriptOnly(result_4);
@@ -34627,12 +34598,19 @@ var ts;
34627
34598
  return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
34628
34599
  }
34629
34600
  else {
34630
- var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
34601
+ var _a = normalizePathForCJSResolution(containingDirectory, moduleName), candidate = _a.path, parts = _a.parts;
34631
34602
  var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, false, state, true);
34632
34603
  return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
34633
34604
  }
34634
34605
  }
34635
34606
  }
34607
+ function normalizePathForCJSResolution(containingDirectory, moduleName) {
34608
+ var combined = ts.combinePaths(containingDirectory, moduleName);
34609
+ var parts = ts.getPathComponents(combined);
34610
+ var lastPart = ts.lastOrUndefined(parts);
34611
+ var path = lastPart === "." || lastPart === ".." ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(combined)) : ts.normalizePath(combined);
34612
+ return { path: path, parts: parts };
34613
+ }
34636
34614
  function realPath(path, host, traceEnabled) {
34637
34615
  if (!host.realpath) {
34638
34616
  return path;
@@ -36135,7 +36113,7 @@ var ts;
36135
36113
  return ts.isDottedName(expr)
36136
36114
  || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression)
36137
36115
  || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 && isNarrowableReference(expr.right)
36138
- || ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression)
36116
+ || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isIdentifier(expr.argumentExpression)) && isNarrowableReference(expr.expression)
36139
36117
  || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left);
36140
36118
  }
36141
36119
  function containsNarrowableReference(expr) {
@@ -56584,8 +56562,9 @@ var ts;
56584
56562
  return isMatchingReference(source.expression, target);
56585
56563
  case 205:
56586
56564
  case 206:
56587
- return ts.isAccessExpression(target) &&
56588
- getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
56565
+ var sourcePropertyName = getAccessedPropertyName(source);
56566
+ var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined;
56567
+ return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName &&
56589
56568
  isMatchingReference(source.expression, target.expression);
56590
56569
  case 160:
56591
56570
  return ts.isAccessExpression(target) &&
@@ -56597,12 +56576,49 @@ var ts;
56597
56576
  return false;
56598
56577
  }
56599
56578
  function getAccessedPropertyName(access) {
56600
- var propertyName;
56601
- return access.kind === 205 ? access.name.escapedText :
56602
- access.kind === 206 && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
56603
- access.kind === 202 && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) :
56604
- access.kind === 163 ? ("" + access.parent.parameters.indexOf(access)) :
56605
- undefined;
56579
+ if (ts.isPropertyAccessExpression(access)) {
56580
+ return access.name.escapedText;
56581
+ }
56582
+ if (ts.isElementAccessExpression(access)) {
56583
+ return tryGetElementAccessExpressionName(access);
56584
+ }
56585
+ if (ts.isBindingElement(access)) {
56586
+ var name = getDestructuringPropertyName(access);
56587
+ return name ? ts.escapeLeadingUnderscores(name) : undefined;
56588
+ }
56589
+ if (ts.isParameter(access)) {
56590
+ return ("" + access.parent.parameters.indexOf(access));
56591
+ }
56592
+ return undefined;
56593
+ }
56594
+ function tryGetNameFromType(type) {
56595
+ return type.flags & 8192 ? type.escapedName :
56596
+ type.flags & 384 ? ts.escapeLeadingUnderscores("" + type.value) : undefined;
56597
+ }
56598
+ function tryGetElementAccessExpressionName(node) {
56599
+ if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) {
56600
+ return ts.escapeLeadingUnderscores(node.argumentExpression.text);
56601
+ }
56602
+ if (ts.isIdentifier(node.argumentExpression)) {
56603
+ var symbol = getResolvedSymbol(node.argumentExpression);
56604
+ if (!isConstVariable(symbol))
56605
+ return undefined;
56606
+ var declaration = symbol.valueDeclaration;
56607
+ if (declaration === undefined)
56608
+ return undefined;
56609
+ var type = tryGetTypeFromEffectiveTypeNode(declaration);
56610
+ if (type) {
56611
+ var name = tryGetNameFromType(type);
56612
+ if (name !== undefined) {
56613
+ return name;
56614
+ }
56615
+ }
56616
+ if (ts.hasOnlyExpressionInitializer(declaration)) {
56617
+ var initializer = ts.getEffectiveInitializer(declaration);
56618
+ return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
56619
+ }
56620
+ }
56621
+ return undefined;
56606
56622
  }
56607
56623
  function containsMatchingReference(source, target) {
56608
56624
  while (ts.isAccessExpression(source)) {
@@ -69292,7 +69308,7 @@ var ts;
69292
69308
  }
69293
69309
  if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) {
69294
69310
  var propName = member.name;
69295
- if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
69311
+ if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
69296
69312
  var type = getTypeOfSymbol(getSymbolOfNode(member));
69297
69313
  if (!(type.flags & 3 || getFalsyFlags(type) & 32768)) {
69298
69314
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
@@ -69326,7 +69342,9 @@ var ts;
69326
69342
  return false;
69327
69343
  }
69328
69344
  function isPropertyInitializedInConstructor(propName, propType, constructor) {
69329
- var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
69345
+ var reference = ts.isComputedPropertyName(propName)
69346
+ ? ts.factory.createElementAccessExpression(ts.factory.createThis(), propName.expression)
69347
+ : ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
69330
69348
  ts.setParent(reference.expression, reference);
69331
69349
  ts.setParent(reference, constructor);
69332
69350
  reference.flowNode = constructor.returnFlowNode;
@@ -74091,7 +74109,7 @@ var ts;
74091
74109
  return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment));
74092
74110
  case 284:
74093
74111
  ts.Debug.type(node);
74094
- return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrTemplateExpressionOrJsxExpression));
74112
+ return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression));
74095
74113
  case 285:
74096
74114
  ts.Debug.type(node);
74097
74115
  return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike));
@@ -80263,9 +80281,6 @@ var ts;
80263
80281
  var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote);
80264
80282
  return ts.setTextRange(literal, node);
80265
80283
  }
80266
- else if (node.kind === 14 || node.kind === 222) {
80267
- return node;
80268
- }
80269
80284
  else if (node.kind === 287) {
80270
80285
  if (node.expression === undefined) {
80271
80286
  return factory.createTrue();
@@ -80868,8 +80883,6 @@ var ts;
80868
80883
  return visitReturnStatement(node);
80869
80884
  case 216:
80870
80885
  return visitVoidExpression(node);
80871
- case 284:
80872
- return visitJsxAttribute(node);
80873
80886
  default:
80874
80887
  return ts.visitEachChild(node, visitor, context);
80875
80888
  }
@@ -80899,12 +80912,6 @@ var ts;
80899
80912
  }
80900
80913
  return ts.visitEachChild(node, visitor, context);
80901
80914
  }
80902
- function visitJsxAttribute(node) {
80903
- if (node.initializer && ts.isTemplateExpression(node.initializer)) {
80904
- return factory.createJsxAttribute(ts.visitNode(node.name, visitor, ts.isIdentifier), factory.createJsxExpression(undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)));
80905
- }
80906
- return ts.visitEachChild(node, visitor, context);
80907
- }
80908
80915
  function visitCaseBlock(node) {
80909
80916
  var ancestorFacts = enterSubtree(7104, 0);
80910
80917
  var updated = ts.visitEachChild(node, visitor, context);
package/lib/tsserver.js CHANGED
@@ -7636,18 +7636,6 @@ var ts;
7636
7636
  return getCanonicalFileName(nonCanonicalizedPath);
7637
7637
  }
7638
7638
  ts.toPath = toPath;
7639
- function normalizePathAndParts(path) {
7640
- path = normalizeSlashes(path);
7641
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
7642
- if (parts.length) {
7643
- var joinedParts = root + parts.join(ts.directorySeparator);
7644
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
7645
- }
7646
- else {
7647
- return { path: root, parts: parts };
7648
- }
7649
- }
7650
- ts.normalizePathAndParts = normalizePathAndParts;
7651
7639
  function removeTrailingDirectorySeparator(path) {
7652
7640
  if (hasTrailingDirectorySeparator(path)) {
7653
7641
  return path.substr(0, path.length - 1);
@@ -11751,8 +11739,6 @@ var ts;
11751
11739
  case 39 /* singleQuote */:
11752
11740
  tokenValue = scanString(/*jsxAttributeString*/ true);
11753
11741
  return token = 10 /* StringLiteral */;
11754
- case 96 /* backtick */:
11755
- return token = scanTemplateAndSetTokenValue(/*isTaggedTemplate*/ false);
11756
11742
  default:
11757
11743
  // If this scans anything other than `{`, it's a parse error.
11758
11744
  return scan();
@@ -13760,11 +13746,6 @@ var ts;
13760
13746
  || kind === 287 /* JsxExpression */;
13761
13747
  }
13762
13748
  ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression;
13763
- /* @internal */
13764
- function isStringLiteralOrTemplateExpressionOrJsxExpression(node) {
13765
- return node.kind === 222 /* TemplateExpression */ || isStringLiteralOrJsxExpression(node);
13766
- }
13767
- ts.isStringLiteralOrTemplateExpressionOrJsxExpression = isStringLiteralOrTemplateExpressionOrJsxExpression;
13768
13749
  function isJsxOpeningLikeElement(node) {
13769
13750
  var kind = node.kind;
13770
13751
  return kind === 279 /* JsxOpeningElement */
@@ -34462,26 +34443,15 @@ var ts;
34462
34443
  }
34463
34444
  return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos);
34464
34445
  }
34465
- function parseJsxAttributeValue() {
34466
- if (token() !== 63 /* EqualsToken */) {
34467
- return undefined;
34468
- }
34469
- var jsxAttributeValueToken = scanJsxAttributeValue();
34470
- if (jsxAttributeValueToken === 10 /* StringLiteral */ || jsxAttributeValueToken === 14 /* NoSubstitutionTemplateLiteral */) {
34471
- return parseLiteralNode();
34472
- }
34473
- if (jsxAttributeValueToken === 15 /* TemplateHead */) {
34474
- return parseTemplateExpression(/*isTaggedTemplate*/ false);
34475
- }
34476
- return parseJsxExpression(/*inExpressionContext*/ true);
34477
- }
34478
34446
  function parseJsxAttribute() {
34479
34447
  if (token() === 18 /* OpenBraceToken */) {
34480
34448
  return parseJsxSpreadAttribute();
34481
34449
  }
34482
34450
  scanJsxIdentifier();
34483
34451
  var pos = getNodePos();
34484
- return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos);
34452
+ return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 63 /* EqualsToken */ ? undefined :
34453
+ scanJsxAttributeValue() === 10 /* StringLiteral */ ? parseLiteralNode() :
34454
+ parseJsxExpression(/*inExpressionContext*/ true)), pos);
34485
34455
  }
34486
34456
  function parseJsxSpreadAttribute() {
34487
34457
  var pos = getNodePos();
@@ -41739,7 +41709,7 @@ var ts;
41739
41709
  result_4 = searchResult && searchResult.value;
41740
41710
  }
41741
41711
  else {
41742
- var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
41712
+ var candidate = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName).path;
41743
41713
  result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
41744
41714
  }
41745
41715
  return resolvedTypeScriptOnly(result_4);
@@ -42442,13 +42412,25 @@ var ts;
42442
42412
  return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
42443
42413
  }
42444
42414
  else {
42445
- var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
42415
+ var _a = normalizePathForCJSResolution(containingDirectory, moduleName), candidate = _a.path, parts = _a.parts;
42446
42416
  var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, /*onlyRecordFailures*/ false, state, /*considerPackageJson*/ true);
42447
42417
  // Treat explicit "node_modules" import as an external library import.
42448
42418
  return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
42449
42419
  }
42450
42420
  }
42451
42421
  }
42422
+ // If you import from "." inside a containing directory "/foo", the result of `normalizePath`
42423
+ // would be "/foo", but this loses the information that `foo` is a directory and we intended
42424
+ // to look inside of it. The Node CommonJS resolution algorithm doesn't call this out
42425
+ // (https://nodejs.org/api/modules.html#all-together), but it seems that module paths ending
42426
+ // in `.` are actually normalized to `./` before proceeding with the resolution algorithm.
42427
+ function normalizePathForCJSResolution(containingDirectory, moduleName) {
42428
+ var combined = ts.combinePaths(containingDirectory, moduleName);
42429
+ var parts = ts.getPathComponents(combined);
42430
+ var lastPart = ts.lastOrUndefined(parts);
42431
+ var path = lastPart === "." || lastPart === ".." ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(combined)) : ts.normalizePath(combined);
42432
+ return { path: path, parts: parts };
42433
+ }
42452
42434
  function realPath(path, host, traceEnabled) {
42453
42435
  if (!host.realpath) {
42454
42436
  return path;
@@ -44196,7 +44178,7 @@ var ts;
44196
44178
  return ts.isDottedName(expr)
44197
44179
  || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression)
44198
44180
  || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right)
44199
- || ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression)
44181
+ || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isIdentifier(expr.argumentExpression)) && isNarrowableReference(expr.expression)
44200
44182
  || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left);
44201
44183
  }
44202
44184
  function containsNarrowableReference(expr) {
@@ -67823,8 +67805,9 @@ var ts;
67823
67805
  return isMatchingReference(source.expression, target);
67824
67806
  case 205 /* PropertyAccessExpression */:
67825
67807
  case 206 /* ElementAccessExpression */:
67826
- return ts.isAccessExpression(target) &&
67827
- getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
67808
+ var sourcePropertyName = getAccessedPropertyName(source);
67809
+ var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined;
67810
+ return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName &&
67828
67811
  isMatchingReference(source.expression, target.expression);
67829
67812
  case 160 /* QualifiedName */:
67830
67813
  return ts.isAccessExpression(target) &&
@@ -67836,12 +67819,49 @@ var ts;
67836
67819
  return false;
67837
67820
  }
67838
67821
  function getAccessedPropertyName(access) {
67839
- var propertyName;
67840
- return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
67841
- access.kind === 206 /* ElementAccessExpression */ && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
67842
- access.kind === 202 /* BindingElement */ && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) :
67843
- access.kind === 163 /* Parameter */ ? ("" + access.parent.parameters.indexOf(access)) :
67844
- undefined;
67822
+ if (ts.isPropertyAccessExpression(access)) {
67823
+ return access.name.escapedText;
67824
+ }
67825
+ if (ts.isElementAccessExpression(access)) {
67826
+ return tryGetElementAccessExpressionName(access);
67827
+ }
67828
+ if (ts.isBindingElement(access)) {
67829
+ var name = getDestructuringPropertyName(access);
67830
+ return name ? ts.escapeLeadingUnderscores(name) : undefined;
67831
+ }
67832
+ if (ts.isParameter(access)) {
67833
+ return ("" + access.parent.parameters.indexOf(access));
67834
+ }
67835
+ return undefined;
67836
+ }
67837
+ function tryGetNameFromType(type) {
67838
+ return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName :
67839
+ type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined;
67840
+ }
67841
+ function tryGetElementAccessExpressionName(node) {
67842
+ if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) {
67843
+ return ts.escapeLeadingUnderscores(node.argumentExpression.text);
67844
+ }
67845
+ if (ts.isIdentifier(node.argumentExpression)) {
67846
+ var symbol = getResolvedSymbol(node.argumentExpression);
67847
+ if (!isConstVariable(symbol))
67848
+ return undefined;
67849
+ var declaration = symbol.valueDeclaration;
67850
+ if (declaration === undefined)
67851
+ return undefined;
67852
+ var type = tryGetTypeFromEffectiveTypeNode(declaration);
67853
+ if (type) {
67854
+ var name = tryGetNameFromType(type);
67855
+ if (name !== undefined) {
67856
+ return name;
67857
+ }
67858
+ }
67859
+ if (ts.hasOnlyExpressionInitializer(declaration)) {
67860
+ var initializer = ts.getEffectiveInitializer(declaration);
67861
+ return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
67862
+ }
67863
+ }
67864
+ return undefined;
67845
67865
  }
67846
67866
  function containsMatchingReference(source, target) {
67847
67867
  while (ts.isAccessExpression(source)) {
@@ -82759,7 +82779,7 @@ var ts;
82759
82779
  }
82760
82780
  if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) {
82761
82781
  var propName = member.name;
82762
- if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
82782
+ if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) {
82763
82783
  var type = getTypeOfSymbol(getSymbolOfNode(member));
82764
82784
  if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 32768 /* Undefined */)) {
82765
82785
  if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
@@ -82794,7 +82814,9 @@ var ts;
82794
82814
  return false;
82795
82815
  }
82796
82816
  function isPropertyInitializedInConstructor(propName, propType, constructor) {
82797
- var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
82817
+ var reference = ts.isComputedPropertyName(propName)
82818
+ ? ts.factory.createElementAccessExpression(ts.factory.createThis(), propName.expression)
82819
+ : ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
82798
82820
  ts.setParent(reference.expression, reference);
82799
82821
  ts.setParent(reference, constructor);
82800
82822
  reference.flowNode = constructor.returnFlowNode;
@@ -88021,7 +88043,7 @@ var ts;
88021
88043
  return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment));
88022
88044
  case 284 /* JsxAttribute */:
88023
88045
  ts.Debug.type(node);
88024
- return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrTemplateExpressionOrJsxExpression));
88046
+ return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression));
88025
88047
  case 285 /* JsxAttributes */:
88026
88048
  ts.Debug.type(node);
88027
88049
  return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike));
@@ -96083,9 +96105,6 @@ var ts;
96083
96105
  var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote);
96084
96106
  return ts.setTextRange(literal, node);
96085
96107
  }
96086
- else if (node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 222 /* TemplateExpression */) {
96087
- return node;
96088
- }
96089
96108
  else if (node.kind === 287 /* JsxExpression */) {
96090
96109
  if (node.expression === undefined) {
96091
96110
  return factory.createTrue();
@@ -96860,8 +96879,6 @@ var ts;
96860
96879
  return visitReturnStatement(node);
96861
96880
  case 216 /* VoidExpression */:
96862
96881
  return visitVoidExpression(node);
96863
- case 284 /* JsxAttribute */:
96864
- return visitJsxAttribute(node);
96865
96882
  default:
96866
96883
  return ts.visitEachChild(node, visitor, context);
96867
96884
  }
@@ -96892,13 +96909,6 @@ var ts;
96892
96909
  }
96893
96910
  return ts.visitEachChild(node, visitor, context);
96894
96911
  }
96895
- function visitJsxAttribute(node) {
96896
- if (node.initializer && ts.isTemplateExpression(node.initializer)) {
96897
- return factory.createJsxAttribute(ts.visitNode(node.name, visitor, ts.isIdentifier), factory.createJsxExpression(
96898
- /* dotDotDotToken */ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)));
96899
- }
96900
- return ts.visitEachChild(node, visitor, context);
96901
- }
96902
96912
  function visitCaseBlock(node) {
96903
96913
  var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */);
96904
96914
  var updated = ts.visitEachChild(node, visitor, context);
@@ -126964,6 +126974,10 @@ var ts;
126964
126974
  return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
126965
126975
  }
126966
126976
  ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
126977
+ function jsxModeNeedsExplicitImport(jsx) {
126978
+ return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
126979
+ }
126980
+ ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
126967
126981
  // #endregion
126968
126982
  })(ts || (ts = {}));
126969
126983
  /*@internal*/
@@ -128908,9 +128922,18 @@ var ts;
128908
128922
  return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath);
128909
128923
  }
128910
128924
  }
128925
+ function isEmitResolutionKindUsingNodeModules(compilerOptions) {
128926
+ return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ||
128927
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
128928
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
128929
+ }
128930
+ function isEmitModuleResolutionRespectingExportMaps(compilerOptions) {
128931
+ return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 ||
128932
+ ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext;
128933
+ }
128911
128934
  function getSupportedExtensionsForModuleResolution(compilerOptions) {
128912
128935
  var extensions = ts.getSupportedExtensions(compilerOptions);
128913
- return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ?
128936
+ return isEmitResolutionKindUsingNodeModules(compilerOptions) ?
128914
128937
  ts.getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) :
128915
128938
  extensions;
128916
128939
  }
@@ -129073,7 +129096,7 @@ var ts;
129073
129096
  result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined));
129074
129097
  }
129075
129098
  getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result);
129076
- if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs) {
129099
+ if (isEmitResolutionKindUsingNodeModules(compilerOptions)) {
129077
129100
  // If looking for a global package name, don't just include everything in `node_modules` because that includes dependencies' own dependencies.
129078
129101
  // (But do if we didn't find anything, e.g. 'package.json' missing.)
129079
129102
  var foundGlobal = false;
@@ -129090,12 +129113,68 @@ var ts;
129090
129113
  }
129091
129114
  }
129092
129115
  if (!foundGlobal) {
129093
- ts.forEachAncestorDirectory(scriptPath, function (ancestor) {
129116
+ var ancestorLookup = function (ancestor) {
129094
129117
  var nodeModules = ts.combinePaths(ancestor, "node_modules");
129095
129118
  if (ts.tryDirectoryExists(host, nodeModules)) {
129096
129119
  getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result);
129097
129120
  }
129098
- });
129121
+ };
129122
+ if (fragmentDirectory && isEmitModuleResolutionRespectingExportMaps(compilerOptions)) {
129123
+ var nodeModulesDirectoryLookup_1 = ancestorLookup;
129124
+ ancestorLookup = function (ancestor) {
129125
+ var components = ts.getPathComponents(fragment);
129126
+ components.shift(); // shift off empty root
129127
+ var packagePath = components.shift();
129128
+ if (!packagePath) {
129129
+ return nodeModulesDirectoryLookup_1(ancestor);
129130
+ }
129131
+ if (ts.startsWith(packagePath, "@")) {
129132
+ var subName = components.shift();
129133
+ if (!subName) {
129134
+ return nodeModulesDirectoryLookup_1(ancestor);
129135
+ }
129136
+ packagePath = ts.combinePaths(packagePath, subName);
129137
+ }
129138
+ var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json");
129139
+ if (ts.tryFileExists(host, packageFile)) {
129140
+ var packageJson = ts.readJson(packageFile, host);
129141
+ var exports = packageJson.exports;
129142
+ if (exports) {
129143
+ if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null
129144
+ return; // null exports or entrypoint only, no sub-modules available
129145
+ }
129146
+ var keys = ts.getOwnKeys(exports);
129147
+ var fragmentSubpath_1 = components.join("/");
129148
+ var processedKeys = ts.mapDefined(keys, function (k) {
129149
+ if (k === ".")
129150
+ return undefined;
129151
+ if (!ts.startsWith(k, "./"))
129152
+ return undefined;
129153
+ var subpath = k.substring(2);
129154
+ if (!ts.startsWith(subpath, fragmentSubpath_1))
129155
+ return undefined;
129156
+ // subpath is a valid export (barring conditions, which we don't currently check here)
129157
+ if (!ts.stringContains(subpath, "*")) {
129158
+ return subpath;
129159
+ }
129160
+ // pattern export - only return everything up to the `*`, so the user can autocomplete, then
129161
+ // keep filling in the pattern (we could speculatively return a list of options by hitting disk,
129162
+ // but conditions will make that somewhat awkward, as each condition may have a different set of possible
129163
+ // options for the `*`.
129164
+ return subpath.slice(0, subpath.indexOf("*"));
129165
+ });
129166
+ ts.forEach(processedKeys, function (k) {
129167
+ if (k) {
129168
+ result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined));
129169
+ }
129170
+ });
129171
+ return;
129172
+ }
129173
+ }
129174
+ return nodeModulesDirectoryLookup_1(ancestor);
129175
+ };
129176
+ }
129177
+ ts.forEachAncestorDirectory(scriptPath, ancestorLookup);
129099
129178
  }
129100
129179
  }
129101
129180
  return result;
@@ -138588,6 +138667,7 @@ var ts;
138588
138667
  return oldImports;
138589
138668
  }
138590
138669
  var typeChecker = program.getTypeChecker();
138670
+ var compilerOptions = program.getCompilerOptions();
138591
138671
  var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
138592
138672
  var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile);
138593
138673
  var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */);
@@ -138644,7 +138724,7 @@ var ts;
138644
138724
  return usedImports;
138645
138725
  function isDeclarationUsed(identifier) {
138646
138726
  // The JSX factory symbol is always used if JSX elements are present - even if they are not allowed.
138647
- return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) ||
138727
+ return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx) ||
138648
138728
  ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile);
138649
138729
  }
138650
138730
  }
@@ -150335,12 +150415,9 @@ var ts;
150335
150415
  return undefined;
150336
150416
  return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
150337
150417
  }
150338
- function jsxModeNeedsExplicitImport(jsx) {
150339
- return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
150340
- }
150341
150418
  function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) {
150342
150419
  var parent = symbolToken.parent;
150343
- if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
150420
+ if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && ts.jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
150344
150421
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
150345
150422
  if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
150346
150423
  return jsxNamespace;
@@ -1373,7 +1373,7 @@ declare namespace ts {
1373
1373
  readonly kind: SyntaxKind.JsxAttribute;
1374
1374
  readonly parent: JsxAttributes;
1375
1375
  readonly name: Identifier;
1376
- readonly initializer?: StringLiteral | TemplateLiteral | JsxExpression;
1376
+ readonly initializer?: StringLiteral | JsxExpression;
1377
1377
  }
1378
1378
  export interface JsxSpreadAttribute extends ObjectLiteralElement {
1379
1379
  readonly kind: SyntaxKind.JsxSpreadAttribute;
@@ -3690,8 +3690,8 @@ declare namespace ts {
3690
3690
  createJsxOpeningFragment(): JsxOpeningFragment;
3691
3691
  createJsxJsxClosingFragment(): JsxClosingFragment;
3692
3692
  updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment;
3693
- createJsxAttribute(name: Identifier, initializer: StringLiteral | TemplateLiteral | JsxExpression | undefined): JsxAttribute;
3694
- updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | TemplateLiteral | JsxExpression | undefined): JsxAttribute;
3693
+ createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute;
3694
+ updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute;
3695
3695
  createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes;
3696
3696
  updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes;
3697
3697
  createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute;
@@ -11183,9 +11183,9 @@ declare namespace ts {
11183
11183
  /** @deprecated Use `factory.updateJsxFragment` or the factory supplied by your transformation context instead. */
11184
11184
  const updateJsxFragment: (node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment) => JsxFragment;
11185
11185
  /** @deprecated Use `factory.createJsxAttribute` or the factory supplied by your transformation context instead. */
11186
- const createJsxAttribute: (name: Identifier, initializer: StringLiteral | TemplateLiteral | JsxExpression | undefined) => JsxAttribute;
11186
+ const createJsxAttribute: (name: Identifier, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute;
11187
11187
  /** @deprecated Use `factory.updateJsxAttribute` or the factory supplied by your transformation context instead. */
11188
- const updateJsxAttribute: (node: JsxAttribute, name: Identifier, initializer: StringLiteral | TemplateLiteral | JsxExpression | undefined) => JsxAttribute;
11188
+ const updateJsxAttribute: (node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined) => JsxAttribute;
11189
11189
  /** @deprecated Use `factory.createJsxAttributes` or the factory supplied by your transformation context instead. */
11190
11190
  const createJsxAttributes: (properties: readonly JsxAttributeLike[]) => JsxAttributes;
11191
11191
  /** @deprecated Use `factory.updateJsxAttributes` or the factory supplied by your transformation context instead. */