typescript 5.1.0-dev.20230412 → 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 {
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.20230412`;
21
+ var version = `${versionMajorMinor}.0-dev.20230413`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -44749,11 +44749,6 @@ function createTypeChecker(host) {
44749
44749
  diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
44750
44750
  } else if (result.flags & 256 /* RegularEnum */) {
44751
44751
  diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
44752
- } else {
44753
- Debug.assert(!!(result.flags & 128 /* ConstEnum */));
44754
- if (shouldPreserveConstEnums(compilerOptions)) {
44755
- diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
44756
- }
44757
44752
  }
44758
44753
  if (diagnosticMessage) {
44759
44754
  addRelatedInfo(
@@ -61581,40 +61576,31 @@ function createTypeChecker(host) {
61581
61576
  return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
61582
61577
  }
61583
61578
  function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
61584
- return findMatchingDiscriminantType(
61585
- source,
61586
- target,
61587
- isRelatedTo,
61588
- /*skipPartial*/
61589
- true
61590
- ) || 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);
61591
61580
  }
61592
- function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
61593
- 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 */);
61594
61584
  for (const [getDiscriminatingType, propertyName] of discriminators) {
61595
- const targetProp = getUnionOrIntersectionProperty(target, propertyName);
61596
- if (skipPartial && targetProp && getCheckFlags(targetProp) & 16 /* ReadPartial */) {
61597
- 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
+ }
61598
61595
  }
61599
- let i = 0;
61600
- for (const type of target.types) {
61601
- const targetType = getTypeOfPropertyOfType(type, propertyName);
61602
- if (targetType && related(getDiscriminatingType(), targetType)) {
61603
- discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
61604
- } else {
61605
- 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 */;
61606
61599
  }
61607
- i++;
61608
61600
  }
61609
61601
  }
61610
- const match = discriminable.indexOf(
61611
- /*searchElement*/
61612
- true
61613
- );
61614
- if (match === -1) {
61615
- return defaultValue;
61616
- }
61617
- 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;
61618
61604
  }
61619
61605
  function isWeakType(type) {
61620
61606
  if (type.flags & 524288 /* Object */) {
@@ -66918,8 +66904,7 @@ function createTypeChecker(host) {
66918
66904
  (s) => [() => undefinedType, s.escapedName]
66919
66905
  )
66920
66906
  ),
66921
- isTypeAssignableTo,
66922
- contextualType
66907
+ isTypeAssignableTo
66923
66908
  );
66924
66909
  }
66925
66910
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
@@ -66938,8 +66923,7 @@ function createTypeChecker(host) {
66938
66923
  (s) => [() => undefinedType, s.escapedName]
66939
66924
  )
66940
66925
  ),
66941
- isTypeAssignableTo,
66942
- contextualType
66926
+ isTypeAssignableTo
66943
66927
  );
66944
66928
  }
66945
66929
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -82953,7 +82937,7 @@ function createTypeChecker(host) {
82953
82937
  }
82954
82938
  return type;
82955
82939
  }
82956
- function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
82940
+ function findMatchingDiscriminantType(source, target, isRelatedTo) {
82957
82941
  if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
82958
82942
  const match = getMatchingUnionConstituentForType(target, source);
82959
82943
  if (match) {
@@ -82963,14 +82947,10 @@ function createTypeChecker(host) {
82963
82947
  if (sourceProperties) {
82964
82948
  const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
82965
82949
  if (sourcePropertiesFiltered) {
82966
- return discriminateTypeByDiscriminableItems(
82967
- target,
82968
- map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]),
82969
- isRelatedTo,
82970
- /*defaultValue*/
82971
- void 0,
82972
- skipPartial
82973
- );
82950
+ const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
82951
+ if (discriminated !== target) {
82952
+ return discriminated;
82953
+ }
82974
82954
  }
82975
82955
  }
82976
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.20230412`;
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";
@@ -49399,11 +49399,6 @@ function createTypeChecker(host) {
49399
49399
  diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
49400
49400
  } else if (result.flags & 256 /* RegularEnum */) {
49401
49401
  diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
49402
- } else {
49403
- Debug.assert(!!(result.flags & 128 /* ConstEnum */));
49404
- if (shouldPreserveConstEnums(compilerOptions)) {
49405
- diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
49406
- }
49407
49402
  }
49408
49403
  if (diagnosticMessage) {
49409
49404
  addRelatedInfo(
@@ -66231,40 +66226,31 @@ function createTypeChecker(host) {
66231
66226
  return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
66232
66227
  }
66233
66228
  function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
66234
- return findMatchingDiscriminantType(
66235
- source,
66236
- target,
66237
- isRelatedTo,
66238
- /*skipPartial*/
66239
- true
66240
- ) || 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);
66241
66230
  }
66242
- function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
66243
- 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 */);
66244
66234
  for (const [getDiscriminatingType, propertyName] of discriminators) {
66245
- const targetProp = getUnionOrIntersectionProperty(target, propertyName);
66246
- if (skipPartial && targetProp && getCheckFlags(targetProp) & 16 /* ReadPartial */) {
66247
- 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
+ }
66248
66245
  }
