typescript 5.1.0-dev.20230411 → 5.1.0-dev.20230413

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.
@@ -106,4 +106,13 @@ declare namespace Intl {
106
106
  */
107
107
  supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: Pick<SegmenterOptions, "localeMatcher">): BCP47LanguageTag[];
108
108
  };
109
+
110
+ /**
111
+ * Returns a sorted array of the supported collation, calendar, currency, numbering system, timezones, and units by the implementation.
112
+ * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf)
113
+ *
114
+ * @param key A string indicating the category of values to return.
115
+ * @returns A sorted array of the supported values.
116
+ */
117
+ function supportedValuesOf(key: "calendar" | "collation" | "currency" | "numberingSystem" | "timeZone" | "unit"): string[];
109
118
  }
package/lib/lib.es5.d.ts CHANGED
@@ -332,9 +332,14 @@ interface CallableFunction extends Function {
332
332
  /**
333
333
  * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
334
334
  * @param thisArg The object to be used as the this object.
335
- * @param args An array of argument values to be passed to the function.
336
335
  */
337
336
  apply<T, R>(this: (this: T) => R, thisArg: T): R;
337
+
338
+ /**
339
+ * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
340
+ * @param thisArg The object to be used as the this object.
341
+ * @param args An array of argument values to be passed to the function.
342
+ */
338
343
  apply<T, A extends any[], R>(this: (this: T, ...args: A) => R, thisArg: T, args: A): R;
339
344
 
340
345
  /**
@@ -348,23 +353,29 @@ interface CallableFunction extends Function {
348
353
  * For a given function, creates a bound function that has the same body as the original function.
349
354
  * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
350
355
  * @param thisArg The object to be used as the this object.
351
- * @param args Arguments to bind to the parameters of the function.
352
356
  */
353
357
  bind<T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;
354
- bind<T, A0, A extends any[], R>(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R;
355
- bind<T, A0, A1, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R;
356
- bind<T, A0, A1, A2, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2): (...args: A) => R;
357
- bind<T, A0, A1, A2, A3, A extends any[], R>(this: (this: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1, arg2: A2, arg3: A3): (...args: A) => R;
358
- bind<T, AX, R>(this: (this: T, ...args: AX[]) => R, thisArg: T, ...args: AX[]): (...args: AX[]) => R;
358
+
359
+ /**
360
+ * For a given function, creates a bound function that has the same body as the original function.
361
+ * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
362
+ * @param thisArg The object to be used as the this object.
363
+ * @param args Arguments to bind to the parameters of the function.
364
+ */
365
+ bind<T, A extends any[], B extends any[], R>(this: (this: T, ...args: [...A, ...B]) => R, thisArg: T, ...args: A): (...args: B) => R;
359
366
  }
360
367
 
361
368
  interface NewableFunction extends Function {
362
369
  /**
363
370
  * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
364
371
  * @param thisArg The object to be used as the this object.
365
- * @param args An array of argument values to be passed to the function.
366
372
  */
367
373
  apply<T>(this: new () => T, thisArg: T): void;
374
+ /**
375
+ * Calls the function with the specified object as the this value and the elements of specified array as the arguments.
376
+ * @param thisArg The object to be used as the this object.
377
+ * @param args An array of argument values to be passed to the function.
378
+ */
368
379
  apply<T, A extends any[]>(this: new (...args: A) => T, thisArg: T, args: A): void;
369
380
 
370
381
  /**
@@ -378,14 +389,16 @@ interface NewableFunction extends Function {
378
389
  * For a given function, creates a bound function that has the same body as the original function.
379
390
  * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
380
391
  * @param thisArg The object to be used as the this object.
381
- * @param args Arguments to bind to the parameters of the function.
382
392
  */
383
393
  bind<T>(this: T, thisArg: any): T;
384
- bind<A0, A extends any[], R>(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R;
385
- bind<A0, A1, A extends any[], R>(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R;
386
- bind<A0, A1, A2, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2): new (...args: A) => R;
387
- bind<A0, A1, A2, A3, A extends any[], R>(this: new (arg0: A0, arg1: A1, arg2: A2, arg3: A3, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1, arg2: A2, arg3: A3): new (...args: A) => R;
388
- bind<AX, R>(this: new (...args: AX[]) => R, thisArg: any, ...args: AX[]): new (...args: AX[]) => R;
394
+
395
+ /**
396
+ * For a given function, creates a bound function that has the same body as the original function.
397
+ * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
398
+ * @param thisArg The object to be used as the this object.
399
+ * @param args Arguments to bind to the parameters of the function.
400
+ */
401
+ bind<A extends any[], B extends any[], R>(this: new (...args: [...A, ...B]) => R, thisArg: any, ...args: A): new (...args: B) => R;
389
402
  }
390
403
 
391
404
  interface IArguments {
@@ -1832,7 +1845,7 @@ interface DataView {
1832
1845
 
1833
1846
  interface DataViewConstructor {
1834
1847
  readonly prototype: DataView;
1835
- new(buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): DataView;
1848
+ new(buffer: ArrayBufferLike & { BYTES_PER_ELEMENT?: never }, byteOffset?: number, byteLength?: number): DataView;
1836
1849
  }
1837
1850
  declare var DataView: DataViewConstructor;
1838
1851
 
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.20230411`;
21
+ var version = `${versionMajorMinor}.0-dev.20230413`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -43407,6 +43407,8 @@ function createTypeChecker(host) {
43407
43407
  var resolutionTargets = [];
43408
43408
  var resolutionResults = [];
43409
43409
  var resolutionPropertyNames = [];
43410
+ var resolutionStart = 0;
43411
+ var inVarianceComputation = false;
43410
43412
  var suggestionCount = 0;
43411
43413
  var maximumSuggestionCount = 10;
43412
43414
  var mergedSymbols = [];
@@ -44747,11 +44749,6 @@ function createTypeChecker(host) {
44747
44749
  diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
44748
44750
  } else if (result.flags & 256 /* RegularEnum */) {
44749
44751
  diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
44750
- } else {
44751
- Debug.assert(!!(result.flags & 128 /* ConstEnum */));
44752
- if (shouldPreserveConstEnums(compilerOptions)) {
44753
- diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
44754
- }
44755
44752
  }
44756
44753
  if (diagnosticMessage) {
44757
44754
  addRelatedInfo(
@@ -50607,7 +50604,7 @@ function createTypeChecker(host) {
50607
50604
  return true;
50608
50605
  }
50609
50606
  function findResolutionCycleStartIndex(target, propertyName) {
50610
- for (let i = resolutionTargets.length - 1; i >= 0; i--) {
50607
+ for (let i = resolutionTargets.length - 1; i >= resolutionStart; i--) {
50611
50608
  if (resolutionTargetHasProperty(resolutionTargets[i], resolutionPropertyNames[i])) {
50612
50609
  return -1;
50613
50610
  }
@@ -61579,40 +61576,31 @@ function createTypeChecker(host) {
61579
61576
  return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
61580
61577
  }
61581
61578
  function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
61582
- return findMatchingDiscriminantType(
61583
- source,
61584
- target,
61585
- isRelatedTo,
61586
- /*skipPartial*/
61587
- true
61588
- ) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
61579
+ return findMatchingDiscriminantType(source, target, isRelatedTo) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
61589
61580
  }
61590
- function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
61591
- const discriminable = target.types.map((_) => void 0);
61581
+ function discriminateTypeByDiscriminableItems(target, discriminators, related) {
61582
+ const types = target.types;
61583
+ const include = types.map((t) => t.flags & 402784252 /* Primitive */ ? 0 /* False */ : -1 /* True */);
61592
61584
  for (const [getDiscriminatingType, propertyName] of discriminators) {
61593
- const targetProp = getUnionOrIntersectionProperty(target, propertyName);
61594
- if (skipPartial && targetProp && getCheckFlags(targetProp) & 16 /* ReadPartial */) {
61595
- continue;
61585
+ let matched = false;
61586
+ for (let i = 0; i < types.length; i++) {
61587
+ if (include[i]) {
61588
+ const targetType = getTypeOfPropertyOfType(types[i], propertyName);
61589
+ if (targetType && related(getDiscriminatingType(), targetType)) {
61590
+ matched = true;
61591
+ } else {
61592
+ include[i] = 3 /* Maybe */;
61593
+ }
61594
+ }
61596
61595
  }
61597
- let i = 0;
61598
- for (const type of target.types) {
61599
- const targetType = getTypeOfPropertyOfType(type, propertyName);
61600
- if (targetType && related(getDiscriminatingType(), targetType)) {
61601
- discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
61602
- } else {
61603
- discriminable[i] = false;
61596
+ for (let i = 0; i < types.length; i++) {
61597
+ if (include[i] === 3 /* Maybe */) {
61598
+ include[i] = matched ? 0 /* False */ : -1 /* True */;
61604
61599
  }
61605
- i++;
61606
61600
  }
61607
61601
  }
61608
- const match = discriminable.indexOf(
61609
- /*searchElement*/
61610
- true
61611
- );
61612
- if (match === -1) {
61613
- return defaultValue;
61614
- }
61615
- return getUnionType(target.types.filter((_, index) => discriminable[index]));
61602
+ const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i])) : target;
61603
+ return filtered.flags & 131072 /* Never */ ? target : filtered;
61616
61604
  }
61617
61605
  function isWeakType(type) {
61618
61606
  if (type.flags & 524288 /* Object */) {
@@ -61643,6 +61631,11 @@ function createTypeChecker(host) {
61643
61631
  const links = getSymbolLinks(symbol);
61644
61632
  if (!links.variances) {
61645
61633
  (_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
61634
+ const oldVarianceComputation = inVarianceComputation;
61635
+ if (!inVarianceComputation) {
61636
+ inVarianceComputation = true;
61637
+ resolutionStart = resolutionTargets.length;
61638
+ }
61646
61639
  links.variances = emptyArray;
61647
61640
  const variances = [];
61648
61641
  for (const tp of typeParameters) {
@@ -61671,6 +61664,10 @@ function createTypeChecker(host) {
61671
61664
  }
61672
61665
  variances.push(variance);
61673
61666
  }
61667
+ if (!oldVarianceComputation) {
61668
+ inVarianceComputation = false;
61669
+ resolutionStart = 0;
61670
+ }
61674
61671
  links.variances = variances;
61675
61672
  (_b = tracing) == null ? void 0 : _b.pop({ variances: variances.map(Debug.formatVariance) });
61676
61673
  }
@@ -66907,8 +66904,7 @@ function createTypeChecker(host) {
66907
66904
  (s) => [() => undefinedType, s.escapedName]
66908
66905
  )
66909
66906
  ),
66910
- isTypeAssignableTo,
66911
- contextualType
66907
+ isTypeAssignableTo
66912
66908
  );
66913
66909
  }
66914
66910
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
@@ -66927,8 +66923,7 @@ function createTypeChecker(host) {
66927
66923
  (s) => [() => undefinedType, s.escapedName]
66928
66924
  )
66929
66925
  ),
66930
- isTypeAssignableTo,
66931
- contextualType
66926
+ isTypeAssignableTo
66932
66927
  );
66933
66928
  }
66934
66929
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -82942,7 +82937,7 @@ function createTypeChecker(host) {
82942
82937
  }
82943
82938
  return type;
82944
82939
  }
82945
- function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
82940
+ function findMatchingDiscriminantType(source, target, isRelatedTo) {
82946
82941
  if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
82947
82942
  const match = getMatchingUnionConstituentForType(target, source);
82948
82943
  if (match) {
@@ -82952,14 +82947,10 @@ function createTypeChecker(host) {
82952
82947
  if (sourceProperties) {
82953
82948
  const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
82954
82949
  if (sourcePropertiesFiltered) {
82955
- return discriminateTypeByDiscriminableItems(
82956
- target,
82957
- map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]),
82958
- isRelatedTo,
82959
- /*defaultValue*/
82960
- void 0,
82961
- skipPartial
82962
- );
82950
+ const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
82951
+ if (discriminated !== target) {
82952
+ return discriminated;
82953
+ }
82963
82954
  }
82964
82955
  }
82965
82956
  }
package/lib/tsserver.js CHANGED
@@ -2293,7 +2293,7 @@ module.exports = __toCommonJS(server_exports);
2293
2293
 
2294
2294
  // src/compiler/corePublic.ts
2295
2295
  var versionMajorMinor = "5.1";
2296
- var version = `${versionMajorMinor}.0-dev.20230411`;
2296
+ var version = `${versionMajorMinor}.0-dev.20230413`;
2297
2297
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2298
2298
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2299
2299
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -48057,6 +48057,8 @@ function createTypeChecker(host) {
48057
48057
  var resolutionTargets = [];
48058
48058
  var resolutionResults = [];
48059
48059
  var resolutionPropertyNames = [];
48060
+ var resolutionStart = 0;
48061
+ var inVarianceComputation = false;
48060
48062
  var suggestionCount = 0;
48061
48063
  var maximumSuggestionCount = 10;
48062
48064
  var mergedSymbols = [];
@@ -49397,11 +49399,6 @@ function createTypeChecker(host) {
49397
49399
  diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
49398
49400
  } else if (result.flags & 256 /* RegularEnum */) {
49399
49401
  diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
49400
- } else {
49401
- Debug.assert(!!(result.flags & 128 /* ConstEnum */));
49402
- if (shouldPreserveConstEnums(compilerOptions)) {
49403
- diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
49404
- }
49405
49402
  }
49406
49403
  if (diagnosticMessage) {
49407
49404
  addRelatedInfo(
@@ -55257,7 +55254,7 @@ function createTypeChecker(host) {
55257
55254
  return true;
55258
55255
  }
55259
55256
  function findResolutionCycleStartIndex(target, propertyName) {
55260
- for (let i = resolutionTargets.length - 1; i >= 0; i--) {
55257
+ for (let i = resolutionTargets.length - 1; i >= resolutionStart; i--) {
55261
55258
  if (resolutionTargetHasProperty(resolutionTargets[i], resolutionPropertyNames[i])) {
55262
55259
  return -1;
55263
55260
  }
@@ -66229,40 +66226,31 @@ function createTypeChecker(host) {
66229
66226
  return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
66230
66227
  }
66231
66228
  function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
66232
- return findMatchingDiscriminantType(
66233
- source,
66234
- target,
66235
- isRelatedTo,
66236
- /*skipPartial*/
66237
- true
66238
- ) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
66229
+ return findMatchingDiscriminantType(source, target, isRelatedTo) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
66239
66230
  }
66240
- function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
66241
- const discriminable = target.types.map((_) => void 0);
66231
+ function discriminateTypeByDiscriminableItems(target, discriminators, related) {
66232
+ const types = target.types;
66233
+ const include = types.map((t) => t.flags & 402784252 /* Primitive */ ? 0 /* False */ : -1 /* True */);
66242
66234
  for (const [getDiscriminatingType, propertyName] of discriminators) {
66243
- const targetProp = getUnionOrIntersectionProperty(target, propertyName);
66244
- if (skipPartial && targetProp && getCheckFlags(targetProp) & 16 /* ReadPartial */) {
66245
- continue;
66235
+ let matched = false;
66236
+ for (let i = 0; i < types.length; i++) {
66237
+ if (include[i]) {
66238
+ const targetType = getTypeOfPropertyOfType(types[i], propertyName);
66239
+ if (targetType && related(getDiscriminatingType(), targetType)) {
66240
+ matched = true;
66241
+ } else {
66242
+ include[i] = 3 /* Maybe */;
66243
+ }
66244
+ }
66246
66245
  }
66247
- let i = 0;
66248
- for (const type of target.types) {
66249
- const targetType = getTypeOfPropertyOfType(type, propertyName);
66250
- if (targetType && related(getDiscriminatingType(), targetType)) {
66251
- discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
66252
- } else {
66253
- discriminable[i] = false;
66246
+ for (let i = 0; i < types.length; i++) {
66247
+ if (include[i] === 3 /* Maybe */) {
66248
+ include[i] = matched ? 0 /* False */ : -1 /* True */;
66254
66249
  }
66255
- i++;
66256
66250
  }
66257
66251
  }
66258
- const match = discriminable.indexOf(
66259
- /*searchElement*/
66260
- true
66261
- );
66262
- if (match === -1) {
66263
- return defaultValue;
66264
- }
66265
- return getUnionType(target.types.filter((_, index) => discriminable[index]));
66252
+ const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i])) : target;
66253
+ return filtered.flags & 131072 /* Never */ ? target : filtered;
66266
66254
  }
66267
66255
  function isWeakType(type) {
66268
66256
  if (type.flags & 524288 /* Object */) {
@@ -66293,6 +66281,11 @@ function createTypeChecker(host) {
66293
66281
  const links = getSymbolLinks(symbol);
66294
66282
  if (!links.variances) {
66295
66283
  (_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
66284
+ const oldVarianceComputation = inVarianceComputation;
66285
+ if (!inVarianceComputation) {
66286
+ inVarianceComputation = true;
66287
+ resolutionStart = resolutionTargets.length;
66288
+ }
66296
66289
  links.variances = emptyArray;
66297
66290
  const variances = [];
66298
66291
  for (const tp of typeParameters) {
@@ -66321,6 +66314,10 @@ function createTypeChecker(host) {
66321
66314
  }
66322
66315
  variances.push(variance);
66323
66316
  }
66317
+ if (!oldVarianceComputation) {
66318
+ inVarianceComputation = false;
66319
+ resolutionStart = 0;
66320
+ }
66324
66321
  links.variances = variances;
66325
66322
  (_b = tracing) == null ? void 0 : _b.pop({ variances: variances.map(Debug.formatVariance) });
66326
66323
  }
@@ -71557,8 +71554,7 @@ function createTypeChecker(host) {
71557
71554
  (s) => [() => undefinedType, s.escapedName]
71558
71555
  )
71559
71556
  ),
71560
- isTypeAssignableTo,
71561
- contextualType
71557
+ isTypeAssignableTo
71562
71558
  );
71563
71559
  }
71564
71560
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
@@ -71577,8 +71573,7 @@ function createTypeChecker(host) {
71577
71573
  (s) => [() => undefinedType, s.escapedName]
71578
71574
  )
71579
71575
  ),
71580
- isTypeAssignableTo,
71581
- contextualType
71576
+ isTypeAssignableTo
71582
71577
  );
71583
71578
  }
71584
71579
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -87592,7 +87587,7 @@ function createTypeChecker(host) {
87592
87587
  }
87593
87588
  return type;
87594
87589
  }
87595
- function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
87590
+ function findMatchingDiscriminantType(source, target, isRelatedTo) {
87596
87591
  if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
87597
87592
  const match = getMatchingUnionConstituentForType(target, source);
87598
87593
  if (match) {
@@ -87602,14 +87597,10 @@ function createTypeChecker(host) {
87602
87597
  if (sourceProperties) {
87603
87598
  const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
87604
87599
  if (sourcePropertiesFiltered) {
87605
- return discriminateTypeByDiscriminableItems(
87606
- target,
87607
- map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]),
87608
- isRelatedTo,
87609
- /*defaultValue*/
87610
- void 0,
87611
- skipPartial
87612
- );
87600
+ const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
87601
+ if (discriminated !== target) {
87602
+ return discriminated;
87603
+ }
87613
87604
  }
87614
87605
  }
87615
87606
  }
@@ -128913,7 +128904,13 @@ function findPrecedingToken(position, sourceFile, startNode2, excludeJsdoc) {
128913
128904
  sourceFile,
128914
128905
  n.kind
128915
128906
  );
128916
- return candidate2 && findRightmostToken(candidate2, sourceFile);
128907
+ if (candidate2) {
128908
+ if (!excludeJsdoc && isJSDocCommentContainingNode(candidate2) && candidate2.getChildren(sourceFile).length) {
128909
+ return find2(candidate2);
128910
+ }
128911
+ return findRightmostToken(candidate2, sourceFile);
128912
+ }
128913
+ return void 0;
128917
128914
  } else {
128918
128915
  return find2(child);
128919
128916
  }
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230411`;
38
+ version = `${versionMajorMinor}.0-dev.20230413`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -45858,6 +45858,8 @@ ${lanes.join("\n")}
45858
45858
  var resolutionTargets = [];
45859
45859
  var resolutionResults = [];
45860
45860
  var resolutionPropertyNames = [];
45861
+ var resolutionStart = 0;
45862
+ var inVarianceComputation = false;
45861
45863
  var suggestionCount = 0;
45862
45864
  var maximumSuggestionCount = 10;
45863
45865
  var mergedSymbols = [];
@@ -47198,11 +47200,6 @@ ${lanes.join("\n")}
47198
47200
  diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
47199
47201
  } else if (result.flags & 256 /* RegularEnum */) {
47200
47202
  diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
47201
- } else {
47202
- Debug.assert(!!(result.flags & 128 /* ConstEnum */));
47203
- if (shouldPreserveConstEnums(compilerOptions)) {
47204
- diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
47205
- }
47206
47203
  }
47207
47204
  if (diagnosticMessage) {
47208
47205
  addRelatedInfo(
@@ -53058,7 +53055,7 @@ ${lanes.join("\n")}
53058
53055
  return true;
53059
53056
  }
53060
53057
  function findResolutionCycleStartIndex(target, propertyName) {
53061
- for (let i = resolutionTargets.length - 1; i >= 0; i--) {
53058
+ for (let i = resolutionTargets.length - 1; i >= resolutionStart; i--) {
53062
53059
  if (resolutionTargetHasProperty(resolutionTargets[i], resolutionPropertyNames[i])) {
53063
53060
  return -1;
53064
53061
  }
@@ -64030,40 +64027,31 @@ ${lanes.join("\n")}
64030
64027
  return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
64031
64028
  }
64032
64029
  function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
64033
- return findMatchingDiscriminantType(
64034
- source,
64035
- target,
64036
- isRelatedTo,
64037
- /*skipPartial*/
64038
- true
64039
- ) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
64030
+ return findMatchingDiscriminantType(source, target, isRelatedTo) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
64040
64031
  }
64041
- function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
64042
- const discriminable = target.types.map((_) => void 0);
64032
+ function discriminateTypeByDiscriminableItems(target, discriminators, related) {
64033
+ const types = target.types;
64034
+ const include = types.map((t) => t.flags & 402784252 /* Primitive */ ? 0 /* False */ : -1 /* True */);
64043
64035
  for (const [getDiscriminatingType, propertyName] of discriminators) {
64044
- const targetProp = getUnionOrIntersectionProperty(target, propertyName);
64045
- if (skipPartial && targetProp && getCheckFlags(targetProp) & 16 /* ReadPartial */) {
64046
- continue;
64036
+ let matched = false;
64037
+ for (let i = 0; i < types.length; i++) {
64038
+ if (include[i]) {
64039
+ const targetType = getTypeOfPropertyOfType(types[i], propertyName);
64040
+ if (targetType && related(getDiscriminatingType(), targetType)) {
64041
+ matched = true;
64042
+ } else {
64043
+ include[i] = 3 /* Maybe */;
64044
+ }
64045
+ }
64047
64046
  }
64048
- let i = 0;
64049
- for (const type of target.types) {
64050
- const targetType = getTypeOfPropertyOfType(type, propertyName);
64051
- if (targetType && related(getDiscriminatingType(), targetType)) {
64052
- discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
64053
- } else {
64054
- discriminable[i] = false;
64047
+ for (let i = 0; i < types.length; i++) {
64048
+ if (include[i] === 3 /* Maybe */) {
64049
+ include[i] = matched ? 0 /* False */ : -1 /* True */;
64055
64050
  }
64056
- i++;
64057
64051
  }
64058
64052
  }
64059
- const match = discriminable.indexOf(
64060
- /*searchElement*/
64061
- true
64062
- );
64063
- if (match === -1) {
64064
- return defaultValue;
64065
- }
64066
- return getUnionType(target.types.filter((_, index) => discriminable[index]));
64053
+ const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i])) : target;
64054
+ return filtered.flags & 131072 /* Never */ ? target : filtered;
64067
64055
  }
64068
64056
  function isWeakType(type) {
64069
64057
  if (type.flags & 524288 /* Object */) {
@@ -64094,6 +64082,11 @@ ${lanes.join("\n")}
64094
64082
  const links = getSymbolLinks(symbol);
64095
64083
  if (!links.variances) {
64096
64084
  (_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
64085
+ const oldVarianceComputation = inVarianceComputation;
64086
+ if (!inVarianceComputation) {
64087
+ inVarianceComputation = true;
64088
+ resolutionStart = resolutionTargets.length;
64089
+ }
64097
64090
  links.variances = emptyArray;
64098
64091
  const variances = [];
64099
64092
  for (const tp of typeParameters) {
@@ -64122,6 +64115,10 @@ ${lanes.join("\n")}
64122
64115
  }
64123
64116
  variances.push(variance);
64124
64117
  }
64118
+ if (!oldVarianceComputation) {
64119
+ inVarianceComputation = false;
64120
+ resolutionStart = 0;
64121
+ }
64125
64122
  links.variances = variances;
64126
64123
  (_b = tracing) == null ? void 0 : _b.pop({ variances: variances.map(Debug.formatVariance) });
64127
64124
  }
@@ -69358,8 +69355,7 @@ ${lanes.join("\n")}
69358
69355
  (s) => [() => undefinedType, s.escapedName]
69359
69356
  )
69360
69357
  ),
69361
- isTypeAssignableTo,
69362
- contextualType
69358
+ isTypeAssignableTo
69363
69359
  );
69364
69360
  }
69365
69361
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
@@ -69378,8 +69374,7 @@ ${lanes.join("\n")}
69378
69374
  (s) => [() => undefinedType, s.escapedName]
69379
69375
  )
69380
69376
  ),
69381
- isTypeAssignableTo,
69382
- contextualType
69377
+ isTypeAssignableTo
69383
69378
  );
69384
69379
  }
