typescript 4.8.0-dev.20220701 → 4.8.0-dev.20220705

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220701";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220705";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -68834,20 +68834,30 @@ var ts;
68834
68834
  isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] :
68835
68835
  type;
68836
68836
  }
68837
- function createAwaitedTypeIfNeeded(type) {
68838
- if (isTypeAny(type)) {
68839
- return type;
68840
- }
68841
- if (isAwaitedTypeInstantiation(type)) {
68842
- return type;
68837
+ function isAwaitedTypeNeeded(type) {
68838
+ if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) {
68839
+ return false;
68843
68840
  }
68844
68841
  if (isGenericObjectType(type)) {
68845
68842
  var baseConstraint = getBaseConstraintOfType(type);
68846
68843
  if (!baseConstraint || (baseConstraint.flags & 3) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
68847
- var awaitedSymbol = getGlobalAwaitedSymbol(true);
68848
- if (awaitedSymbol) {
68849
- return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
68850
- }
68844
+ return true;
68845
+ }
68846
+ }
68847
+ return false;
68848
+ }
68849
+ function tryCreateAwaitedType(type) {
68850
+ var awaitedSymbol = getGlobalAwaitedSymbol(true);
68851
+ if (awaitedSymbol) {
68852
+ return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
68853
+ }
68854
+ return undefined;
68855
+ }
68856
+ function createAwaitedTypeIfNeeded(type) {
68857
+ if (isAwaitedTypeNeeded(type)) {
68858
+ var awaitedType = tryCreateAwaitedType(type);
68859
+ if (awaitedType) {
68860
+ return awaitedType;
68851
68861
  }
68852
68862
  }
68853
68863
  ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like.");
@@ -68881,6 +68891,9 @@ var ts;
68881
68891
  awaitedTypeStack.pop();
68882
68892
  return typeAsAwaitable.awaitedTypeOfType = mapped;
68883
68893
  }
68894
+ if (isAwaitedTypeNeeded(type)) {
68895
+ return typeAsAwaitable.awaitedTypeOfType = type;
68896
+ }
68884
68897
  var thisTypeForErrorOut = { value: undefined };
68885
68898
  var promisedType = getPromisedTypeOfPromise(type, undefined, thisTypeForErrorOut);
68886
68899
  if (promisedType) {
package/lib/tsserver.js CHANGED
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-dev.20220701";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220705";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -81991,6 +81991,32 @@ var ts;
81991
81991
  isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] :
81992
81992
  type;
81993
81993
  }