66249
- let i = 0;
66250
- for (const type of target.types) {
66251
- const targetType = getTypeOfPropertyOfType(type, propertyName);
66252
- if (targetType && related(getDiscriminatingType(), targetType)) {
66253
- discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
66254
- } else {
66255
- 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 */;
66256
66249
  }
66257
- i++;
66258
66250
  }
66259
66251
  }
66260
- const match = discriminable.indexOf(
66261
- /*searchElement*/
66262
- true
66263
- );
66264
- if (match === -1) {
66265
- return defaultValue;
66266
- }
66267
- 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;
66268
66254
  }
66269
66255
  function isWeakType(type) {
66270
66256
  if (type.flags & 524288 /* Object */) {
@@ -71568,8 +71554,7 @@ function createTypeChecker(host) {
71568
71554
  (s) => [() => undefinedType, s.escapedName]
71569
71555
  )
71570
71556
  ),
71571
- isTypeAssignableTo,
71572
- contextualType
71557
+ isTypeAssignableTo
71573
71558
  );
71574
71559
  }
71575
71560
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
@@ -71588,8 +71573,7 @@ function createTypeChecker(host) {
71588
71573
  (s) => [() => undefinedType, s.escapedName]
71589
71574
  )
71590
71575
  ),
71591
- isTypeAssignableTo,
71592
- contextualType
71576
+ isTypeAssignableTo
71593
71577
  );
71594
71578
  }
71595
71579
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -87603,7 +87587,7 @@ function createTypeChecker(host) {
87603
87587
  }
87604
87588
  return type;
87605
87589
  }
87606
- function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
87590
+ function findMatchingDiscriminantType(source, target, isRelatedTo) {
87607
87591
  if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
87608
87592
  const match = getMatchingUnionConstituentForType(target, source);
87609
87593
  if (match) {
@@ -87613,14 +87597,10 @@ function createTypeChecker(host) {
87613
87597
  if (sourceProperties) {
87614
87598
  const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
87615
87599
  if (sourcePropertiesFiltered) {
87616
- return discriminateTypeByDiscriminableItems(
87617
- target,
87618
- map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]),
87619
- isRelatedTo,
87620
- /*defaultValue*/
87621
- void 0,
87622
- skipPartial
87623
- );
87600
+ const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
87601
+ if (discriminated !== target) {
87602
+ return discriminated;
87603
+ }
87624
87604
  }
87625
87605
  }
87626
87606
  }
@@ -128924,7 +128904,13 @@ function findPrecedingToken(position, sourceFile, startNode2, excludeJsdoc) {
128924
128904
  sourceFile,
128925
128905
  n.kind
128926
128906
  );