69385
69380
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -85393,7 +85388,7 @@ ${lanes.join("\n")}
85393
85388
  }
85394
85389
  return type;
85395
85390
  }
85396
- function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
85391
+ function findMatchingDiscriminantType(source, target, isRelatedTo) {
85397
85392
  if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
85398
85393
  const match = getMatchingUnionConstituentForType(target, source);
85399
85394
  if (match) {
@@ -85403,14 +85398,10 @@ ${lanes.join("\n")}
85403
85398
  if (sourceProperties) {
85404
85399
  const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
85405
85400
  if (sourcePropertiesFiltered) {
85406
- return discriminateTypeByDiscriminableItems(
85407
- target,
85408
- map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]),
85409
- isRelatedTo,
85410
- /*defaultValue*/
85411
- void 0,
85412
- skipPartial
85413
- );
85401
+ const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
85402
+ if (discriminated !== target) {
85403
+ return discriminated;
85404
+ }
85414
85405
  }
85415
85406
  }
85416
85407
  }
@@ -127225,7 +127216,13 @@ ${lanes.join("\n")}
127225
127216
  sourceFile,
127226
127217
  n.kind
127227
127218
  );
127228
- return candidate2 && findRightmostToken(candidate2, sourceFile);
127219
+ if (candidate2) {
127220
+ if (!excludeJsdoc && isJSDocCommentContainingNode(candidate2) && candidate2.getChildren(sourceFile).length) {
127221
+ return find2(candidate2);
127222
+ }
127223
+ return findRightmostToken(candidate2, sourceFile);
127224
+ }
127225
+ return void 0;
127229
127226
  } else {
127230
127227
  return find2(child);
127231
127228
  }
