typescript 5.1.0-dev.20230416 → 5.1.0-dev.20230418

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
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.1";
21
- var version = `${versionMajorMinor}.0-dev.20230416`;
21
+ var version = `${versionMajorMinor}.0-dev.20230418`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -12469,6 +12469,14 @@ function getErrorSpanForNode(sourceFile, node) {
12469
12469
  const pos2 = skipTrivia(sourceFile.text, node.pos);
12470
12470
  return getSpanOfTokenAtPosition(sourceFile, pos2);
12471
12471
  }
12472
+ case 237 /* SatisfiesExpression */: {
12473
+ const pos2 = skipTrivia(sourceFile.text, node.expression.end);
12474
+ return getSpanOfTokenAtPosition(sourceFile, pos2);
12475
+ }
12476
+ case 356 /* JSDocSatisfiesTag */: {
12477
+ const pos2 = skipTrivia(sourceFile.text, node.tagName.pos);
12478
+ return getSpanOfTokenAtPosition(sourceFile, pos2);
12479
+ }
12472
12480
  }
12473
12481
  if (errorNode === void 0) {
12474
12482
  return getSpanOfTokenAtPosition(sourceFile, node.pos);
@@ -14610,7 +14618,7 @@ function isQuoteOrBacktick(charCode) {
14610
14618
  }
14611
14619
  function isIntrinsicJsxName(name) {
14612
14620
  const ch = name.charCodeAt(0);
14613
- return ch >= 97 /* a */ && ch <= 122 /* z */ || stringContains(name, "-") || stringContains(name, ":");
14621
+ return ch >= 97 /* a */ && ch <= 122 /* z */ || stringContains(name, "-");
14614
14622
  }
14615
14623
  var indentStrings = ["", " "];
14616
14624
  function getIndentString(level) {
@@ -17272,15 +17280,24 @@ function tryGetJSDocSatisfiesTypeNode(node) {
17272
17280
  return tag && tag.typeExpression && tag.typeExpression.type;
17273
17281
  }
17274
17282
  function getEscapedTextOfJsxAttributeName(node) {
17275
- return isIdentifier(node) ? node.escapedText : `${node.namespace.escapedText}:${idText(node.name)}`;
17283
+ return isIdentifier(node) ? node.escapedText : getEscapedTextOfJsxNamespacedName(node);
17276
17284
  }
17277
17285
  function getTextOfJsxAttributeName(node) {
17278
- return isIdentifier(node) ? idText(node) : `${idText(node.namespace)}:${idText(node.name)}`;
17286
+ return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
17279
17287
  }
17280
17288
  function isJsxAttributeName(node) {
17281
17289
  const kind = node.kind;
17282
17290
  return kind === 80 /* Identifier */ || kind === 294 /* JsxNamespacedName */;
17283
17291
  }
17292
+ function getEscapedTextOfJsxNamespacedName(node) {
17293
+ return `${node.namespace.escapedText}:${idText(node.name)}`;
17294
+ }
17295
+ function getTextOfJsxNamespacedName(node) {
17296
+ return `${idText(node.namespace)}:${idText(node.name)}`;
17297
+ }
17298
+ function intrinsicTagNameToString(node) {
17299
+ return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
17300
+ }
17284
17301
 
17285
17302
  // src/compiler/factory/baseNodeFactory.ts
17286
17303
  function createBaseNodeFactory() {
@@ -37616,22 +37633,22 @@ var nodeModulesPathPart = "/node_modules/";
37616
37633
  function pathContainsNodeModules(path) {
37617
37634
  return stringContains(path, nodeModulesPathPart);
37618
37635
  }
37619
- function parseNodeModuleFromPath(resolved) {
37636
+ function parseNodeModuleFromPath(resolved, isFolder) {
37620
37637
  const path = normalizePath(resolved);
37621
37638
  const idx = path.lastIndexOf(nodeModulesPathPart);
37622
37639
  if (idx === -1) {
37623
37640
  return void 0;
37624
37641
  }
37625
37642
  const indexAfterNodeModules = idx + nodeModulesPathPart.length;
37626
- let indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
37643
+ let indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules, isFolder);
37627
37644
  if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) {
37628
- indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
37645
+ indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName, isFolder);
37629
37646
  }
37630
37647
  return path.slice(0, indexAfterPackageName);
37631
37648
  }
37632
- function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
37649
+ function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex, isFolder) {
37633
37650
  const nextSeparatorIndex = path.indexOf(directorySeparator, prevSeparatorIndex + 1);
37634
- return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
37651
+ return nextSeparatorIndex === -1 ? isFolder ? path.length : prevSeparatorIndex : nextSeparatorIndex;
37635
37652
  }