81994
+ function isAwaitedTypeNeeded(type) {
81995
+ // If this is already an `Awaited<T>`, we shouldn't wrap it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
81996
+ if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) {
81997
+ return false;
81998
+ }
81999
+ // We only need `Awaited<T>` if `T` contains possibly non-primitive types.
82000
+ if (isGenericObjectType(type)) {
82001
+ var baseConstraint = getBaseConstraintOfType(type);
82002
+ // We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82003
+ // or is promise-like.
82004
+ if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82005
+ return true;
82006
+ }
82007
+ }
82008
+ return false;
82009
+ }
82010
+ function tryCreateAwaitedType(type) {
82011
+ // Nothing to do if `Awaited<T>` doesn't exist
82012
+ var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
82013
+ if (awaitedSymbol) {
82014
+ // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
82015
+ // an `Awaited<T | U>` would suffice.
82016
+ return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
82017
+ }
82018
+ return undefined;
82019
+ }
81994
82020
  function createAwaitedTypeIfNeeded(type) {
81995
82021
  // We wrap type `T` in `Awaited<T>` based on the following conditions:
81996
82022
  // - `T` is not already an `Awaited<U>`, and
@@ -81999,26 +82025,10 @@ var ts;
81999
82025
  // - `T` has no base constraint, or
82000
82026
  // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or
82001
82027
  // - The base constraint of `T` is an object type with a callable `then` method.
82002
- if (isTypeAny(type)) {
82003
- return type;
82004
- }
82005
- // If this is already an `Awaited<T>`, just return it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
82006
- if (isAwaitedTypeInstantiation(type)) {
82007
- return type;
82008
- }
82009
- // Only instantiate `Awaited<T>` if `T` contains possibly non-primitive types.
82010
- if (isGenericObjectType(type)) {
82011
- var baseConstraint = getBaseConstraintOfType(type);
82012
- // Only instantiate `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82013
- // or is promise-like.
82014
- if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82015
- // Nothing to do if `Awaited<T>` doesn't exist
82016
- var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
82017
- if (awaitedSymbol) {
82018
- // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
82019
- // an `Awaited<T | U>` would suffice.
82020
- return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
82021
- }
82028
+ if (isAwaitedTypeNeeded(type)) {
82029
+ var awaitedType = tryCreateAwaitedType(type);
82030
+ if (awaitedType) {
82031
+ return awaitedType;
82022
82032
  }
82023
82033
  }
82024
82034
  ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like.");
@@ -82070,6 +82080,10 @@ var ts;
82070
82080
  awaitedTypeStack.pop();
82071
82081
  return typeAsAwaitable.awaitedTypeOfType = mapped;
82072
82082
  }
82083
+ // If `type` is generic and should be wrapped in `Awaited<T>`, return it.
82084
+ if (isAwaitedTypeNeeded(type)) {
82085
+ return typeAsAwaitable.awaitedTypeOfType = type;
82086
+ }
82073
82087
  var thisTypeForErrorOut = { value: undefined };
82074
82088
  var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
82075
82089
  if (promisedType) {
@@ -303,7 +303,7 @@ var ts;
303
303
  // The following is baselined as a literal template type without intervention
304
304
  /** The version of the TypeScript compiler release */
305
305
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
306
- ts.version = ts.versionMajorMinor + ".0-dev.20220701";
306
+ ts.version = ts.versionMajorMinor + ".0-dev.20220705";
307
307
  /* @internal */
308
308
  var Comparison;
309
309
  (function (Comparison) {
@@ -82185,6 +82185,32 @@ var ts;
82185
82185
  isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] :
82186
82186
  type;
82187
82187
  }
82188
+ function isAwaitedTypeNeeded(type) {
82189
+ // If this is already an `Awaited<T>`, we shouldn't wrap it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
82190
+ if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) {
82191
+ return false;
82192
+ }
82193
+ // We only need `Awaited<T>` if `T` contains possibly non-primitive types.
82194
+ if (isGenericObjectType(type)) {
82195
+ var baseConstraint = getBaseConstraintOfType(type);
82196
+ // We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82197
+ // or is promise-like.
82198
+ if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82199
+ return true;
82200
+ }
82201
+ }
82202
+ return false;
82203
+ }
82204
+ function tryCreateAwaitedType(type) {
82205
+ // Nothing to do if `Awaited<T>` doesn't exist
82206
+ var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
82207
+ if (awaitedSymbol) {
82208
+ // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
82209
+ // an `Awaited<T | U>` would suffice.
82210
+ return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
82211
+ }
82212
+ return undefined;
82213
+ }
82188
82214
  function createAwaitedTypeIfNeeded(type) {
82189
82215
  // We wrap type `T` in `Awaited<T>` based on the following conditions:
82190
82216
  // - `T` is not already an `Awaited<U>`, and
@@ -82193,26 +82219,10 @@ var ts;
82193
82219
  // - `T` has no base constraint, or
82194
82220
  // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or
82195
82221
  // - The base constraint of `T` is an object type with a callable `then` method.
82196
- if (isTypeAny(type)) {
82197
- return type;
82198
- }
82199
- // If this is already an `Awaited<T>`, just return it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
82200
- if (isAwaitedTypeInstantiation(type)) {
82201
- return type;
82202
- }
82203
- // Only instantiate `Awaited<T>` if `T` contains possibly non-primitive types.
82204
- if (isGenericObjectType(type)) {
82205
- var baseConstraint = getBaseConstraintOfType(type);
82206
- // Only instantiate `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82207
- // or is promise-like.
82208
- if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82209
- // Nothing to do if `Awaited<T>` doesn't exist
82210
- var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
82211
- if (awaitedSymbol) {
82212
- // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
82213
- // an `Awaited<T | U>` would suffice.
82214
- return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
82215
- }
82222
+ if (isAwaitedTypeNeeded(type)) {
82223
+ var awaitedType = tryCreateAwaitedType(type);
82224
+ if (awaitedType) {
82225
+ return awaitedType;
82216
82226
  }
82217
82227
  }
82218
82228
  ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like.");
@@ -82264,6 +82274,10 @@ var ts;
82264
82274
  awaitedTypeStack.pop();
82265
82275
  return typeAsAwaitable.awaitedTypeOfType = mapped;
82266
82276
  }
82277
+ // If `type` is generic and should be wrapped in `Awaited<T>`, return it.
82278
+ if (isAwaitedTypeNeeded(type)) {
82279
+ return typeAsAwaitable.awaitedTypeOfType = type;
82280
+ }
82267
82281
  var thisTypeForErrorOut = { value: undefined };
82268
82282
  var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
82269
82283
  if (promisedType) {
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220701";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220705";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -82176,6 +82176,32 @@ var ts;
82176
82176
  isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] :
82177
82177
  type;
82178
82178
  }