package/lib/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.1";
38
- version = `${versionMajorMinor}.0-dev.20230411`;
38
+ version = `${versionMajorMinor}.0-dev.20230413`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -45858,6 +45858,8 @@ ${lanes.join("\n")}
45858
45858
  var resolutionTargets = [];
45859
45859
  var resolutionResults = [];
45860
45860
  var resolutionPropertyNames = [];
45861
+ var resolutionStart = 0;
45862
+ var inVarianceComputation = false;
45861
45863
  var suggestionCount = 0;
45862
45864
  var maximumSuggestionCount = 10;
45863
45865
  var mergedSymbols = [];
@@ -47198,11 +47200,6 @@ ${lanes.join("\n")}
47198
47200
  diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
47199
47201
  } else if (result.flags & 256 /* RegularEnum */) {
47200
47202
  diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
47201
- } else {
47202
- Debug.assert(!!(result.flags & 128 /* ConstEnum */));
47203
- if (shouldPreserveConstEnums(compilerOptions)) {
47204
- diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
47205
- }
47206
47203
  }
47207
47204
  if (diagnosticMessage) {
47208
47205
  addRelatedInfo(
@@ -53058,7 +53055,7 @@ ${lanes.join("\n")}
53058
53055
  return true;
53059
53056
  }
53060
53057
  function findResolutionCycleStartIndex(target, propertyName) {
53061
- for (let i = resolutionTargets.length - 1; i >= 0; i--) {
53058
+ for (let i = resolutionTargets.length - 1; i >= resolutionStart; i--) {
53062
53059
  if (resolutionTargetHasProperty(resolutionTargets[i], resolutionPropertyNames[i])) {
53063
53060
  return -1;
53064
53061
  }
@@ -64030,40 +64027,31 @@ ${lanes.join("\n")}
64030
64027
  return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
64031
64028
  }
64032
64029
  function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
64033
- return findMatchingDiscriminantType(
64034
- source,
64035
- target,
64036
- isRelatedTo,
64037
- /*skipPartial*/
64038
- true
64039
- ) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
64030
+ return findMatchingDiscriminantType(source, target, isRelatedTo) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
64040
64031
  }
64041
- function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
64042
- const discriminable = target.types.map((_) => void 0);
64032
+ function discriminateTypeByDiscriminableItems(target, discriminators, related) {
64033
+ const types = target.types;
64034
+ const include = types.map((t) => t.flags & 402784252 /* Primitive */ ? 0 /* False */ : -1 /* True */);
64043
64035
  for (const [getDiscriminatingType, propertyName] of discriminators) {
64044
- const targetProp = getUnionOrIntersectionProperty(target, propertyName);
64045
- if (skipPartial && targetProp && getCheckFlags(targetProp) & 16 /* ReadPartial */) {
64046
- continue;
64036
+ let matched = false;
64037
+ for (let i = 0; i < types.length; i++) {
64038
+ if (include[i]) {
64039
+ const targetType = getTypeOfPropertyOfType(types[i], propertyName);
64040
+ if (targetType && related(getDiscriminatingType(), targetType)) {
64041
+ matched = true;
64042
+ } else {
64043
+ include[i] = 3 /* Maybe */;
64044
+ }
64045
+ }
64047
64046
  }
64048
- let i = 0;
64049
- for (const type of target.types) {
64050
- const targetType = getTypeOfPropertyOfType(type, propertyName);
64051
- if (targetType && related(getDiscriminatingType(), targetType)) {
64052
- discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
64053
- } else {
64054
- discriminable[i] = false;
64047
+ for (let i = 0; i < types.length; i++) {
64048
+ if (include[i] === 3 /* Maybe */) {
64049
+ include[i] = matched ? 0 /* False */ : -1 /* True */;
64055
64050
  }
64056
- i++;
64057
64051
  }
64058
64052
  }
64059
- const match = discriminable.indexOf(
64060
- /*searchElement*/
64061
- true
64062
- );
64063
- if (match === -1) {
64064
- return defaultValue;
64065
- }
64066
- return getUnionType(target.types.filter((_, index) => discriminable[index]));
64053
+ const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i])) : target;
64054
+ return filtered.flags & 131072 /* Never */ ? target : filtered;
64067
64055
  }
64068
64056
  function isWeakType(type) {
64069
64057
  if (type.flags & 524288 /* Object */) {
@@ -64094,6 +64082,11 @@ ${lanes.join("\n")}
64094
64082
  const links = getSymbolLinks(symbol);
64095
64083
  if (!links.variances) {
64096
64084
  (_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
64085
+ const oldVarianceComputation = inVarianceComputation;
64086
+ if (!inVarianceComputation) {
64087
+ inVarianceComputation = true;
64088
+ resolutionStart = resolutionTargets.length;
64089
+ }
64097
64090
  links.variances = emptyArray;
64098
64091
  const variances = [];
64099
64092
  for (const tp of typeParameters) {
@@ -64122,6 +64115,10 @@ ${lanes.join("\n")}
64122
64115
  }
64123
64116
  variances.push(variance);
64124
64117
  }
64118
+ if (!oldVarianceComputation) {
64119
+ inVarianceComputation = false;
64120
+ resolutionStart = 0;
64121
+ }
64125
64122
  links.variances = variances;
64126
64123
  (_b = tracing) == null ? void 0 : _b.pop({ variances: variances.map(Debug.formatVariance) });
64127
64124
  }
@@ -69358,8 +69355,7 @@ ${lanes.join("\n")}
69358
69355
  (s) => [() => undefinedType, s.escapedName]
69359
69356
  )
69360
69357
  ),
69361
- isTypeAssignableTo,
69362
- contextualType
69358
+ isTypeAssignableTo
69363
69359
  );
69364
69360
  }