128927
- 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;
128928
128914
  } else {
128929
128915
  return find2(child);
128930
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.20230412`;
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";
@@ -47200,11 +47200,6 @@ ${lanes.join("\n")}
47200
47200
  diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
47201
47201
  } else if (result.flags & 256 /* RegularEnum */) {
47202
47202
  diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
47203
- } else {
47204
- Debug.assert(!!(result.flags & 128 /* ConstEnum */));
47205
- if (shouldPreserveConstEnums(compilerOptions)) {
47206
- diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
47207
- }
47208
47203
  }
47209
47204
  if (diagnosticMessage) {
47210
47205
  addRelatedInfo(
@@ -64032,40 +64027,31 @@ ${lanes.join("\n")}
64032
64027
  return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
64033
64028
  }
64034
64029
  function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
64035
- return findMatchingDiscriminantType(
64036
- source,
64037
- target,
64038
- isRelatedTo,
64039
- /*skipPartial*/
64040
- true
64041
- ) || 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);
64042
64031
  }
64043
- function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
64044
- 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 */);
64045
64035
  for (const [getDiscriminatingType, propertyName] of discriminators) {
64046
- const targetProp = getUnionOrIntersectionProperty(target, propertyName);
64047
- if (skipPartial && targetProp && getCheckFlags(targetProp) & 16 /* ReadPartial */) {
64048
- 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
+ }
64049
64046
  }
64050
- let i = 0;
64051
- for (const type of target.types) {
64052
- const targetType = getTypeOfPropertyOfType(type, propertyName);
64053
- if (targetType && related(getDiscriminatingType(), targetType)) {
64054
- discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
64055
- } else {
64056
- 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 */;
64057
64050
  }
64058
- i++;
64059
64051
  }
64060
64052
  }
64061
- const match = discriminable.indexOf(
64062
- /*searchElement*/
64063
- true
64064
- );
64065
- if (match === -1) {
64066
- return defaultValue;
64067
- }
64068
- 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;
64069
64055
  }
64070
64056
  function isWeakType(type) {
64071
64057
  if (type.flags & 524288 /* Object */) {
@@ -69369,8 +69355,7 @@ ${lanes.join("\n")}
69369
69355
  (s) => [() => undefinedType, s.escapedName]
69370
69356
  )
69371
69357
  ),
69372
- isTypeAssignableTo,
69373
- contextualType
69358
+ isTypeAssignableTo
69374
69359
  );
69375
69360
  }
69376
69361
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
@@ -69389,8 +69374,7 @@ ${lanes.join("\n")}
69389
69374
  (s) => [() => undefinedType, s.escapedName]
69390
69375
  )
69391
69376
  ),
69392
- isTypeAssignableTo,
69393
- contextualType
69377
+ isTypeAssignableTo
69394
69378
  );
69395
69379
  }
69396
69380
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -85404,7 +85388,7 @@ ${lanes.join("\n")}
85404
85388
  }
85405
85389
  return type;
85406
85390
  }
85407
- function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
85391
+ function findMatchingDiscriminantType(source, target, isRelatedTo) {
85408
85392
  if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
85409
85393
  const match = getMatchingUnionConstituentForType(target, source);
85410
85394
  if (match) {
@@ -85414,14 +85398,10 @@ ${lanes.join("\n")}
85414
85398
  if (sourceProperties) {
85415
85399
  const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
85416
85400
  if (sourcePropertiesFiltered) {
85417
- return discriminateTypeByDiscriminableItems(
85418
- target,
85419
- map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]),
85420
- isRelatedTo,
85421
- /*defaultValue*/
85422
- void 0,
85423
- skipPartial
85424
- );
85401
+ const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
85402
+ if (discriminated !== target) {
85403
+ return discriminated;
85404
+ }
85425
85405
  }
85426
85406
  }
85427
85407
  }
@@ -127236,7 +127216,13 @@ ${lanes.join("\n")}
127236
127216
  sourceFile,
127237
127217
  n.kind
127238
127218
  );
127239
- 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;
127240
127226
  } else {
127241
127227
  return find2(child);
127242
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.20230412`;
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";
@@ -47200,11 +47200,6 @@ ${lanes.join("\n")}
47200
47200
  diagnosticMessage = error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationName);
47201
47201
  } else if (result.flags & 256 /* RegularEnum */) {
47202
47202
  diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
47203
- } else {
47204
- Debug.assert(!!(result.flags & 128 /* ConstEnum */));
47205
- if (shouldPreserveConstEnums(compilerOptions)) {
47206
- diagnosticMessage = error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationName);
47207
- }
47208
47203
  }
47209
47204
  if (diagnosticMessage) {
47210
47205
  addRelatedInfo(
@@ -64032,40 +64027,31 @@ ${lanes.join("\n")}
64032
64027
  return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
64033
64028
  }
64034
64029
  function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
64035
- return findMatchingDiscriminantType(
64036
- source,
64037
- target,
64038
- isRelatedTo,
64039
- /*skipPartial*/
64040
- true
64041
- ) || 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);
64042
64031
  }
64043
- function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
64044
- 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 */);
64045
64035
  for (const [getDiscriminatingType, propertyName] of discriminators) {
64046
- const targetProp = getUnionOrIntersectionProperty(target, propertyName);
64047
- if (skipPartial && targetProp && getCheckFlags(targetProp) & 16 /* ReadPartial */) {
64048
- 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
+ }
64049
64046
  }
64050
- let i = 0;
64051
- for (const type of target.types) {
64052
- const targetType = getTypeOfPropertyOfType(type, propertyName);
64053
- if (targetType && related(getDiscriminatingType(), targetType)) {
64054
- discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
64055
- } else {
64056
- 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 */;
64057
64050
  }
64058
- i++;
64059
64051
  }
64060
64052
  }
64061
- const match = discriminable.indexOf(
64062
- /*searchElement*/
64063
- true
64064
- );
64065
- if (match === -1) {
64066
- return defaultValue;
64067
- }
64068
- 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;
64069
64055
  }
64070
64056
  function isWeakType(type) {
64071
64057
  if (type.flags & 524288 /* Object */) {
@@ -69369,8 +69355,7 @@ ${lanes.join("\n")}
69369
69355
  (s) => [() => undefinedType, s.escapedName]
69370
69356
  )
69371
69357
  ),
69372
- isTypeAssignableTo,
69373
- contextualType
69358
+ isTypeAssignableTo
69374
69359
  );
69375
69360
  }
69376
69361
  function discriminateContextualTypeByJSXAttributes(node, contextualType) {
@@ -69389,8 +69374,7 @@ ${lanes.join("\n")}
69389
69374
  (s) => [() => undefinedType, s.escapedName]
69390
69375
  )
69391
69376
  ),
69392
- isTypeAssignableTo,
69393
- contextualType
69377
+ isTypeAssignableTo
69394
69378
  );
69395
69379
  }
69396
69380
  function getApparentTypeOfContextualType(node, contextFlags) {
@@ -85404,7 +85388,7 @@ ${lanes.join("\n")}
85404
85388
  }
85405
85389
  return type;
85406
85390
  }
85407
- function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
85391
+ function findMatchingDiscriminantType(source, target, isRelatedTo) {
85408
85392
  if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
85409
85393
  const match = getMatchingUnionConstituentForType(target, source);
85410
85394
  if (match) {
@@ -85414,14 +85398,10 @@ ${lanes.join("\n")}
85414
85398
  if (sourceProperties) {
85415
85399
  const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
85416
85400
  if (sourcePropertiesFiltered) {
85417
- return discriminateTypeByDiscriminableItems(
85418
- target,
85419
- map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]),
85420
- isRelatedTo,
85421
- /*defaultValue*/
85422
- void 0,
85423
- skipPartial
85424
- );
85401
+ const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
85402
+ if (discriminated !== target) {
85403
+ return discriminated;
85404
+ }
85425
85405
  }
85426
85406
  }
85427
85407
  }
@@ -127250,7 +127230,13 @@ ${lanes.join("\n")}
127250
127230
  sourceFile,
127251
127231
  n.kind
127252
127232
  );
127253
- 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;
127254
127240
  } else {
127255
127241
  return find2(child);
127256
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.20230412`;
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.20230412",
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": "2db688e36ff57ee1d4f730e124ac340379eae4f0"
116
+ "gitHead": "33ab6fd0d5eceb7715000398382b60d64dde1c67"
117
117
  }