37636
37653
  function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
37637
37654
  return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
@@ -39006,6 +39023,9 @@ function createBinder() {
39006
39023
  const containingClassSymbol = containingClass.symbol;
39007
39024
  return getSymbolNameForPrivateIdentifier(containingClassSymbol, name.escapedText);
39008
39025
  }
39026
+ if (isJsxNamespacedName(name)) {
39027
+ return getEscapedTextOfJsxNamespacedName(name);
39028
+ }
39009
39029
  return isPropertyNameLiteral(name) ? getEscapedTextOfIdentifierOrLiteral(name) : void 0;
39010
39030
  }
39011
39031
  switch (node.kind) {
@@ -57139,16 +57159,18 @@ function createTypeChecker(host) {
57139
57159
  while (true) {
57140
57160
  if (tailCount === 1e3) {
57141
57161
  error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
57142
- result = errorType;
57143
- break;
57162
+ return errorType;
57144
57163
  }
57145
- const checkTuples = isSimpleTupleType(root.node.checkType) && isSimpleTupleType(root.node.extendsType) && length(root.node.checkType.elements) === length(root.node.extendsType.elements);
57146
57164
  const checkType = instantiateType(getActualTypeVariable(root.checkType), mapper);
57147
- const checkTypeDeferred = isDeferredType(checkType, checkTuples);
57148
57165
  const extendsType = instantiateType(root.extendsType, mapper);
57166
+ if (checkType === errorType || extendsType === errorType) {
57167
+ return errorType;
57168
+ }
57149
57169
  if (checkType === wildcardType || extendsType === wildcardType) {
57150
57170
  return wildcardType;
57151
57171
  }
57172
+ const checkTuples = isSimpleTupleType(root.node.checkType) && isSimpleTupleType(root.node.extendsType) && length(root.node.checkType.elements) === length(root.node.extendsType.elements);
57173
+ const checkTypeDeferred = isDeferredType(checkType, checkTuples);
57152
57174
  let combinedMapper;
57153
57175
  if (root.inferTypeParameters) {
57154
57176
  const freshParams = sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
@@ -65065,7 +65087,7 @@ function createTypeChecker(host) {
65065
65087
  }
65066
65088
  function isTypePresencePossible(type, propName, assumeTrue) {
65067
65089
  const prop = getPropertyOfType(type, propName);
65068
- return prop ? !!(prop.flags & 16777216 /* Optional */) || assumeTrue : !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
65090
+ return prop ? !!(prop.flags & 16777216 /* Optional */ || getCheckFlags(prop) & 48 /* Partial */) || assumeTrue : !!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
65069
65091
  }
65070
65092
  function narrowTypeByInKeyword(type, nameType, assumeTrue) {
65071
65093
  const name = getPropertyNameFromType(nameType);
@@ -66873,7 +66895,7 @@ function createTypeChecker(host) {
66873
66895
  return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : void 0;
66874
66896
  }
66875
66897
  function getContextualTypeForChildJsxExpression(node, child, contextFlags) {
66876
- const attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags);
66898
+ const attributesType = getApparentTypeOfContextualType(node.openingElement.attributes, contextFlags);
66877
66899
  const jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
66878
66900
  if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
66879
66901
  return void 0;
@@ -67182,7 +67204,7 @@ function createTypeChecker(host) {
67182
67204
  return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation);
67183
67205
  }
67184
67206
  function getStaticTypeOfReferencedJsxConstructor(context) {
67185
- if (isJsxIntrinsicIdentifier(context.tagName)) {
67207
+ if (isJsxIntrinsicTagName(context.tagName)) {
67186
67208
  const result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context);
67187
67209
  const fakeSignature = createSignatureForJSXIntrinsic(context, result);
67188
67210
  return getOrCreateTypeFromSignature(fakeSignature);
@@ -67783,7 +67805,7 @@ function createTypeChecker(host) {
67783
67805
  }
67784
67806
  function checkJsxElementDeferred(node) {
67785
67807
  checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement);
67786
- if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) {
67808
+ if (isJsxIntrinsicTagName(node.closingElement.tagName)) {
67787
67809
  getIntrinsicTagSymbol(node.closingElement);
67788
67810
  } else {
67789
67811
  checkExpression(node.closingElement.tagName);
@@ -67806,8 +67828,8 @@ function createTypeChecker(host) {
67806
67828
  function isHyphenatedJsxName(name) {
67807
67829
  return stringContains(name, "-");
67808
67830
  }
67809
- function isJsxIntrinsicIdentifier(tagName) {
67810
- return tagName.kind === 80 /* Identifier */ && isIntrinsicJsxName(tagName.escapedText);
67831
+ function isJsxIntrinsicTagName(tagName) {
67832
+ return isIdentifier(tagName) && isIntrinsicJsxName(tagName.escapedText) || isJsxNamespacedName(tagName);
67811
67833
  }
67812
67834
  function checkJsxAttribute(node, checkMode) {
67813
67835
  return node.initializer ? checkExpressionForMutableLocation(node.initializer, checkMode) : trueType;
@@ -67992,9 +68014,9 @@ function createTypeChecker(host) {
67992
68014
  if (!links.resolvedSymbol) {
67993
68015
  const intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
67994
68016
  if (!isErrorType(intrinsicElementsType)) {
67995
- if (!isIdentifier(node.tagName))
68017
+ if (!isIdentifier(node.tagName) && !isJsxNamespacedName(node.tagName))
67996
68018
  return Debug.fail();
67997
- const intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText);
68019
+ const intrinsicProp = getPropertyOfType(intrinsicElementsType, isJsxNamespacedName(node.tagName) ? getEscapedTextOfJsxNamespacedName(node.tagName) : node.tagName.escapedText);
67998
68020
  if (intrinsicProp) {
67999
68021
  links.jsxFlags |= 1 /* IntrinsicNamedElement */;
68000
68022
  return links.resolvedSymbol = intrinsicProp;
@@ -68004,7 +68026,7 @@ function createTypeChecker(host) {
68004
68026
  links.jsxFlags |= 2 /* IntrinsicIndexedElement */;
68005
68027
  return links.resolvedSymbol = intrinsicElementsType.symbol;
68006
68028
  }
68007
- error(node, Diagnostics.Property_0_does_not_exist_on_type_1, idText(node.tagName), "JSX." + JsxNames.IntrinsicElements);
68029
+ error(node, Diagnostics.Property_0_does_not_exist_on_type_1, intrinsicTagNameToString(node.tagName), "JSX." + JsxNames.IntrinsicElements);
68008
68030
  return links.resolvedSymbol = unknownSymbol;
68009
68031
  } else {
68010
68032
  if (noImplicitAny) {
@@ -68175,7 +68197,7 @@ function createTypeChecker(host) {
68175
68197
  }
68176
68198
  }
68177
68199
  function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) {
68178
- Debug.assert(isJsxIntrinsicIdentifier(node.tagName));
68200
+ Debug.assert(isJsxIntrinsicTagName(node.tagName));
68179
68201
  const links = getNodeLinks(node);
68180
68202
  if (!links.resolvedJsxElementAttributesType) {
68181
68203
  const symbol = getIntrinsicTagSymbol(node);
@@ -68275,7 +68297,7 @@ function createTypeChecker(host) {
68275
68297
  const elementTypeConstraint = getJsxElementTypeTypeAt(jsxOpeningLikeNode);
68276
68298
  if (elementTypeConstraint !== void 0) {
68277
68299
  const tagName = jsxOpeningLikeNode.tagName;
68278
- const tagType = isJsxIntrinsicIdentifier(tagName) ? getStringLiteralType(unescapeLeadingUnderscores(tagName.escapedText)) : checkExpression(tagName);
68300
+ const tagType = isJsxIntrinsicTagName(tagName) ? getStringLiteralType(intrinsicTagNameToString(tagName)) : checkExpression(tagName);
68279
68301
  checkTypeRelatedTo(tagType, elementTypeConstraint, assignableRelation, tagName, Diagnostics.Its_type_0_is_not_a_valid_JSX_element_type, () => {
68280
68302
  const componentName = getTextOfNode(tagName);
68281
68303
  return chainDiagnosticMessages(
@@ -69535,7 +69557,7 @@ function createTypeChecker(host) {
69535
69557
  return typeArgumentTypes;
69536
69558
  }
69537
69559
  function getJsxReferenceKind(node) {
69538
- if (isJsxIntrinsicIdentifier(node.tagName)) {
69560
+ if (isJsxIntrinsicTagName(node.tagName)) {
69539
69561
  return 2 /* Mixed */;
69540
69562
  }
69541
69563
  const tagType = getApparentType(checkExpression(node.tagName));
@@ -69572,7 +69594,7 @@ function createTypeChecker(host) {
69572
69594
  if (getJsxNamespaceContainerForImplicitImport(node)) {
69573
69595
  return true;
69574
69596
  }
69575
- const tagType = isJsxOpeningElement(node) || isJsxSelfClosingElement(node) && !isJsxIntrinsicIdentifier(node.tagName) ? checkExpression(node.tagName) : void 0;
69597
+ const tagType = isJsxOpeningElement(node) || isJsxSelfClosingElement(node) && !isJsxIntrinsicTagName(node.tagName) ? checkExpression(node.tagName) : void 0;
69576
69598
  if (!tagType) {
69577
69599
  return true;
69578
69600
  }
@@ -70822,7 +70844,7 @@ function createTypeChecker(host) {
70822
70844
  );
70823
70845
  }
70824
70846
  function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) {
70825
- if (isJsxIntrinsicIdentifier(node.tagName)) {
70847
+ if (isJsxIntrinsicTagName(node.tagName)) {
70826
70848
  const result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
70827
70849
  const fakeSignature = createSignatureForJSXIntrinsic(node, result);
70828
70850
  checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(
@@ -71437,7 +71459,8 @@ function createTypeChecker(host) {
71437
71459
  if (isErrorType(targetType)) {
71438
71460
  return targetType;
71439
71461
  }
71440
- checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, target, expression, Diagnostics.Type_0_does_not_satisfy_the_expected_type_1);
71462
+ const errorNode = findAncestor(target.parent, (n) => n.kind === 237 /* SatisfiesExpression */ || n.kind === 356 /* JSDocSatisfiesTag */);
71463
+ checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, errorNode, expression, Diagnostics.Type_0_does_not_satisfy_the_expected_type_1);
71441
71464
  return exprType;
71442
71465
  }
71443
71466
  function checkMetaProperty(node) {
@@ -80143,7 +80166,7 @@ function createTypeChecker(host) {
80143
80166
  const isJSDoc2 = findAncestor(name, or(isJSDocLinkLike, isJSDocNameReference, isJSDocMemberName));
80144
80167
  const meaning = isJSDoc2 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */;
80145
80168
  if (name.kind === 80 /* Identifier */) {
80146
- if (isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) {
80169
+ if (isJSXTagName(name) && isJsxIntrinsicTagName(name)) {
80147
80170
  const symbol = getIntrinsicTagSymbol(name.parent);
80148
80171
  return symbol === unknownSymbol ? void 0 : symbol;
80149
80172
  }
@@ -80373,6 +80396,11 @@ function createTypeChecker(host) {
80373
80396
  return isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : void 0;
80374
80397
  case 235 /* MetaProperty */:
80375
80398
  return checkExpression(node).symbol;
80399
+ case 294 /* JsxNamespacedName */:
80400
+ if (isJSXTagName(node) && isJsxIntrinsicTagName(node)) {
80401
+ const symbol = getIntrinsicTagSymbol(node.parent);
80402
+ return symbol === unknownSymbol ? void 0 : symbol;
80403
+ }
80376
80404
  default:
80377
80405
  return void 0;
80378
80406
  }
@@ -118465,6 +118493,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118465
118493
  reusedNames,
118466
118494
  loader,
118467
118495
  getResolutionWithResolvedFileName,
118496
+ deferWatchingNonRelativeResolution,
118468
118497
  shouldRetryResolution,
118469
118498
  logChanges
118470
118499
  }) {
@@ -118489,7 +118518,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118489
118518
  resolutionHost.onDiscoveredSymlink();
118490
118519
  }
118491
118520
  resolutionsInFile.set(name, mode, resolution);
118492
- watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
118521
+ watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName, deferWatchingNonRelativeResolution);
118493
118522
  if (existingResolution) {
118494
118523
  stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
118495
118524
  }
@@ -118565,7 +118594,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118565
118594
  typeReferenceDirectiveResolutionCache
118566
118595
  ),
118567
118596
  getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
118568
- shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0
118597
+ shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0,
118598
+ deferWatchingNonRelativeResolution: false
118569
118599
  });
118570
118600
  }
118571
118601
  function resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
@@ -118584,7 +118614,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118584
118614
  ),
118585
118615
  getResolutionWithResolvedFileName: getResolvedModule2,
118586
118616
  shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
118587
- logChanges: logChangesWhenResolvingModule
118617
+ logChanges: logChangesWhenResolvingModule,
118618
+ deferWatchingNonRelativeResolution: true
118619
+ // Defer non relative resolution watch because we could be using ambient modules
118588
118620
  });
118589
118621
  }
118590
118622
  function resolveSingleModuleNameWithoutWatching(moduleName, containingFile) {
@@ -118602,7 +118634,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118602
118634
  function isNodeModulesAtTypesDirectory(dirPath) {
118603
118635
  return endsWith(dirPath, "/node_modules/@types");
118604
118636
  }
118605
- function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
118637
+ function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName, deferWatchingNonRelativeResolution) {
118606
118638
  var _a;
118607
118639
  if (resolution.refCount) {
118608
118640
  resolution.refCount++;
@@ -118610,7 +118642,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118610
118642
  } else {
118611
118643
  resolution.refCount = 1;
118612
118644
  Debug.assert(!((_a = resolution.files) == null ? void 0 : _a.size));
118613
- if (isExternalModuleNameRelative(name)) {
118645
+ if (!deferWatchingNonRelativeResolution || isExternalModuleNameRelative(name)) {
118614
118646
  watchFailedLookupLocationOfResolution(resolution);
118615
118647
  } else {
118616
118648
  nonRelativeExternalModuleResolutions.add(name, resolution);
@@ -118890,7 +118922,11 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
118890
118922
  return false;
118891
118923
  }
118892
118924
  (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
118893
- const packagePath = parseNodeModuleFromPath(fileOrDirectoryPath);
118925
+ const packagePath = parseNodeModuleFromPath(
118926
+ fileOrDirectoryPath,
118927
+ /*isFolder*/
118928
+ true
118929
+ );
118894
118930
  if (packagePath)
118895
118931
  (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(packagePath);
118896
118932
  }