69365
69361
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
@@ -69378,8 +69374,7 @@ ${lanes.join("\n")}
69378
69374
  (s) => [() => undefinedType, s.escapedName]
69379
69375
  )
69380
69376
  ),
69381
- isTypeAssignableTo,
69382
- contextualType
69377
+ isTypeAssignableTo
69383
69378
  );
69384
69379
  }
69385
69380
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -85393,7 +85388,7 @@ ${lanes.join("\n")}
85393
85388
  }
85394
85389
  return type;
85395
85390
  }
85396
- function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
85391
+ function findMatchingDiscriminantType(source, target, isRelatedTo) {
85397
85392
  if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
85398
85393
  const match = getMatchingUnionConstituentForType(target, source);
85399
85394
  if (match) {
@@ -85403,14 +85398,10 @@ ${lanes.join("\n")}
85403
85398
  if (sourceProperties) {
85404
85399
  const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
85405
85400
  if (sourcePropertiesFiltered) {
85406
- return discriminateTypeByDiscriminableItems(
85407
- target,
85408
- map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]),
85409
- isRelatedTo,
85410
- /*defaultValue*/
85411
- void 0,
85412
- skipPartial
85413
- );
85401
+ const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
85402
+ if (discriminated !== target) {
85403
+ return discriminated;
85404
+ }
85414
85405
  }
85415
85406
  }