82179
+ function isAwaitedTypeNeeded(type) {
82180
+ // If this is already an `Awaited<T>`, we shouldn't wrap it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
82181
+ if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) {
82182
+ return false;
82183
+ }
82184
+ // We only need `Awaited<T>` if `T` contains possibly non-primitive types.
82185
+ if (isGenericObjectType(type)) {
82186
+ var baseConstraint = getBaseConstraintOfType(type);
82187
+ // We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82188
+ // or is promise-like.
82189
+ if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82190
+ return true;
82191
+ }
82192
+ }
82193
+ return false;
82194
+ }
82195
+ function tryCreateAwaitedType(type) {
82196
+ // Nothing to do if `Awaited<T>` doesn't exist
82197
+ var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
82198
+ if (awaitedSymbol) {
82199
+ // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
82200
+ // an `Awaited<T | U>` would suffice.
82201
+ return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
82202
+ }
82203
+ return undefined;
82204
+ }
82179
82205
  function createAwaitedTypeIfNeeded(type) {
82180
82206
  // We wrap type `T` in `Awaited<T>` based on the following conditions:
82181
82207
  // - `T` is not already an `Awaited<U>`, and
@@ -82184,26 +82210,10 @@ var ts;
82184
82210
  // - `T` has no base constraint, or
82185
82211
  // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or
82186
82212
  // - The base constraint of `T` is an object type with a callable `then` method.
82187
- if (isTypeAny(type)) {
82188
- return type;
82189
- }
82190
- // If this is already an `Awaited<T>`, just return it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
82191
- if (isAwaitedTypeInstantiation(type)) {
82192
- return type;
82193
- }
82194
- // Only instantiate `Awaited<T>` if `T` contains possibly non-primitive types.
82195
- if (isGenericObjectType(type)) {
82196
- var baseConstraint = getBaseConstraintOfType(type);
82197
- // Only instantiate `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82198
- // or is promise-like.
82199
- if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82200
- // Nothing to do if `Awaited<T>` doesn't exist
82201
- var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
82202
- if (awaitedSymbol) {
82203
- // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
82204
- // an `Awaited<T | U>` would suffice.
82205
- return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
82206
- }
82213
+ if (isAwaitedTypeNeeded(type)) {
82214
+ var awaitedType = tryCreateAwaitedType(type);
82215
+ if (awaitedType) {
82216
+ return awaitedType;
82207
82217
  }
82208
82218
  }
82209
82219
  ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like.");
@@ -82255,6 +82265,10 @@ var ts;
82255
82265
  awaitedTypeStack.pop();
82256
82266
  return typeAsAwaitable.awaitedTypeOfType = mapped;
82257
82267
  }
82268
+ // If `type` is generic and should be wrapped in `Awaited<T>`, return it.
82269
+ if (isAwaitedTypeNeeded(type)) {
82270
+ return typeAsAwaitable.awaitedTypeOfType = type;
82271
+ }
82258
82272
  var thisTypeForErrorOut = { value: undefined };
82259
82273
  var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
82260
82274
  if (promisedType) {
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220701";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220705";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -82176,6 +82176,32 @@ var ts;
82176
82176
  isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] :
82177
82177
  type;
82178
82178
  }
82179
+ function isAwaitedTypeNeeded(type) {
82180
+ // If this is already an `Awaited<T>`, we shouldn't wrap it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
82181
+ if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) {
82182
+ return false;
82183
+ }
82184
+ // We only need `Awaited<T>` if `T` contains possibly non-primitive types.
82185
+ if (isGenericObjectType(type)) {
82186
+ var baseConstraint = getBaseConstraintOfType(type);
82187
+ // We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82188
+ // or is promise-like.
82189
+ if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82190
+ return true;
82191
+ }
82192
+ }
82193
+ return false;
82194
+ }
82195
+ function tryCreateAwaitedType(type) {
82196
+ // Nothing to do if `Awaited<T>` doesn't exist
82197
+ var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
82198
+ if (awaitedSymbol) {
82199
+ // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
82200
+ // an `Awaited<T | U>` would suffice.
82201
+ return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
82202
+ }
82203
+ return undefined;
82204
+ }
82179
82205
  function createAwaitedTypeIfNeeded(type) {
82180
82206
  // We wrap type `T` in `Awaited<T>` based on the following conditions:
82181
82207
  // - `T` is not already an `Awaited<U>`, and
@@ -82184,26 +82210,10 @@ var ts;
82184
82210
  // - `T` has no base constraint, or
82185
82211
  // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or
82186
82212
  // - The base constraint of `T` is an object type with a callable `then` method.
82187
- if (isTypeAny(type)) {
82188
- return type;
82189
- }
82190
- // If this is already an `Awaited<T>`, just return it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
82191
- if (isAwaitedTypeInstantiation(type)) {
82192
- return type;
82193
- }
82194
- // Only instantiate `Awaited<T>` if `T` contains possibly non-primitive types.
82195
- if (isGenericObjectType(type)) {
82196
- var baseConstraint = getBaseConstraintOfType(type);
82197
- // Only instantiate `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
82198
- // or is promise-like.
82199
- if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
82200
- // Nothing to do if `Awaited<T>` doesn't exist
82201
- var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
82202
- if (awaitedSymbol) {
82203
- // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
82204
- // an `Awaited<T | U>` would suffice.
82205
- return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
82206
- }
82213
+ if (isAwaitedTypeNeeded(type)) {
82214
+ var awaitedType = tryCreateAwaitedType(type);
82215
+ if (awaitedType) {
82216
+ return awaitedType;
82207
82217
  }
82208
82218
  }
82209
82219
  ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like.");
@@ -82255,6 +82265,10 @@ var ts;
82255
82265
  awaitedTypeStack.pop();
82256
82266
  return typeAsAwaitable.awaitedTypeOfType = mapped;
82257
82267
  }
82268
+ // If `type` is generic and should be wrapped in `Awaited<T>`, return it.
82269
+ if (isAwaitedTypeNeeded(type)) {
82270
+ return typeAsAwaitable.awaitedTypeOfType = type;
82271
+ }
82258
82272
  var thisTypeForErrorOut = { value: undefined };
82259
82273
  var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
82260
82274
  if (promisedType) {
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220701";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220705";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -81971,6 +81971,32 @@ var ts;
81971
81971
  isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] :
81972
81972
  type;
81973
81973
  }