85416
85407
  }
@@ -127239,7 +127230,13 @@ ${lanes.join("\n")}
127239
127230
  sourceFile,
127240
127231
  n.kind
127241
127232
  );
127242
- return candidate2 && findRightmostToken(candidate2, sourceFile);
127233
+ if (candidate2) {
127234
+ if (!excludeJsdoc && isJSDocCommentContainingNode(candidate2) && candidate2.getChildren(sourceFile).length) {
127235
+ return find2(candidate2);
127236
+ }
127237
+ return findRightmostToken(candidate2, sourceFile);
127238
+ }
127239
+ return void 0;
127243
127240
  } else {
127244
127241
  return find2(child);
127245
127242
  }
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.1";
57
- var version = `${versionMajorMinor}.0-dev.20230411`;
57
+ var version = `${versionMajorMinor}.0-dev.20230413`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.1.0-dev.20230411",
5
+ "version": "5.1.0-dev.20230413",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -113,5 +113,5 @@
113
113
  "node": "14.21.1",
114
114
  "npm": "8.19.3"
115
115
  },
116
- "gitHead": "89a6482d60ed3d59b2b697ca29a6cf662ebbe20c"
116
+ "gitHead": "33ab6fd0d5eceb7715000398382b60d64dde1c67"
117
117
  }