81974
+ function isAwaitedTypeNeeded(type) {
81975
+ // If this is already an `Awaited<T>`, we shouldn't wrap it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
81976
+ if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) {
81977
+ return false;
81978
+ }
81979
+ // We only need `Awaited<T>` if `T` contains possibly non-primitive types.
81980
+ if (isGenericObjectType(type)) {
81981
+ var baseConstraint = getBaseConstraintOfType(type);
81982
+ // We only need `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
81983
+ // or is promise-like.
81984
+ if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
81985
+ return true;
81986
+ }
81987
+ }
81988
+ return false;
81989
+ }
81990
+ function tryCreateAwaitedType(type) {
81991
+ // Nothing to do if `Awaited<T>` doesn't exist
81992
+ var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
81993
+ if (awaitedSymbol) {
81994
+ // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
81995
+ // an `Awaited<T | U>` would suffice.
81996
+ return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
81997
+ }
81998
+ return undefined;
81999
+ }
81974
82000
  function createAwaitedTypeIfNeeded(type) {
81975
82001
  // We wrap type `T` in `Awaited<T>` based on the following conditions:
81976
82002
  // - `T` is not already an `Awaited<U>`, and
@@ -81979,26 +82005,10 @@ var ts;
81979
82005
  // - `T` has no base constraint, or
81980
82006
  // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or
81981
82007
  // - The base constraint of `T` is an object type with a callable `then` method.
81982
- if (isTypeAny(type)) {
81983
- return type;
81984
- }
81985
- // If this is already an `Awaited<T>`, just return it. This helps to avoid `Awaited<Awaited<T>>` in higher-order.
81986
- if (isAwaitedTypeInstantiation(type)) {
81987
- return type;
81988
- }
81989
- // Only instantiate `Awaited<T>` if `T` contains possibly non-primitive types.
81990
- if (isGenericObjectType(type)) {
81991
- var baseConstraint = getBaseConstraintOfType(type);
81992
- // Only instantiate `Awaited<T>` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
81993
- // or is promise-like.
81994
- if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) {
81995
- // Nothing to do if `Awaited<T>` doesn't exist
81996
- var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true);
81997
- if (awaitedSymbol) {
81998
- // Unwrap unions that may contain `Awaited<T>`, otherwise its possible to manufacture an `Awaited<Awaited<T> | U>` where
81999
- // an `Awaited<T | U>` would suffice.
82000
- return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]);
82001
- }
82008
+ if (isAwaitedTypeNeeded(type)) {
82009
+ var awaitedType = tryCreateAwaitedType(type);
82010
+ if (awaitedType) {
82011
+ return awaitedType;
82002
82012
  }
82003
82013
  }
82004
82014
  ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like.");
@@ -82050,6 +82060,10 @@ var ts;
82050
82060
  awaitedTypeStack.pop();
82051
82061
  return typeAsAwaitable.awaitedTypeOfType = mapped;
82052
82062
  }
82063
+ // If `type` is generic and should be wrapped in `Awaited<T>`, return it.
82064
+ if (isAwaitedTypeNeeded(type)) {
82065
+ return typeAsAwaitable.awaitedTypeOfType = type;
82066
+ }
82053
82067
  var thisTypeForErrorOut = { value: undefined };
82054
82068
  var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
82055
82069
  if (promisedType) {
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": "4.8.0-dev.20220701",
5
+ "version": "4.8.0-dev.20220705",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [