typescript 4.8.0-dev.20220714 → 4.8.0-dev.20220715

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.
@@ -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.20220714";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220715";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -47066,37 +47066,6 @@ var ts;
47066
47066
  typeLiteralSymbol.members.set(symbol.escapedName, symbol);
47067
47067
  }
47068
47068
  function bindObjectLiteralExpression(node) {
47069
- var ElementKind;
47070
- (function (ElementKind) {
47071
- ElementKind[ElementKind["Property"] = 1] = "Property";
47072
- ElementKind[ElementKind["Accessor"] = 2] = "Accessor";
47073
- })(ElementKind || (ElementKind = {}));
47074
- if (inStrictMode && !ts.isAssignmentTarget(node)) {
47075
- var seen = new ts.Map();
47076
- for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
47077
- var prop = _a[_i];
47078
- if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) {
47079
- continue;
47080
- }
47081
- var identifier = prop.name;
47082
- // ECMA-262 11.1.5 Object Initializer
47083
- // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
47084
- // a.This production is contained in strict code and IsDataDescriptor(previous) is true and
47085
- // IsDataDescriptor(propId.descriptor) is true.
47086
- // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true.
47087
- // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true.
47088
- // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true
47089
- // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields
47090
- var currentKind = prop.kind === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */
47091
- ? 1 /* Property */
47092
- : 2 /* Accessor */;
47093
- var existingKind = seen.get(identifier.escapedText);
47094
- if (!existingKind) {
47095
- seen.set(identifier.escapedText, currentKind);
47096
- continue;
47097
- }
47098
- }
47099
- }
47100
47069
  return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */);
47101
47070
  }
47102
47071
  function bindJsxAttributes(node) {
@@ -49335,11 +49304,10 @@ var ts;
49335
49304
  var unresolvedSymbols = new ts.Map();
49336
49305
  var errorTypes = new ts.Map();
49337
49306
  var anyType = createIntrinsicType(1 /* Any */, "any");
49338
- var autoType = createIntrinsicType(1 /* Any */, "any");
49307
+ var autoType = createIntrinsicType(1 /* Any */, "any", 262144 /* NonInferrableType */);
49339
49308
  var wildcardType = createIntrinsicType(1 /* Any */, "any");
49340
49309
  var errorType = createIntrinsicType(1 /* Any */, "error");
49341
49310
  var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved");
49342
- var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */);
49343
49311
  var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
49344
49312
  var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
49345
49313
  var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown");
@@ -49368,8 +49336,7 @@ var ts;
49368
49336
  var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol");
49369
49337
  var voidType = createIntrinsicType(16384 /* Void */, "void");
49370
49338
  var neverType = createIntrinsicType(131072 /* Never */, "never");
49371
- var silentNeverType = createIntrinsicType(131072 /* Never */, "never");
49372
- var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */);
49339
+ var silentNeverType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */);
49373
49340
  var implicitNeverType = createIntrinsicType(131072 /* Never */, "never");
49374
49341
  var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never");
49375
49342
  var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object");
@@ -57107,11 +57074,7 @@ var ts;
57107
57074
  if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) {
57108
57075
  reportImplicitAny(element, anyType);
57109
57076
  }
57110
- // When we're including the pattern in the type (an indication we're obtaining a contextual type), we
57111
- // use the non-inferrable any type. Inference will never directly infer this type, but it is possible
57112
- // to infer a type that contains it, e.g. for a binding pattern like [foo] or { foo }. In such cases,
57113
- // widening of the binding pattern type substitutes a regular any for the non-inferrable any.
57114
- return includePatternInType ? nonInferrableAnyType : anyType;
57077
+ return anyType;
57115
57078
  }
57116
57079
  // Return the type implied by an object binding pattern
57117
57080
  function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
@@ -60897,13 +60860,13 @@ var ts;
60897
60860
  }
60898
60861
  // This function is used to propagate certain flags when creating new object type references and union types.
60899
60862
  // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type
60900
- // of an object literal or the anyFunctionType. This is because there are operations in the type checker
60863
+ // of an object literal or a non-inferrable type. This is because there are operations in the type checker
60901
60864
  // that care about the presence of such types at arbitrary depth in a containing type.
60902
60865
  function getPropagatingFlagsOfTypes(types, excludeKinds) {
60903
60866
  var result = 0;
60904
60867
  for (var _i = 0, types_8 = types; _i < types_8.length; _i++) {
60905
60868
  var type = types_8[_i];
60906
- if (!(type.flags & excludeKinds)) {
60869
+ if (excludeKinds === undefined || !(type.flags & excludeKinds)) {
60907
60870
  result |= ts.getObjectFlags(type);
60908
60871
  }
60909
60872
  }
@@ -60915,7 +60878,7 @@ var ts;
60915
60878
  if (!type) {
60916
60879
  type = createObjectType(4 /* Reference */, target.symbol);
60917
60880
  target.instantiations.set(id, type);
60918
- type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0;
60881
+ type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0;
60919
60882
  type.target = target;
60920
60883
  type.resolvedTypeArguments = typeArguments;
60921
60884
  }
@@ -64349,6 +64312,7 @@ var ts;
64349
64312
  result.mapper = mapper;
64350
64313
  result.aliasSymbol = aliasSymbol || type.aliasSymbol;
64351
64314
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
64315
+ result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
64352
64316
  return result;
64353
64317
  }
64354
64318
  function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
@@ -69301,10 +69265,13 @@ var ts;
69301
69265
  propagationType = savePropagationType;
69302
69266
  return;
69303
69267
  }
69304
- if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
69305
- // Source and target are types originating in the same generic type alias declaration.
69306
- // Simply infer from source type arguments to target type arguments.
69307
- inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
69268
+ if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) {
69269
+ if (source.aliasTypeArguments) {
69270
+ // Source and target are types originating in the same generic type alias declaration.
69271
+ // Simply infer from source type arguments to target type arguments.
69272
+ inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
69273
+ }
69274
+ // And if there weren't any type arguments, there's no reason to run inference as the types must be the same.
69308
69275
  return;
69309
69276
  }
69310
69277
  if (source === target && source.flags & 3145728 /* UnionOrIntersection */) {
@@ -69360,18 +69327,26 @@ var ts;
69360
69327
  target = getActualTypeVariable(target);
69361
69328
  }
69362
69329
  if (target.flags & 8650752 /* TypeVariable */) {
69363
- // If target is a type parameter, make an inference, unless the source type contains
69364
- // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions).
69365
- // Because the anyFunctionType is internal, it should not be exposed to the user by adding
69366
- // it as an inference candidate. Hopefully, a better candidate will come along that does
69367
- // not contain anyFunctionType when we come back to this argument for its second round
69368
- // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
69369
- // when constructing types from type parameters that had no inference candidates).
69370
- if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
69330
+ // Skip inference if the source is "blocked", which is used by the language service to
69331
+ // prevent inference on nodes currently being edited.
69332
+ if (isFromInferenceBlockedSource(source)) {
69371
69333
  return;
69372
69334
  }
69373
69335
  var inference = getInferenceInfoForType(target);
69374
69336
  if (inference) {
69337
+ // If target is a type parameter, make an inference, unless the source type contains
69338
+ // a "non-inferrable" type. Types with this flag set are markers used to prevent inference.
69339
+ //
69340
+ // For example:
69341
+ // - anyFunctionType is a wildcard type that's used to avoid contextually typing functions;
69342
+ // it's internal, so should not be exposed to the user by adding it as a candidate.
69343
+ // - autoType (and autoArrayType) is a special "any" used in control flow; like anyFunctionType,
69344
+ // it's internal and should not be observable.
69345
+ // - silentNeverType is returned by getInferredType when instantiating a generic function for
69346
+ // inference (and a type variable has no mapping).
69347
+ //
69348
+ // This flag is infectious; if we produce Box<never> (where never is silentNeverType), Box<never> is
69349
+ // also non-inferrable.
69375
69350
  if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) {
69376
69351
  return;
69377
69352
  }
@@ -69914,20 +69889,17 @@ var ts;
69914
69889
  var sourceLen = sourceSignatures.length;
69915
69890
  var targetLen = targetSignatures.length;
69916
69891
  var len = sourceLen < targetLen ? sourceLen : targetLen;
69917
- var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */);
69918
69892
  for (var i = 0; i < len; i++) {
69919
- inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters);
69893
+ inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]));
69920
69894
  }
69921
69895
  }
69922
- function inferFromSignature(source, target, skipParameters) {
69923
- if (!skipParameters) {
69924
- var saveBivariant = bivariant;
69925
- var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
69926
- // Once we descend into a bivariant signature we remain bivariant for all nested inferences
69927
- bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */;
69928
- applyToParameterTypes(source, target, inferFromContravariantTypes);
69929
- bivariant = saveBivariant;
69930
- }
69896
+ function inferFromSignature(source, target) {
69897
+ var saveBivariant = bivariant;
69898
+ var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
69899
+ // Once we descend into a bivariant signature we remain bivariant for all nested inferences
69900
+ bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */;
69901
+ applyToParameterTypes(source, target, inferFromContravariantTypes);
69902
+ bivariant = saveBivariant;
69931
69903
  applyToReturnTypes(source, target, inferFromTypes);
69932
69904
  }
69933
69905
  function inferFromIndexTypes(source, target) {
@@ -77433,7 +77405,7 @@ var ts;
77433
77405
  // returns a function type, we choose to defer processing. This narrowly permits function composition
77434
77406
  // operators to flow inferences through return types, but otherwise processes calls right away. We
77435
77407
  // use the resolvingSignature singleton to indicate that we deferred processing. This result will be
77436
- // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and
77408
+ // propagated out and eventually turned into silentNeverType (a type that is assignable to anything and
77437
77409
  // from which we never make inferences).
77438
77410
  if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
77439
77411
  skippedGenericFunction(node, checkMode);
@@ -77986,8 +77958,8 @@ var ts;
77986
77958
  var signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode);
77987
77959
  if (signature === resolvingSignature) {
77988
77960
  // CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that
77989
- // returns a function type. We defer checking and return nonInferrableType.
77990
- return nonInferrableType;
77961
+ // returns a function type. We defer checking and return silentNeverType.
77962
+ return silentNeverType;
77991
77963
  }
77992
77964
  checkDeprecatedSignature(signature, node);
77993
77965
  if (node.expression.kind === 106 /* SuperKeyword */) {
@@ -84613,9 +84585,14 @@ var ts;
84613
84585
  function unwrapReturnType(returnType, functionFlags) {
84614
84586
  var isGenerator = !!(functionFlags & 1 /* Generator */);
84615
84587
  var isAsync = !!(functionFlags & 2 /* Async */);
84616
- return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType :
84617
- isAsync ? getAwaitedTypeNoAlias(returnType) || errorType :
84618
- returnType;
84588
+ if (isGenerator) {
84589
+ var returnIterationType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync);
84590
+ if (!returnIterationType) {
84591
+ return errorType;
84592
+ }
84593
+ return isAsync ? getAwaitedTypeNoAlias(unwrapAwaitedType(returnIterationType)) : returnIterationType;
84594
+ }
84595
+ return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType;
84619
84596
  }
84620
84597
  function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
84621
84598
  var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
@@ -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.20220714";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220715";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -46861,37 +46861,6 @@ var ts;
46861
46861
  typeLiteralSymbol.members.set(symbol.escapedName, symbol);
46862
46862
  }
46863
46863
  function bindObjectLiteralExpression(node) {
46864
- var ElementKind;
46865
- (function (ElementKind) {
46866
- ElementKind[ElementKind["Property"] = 1] = "Property";
46867
- ElementKind[ElementKind["Accessor"] = 2] = "Accessor";
46868
- })(ElementKind || (ElementKind = {}));
46869
- if (inStrictMode && !ts.isAssignmentTarget(node)) {
46870
- var seen = new ts.Map();
46871
- for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
46872
- var prop = _a[_i];
46873
- if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) {
46874
- continue;
46875
- }
46876
- var identifier = prop.name;
46877
- // ECMA-262 11.1.5 Object Initializer
46878
- // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
46879
- // a.This production is contained in strict code and IsDataDescriptor(previous) is true and
46880
- // IsDataDescriptor(propId.descriptor) is true.
46881
- // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true.
46882
- // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true.
46883
- // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true
46884
- // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields
46885
- var currentKind = prop.kind === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */
46886
- ? 1 /* Property */
46887
- : 2 /* Accessor */;
46888
- var existingKind = seen.get(identifier.escapedText);
46889
- if (!existingKind) {
46890
- seen.set(identifier.escapedText, currentKind);
46891
- continue;
46892
- }
46893
- }
46894
- }
46895
46864
  return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */);
46896
46865
  }
46897
46866
  function bindJsxAttributes(node) {
@@ -49130,11 +49099,10 @@ var ts;
49130
49099
  var unresolvedSymbols = new ts.Map();
49131
49100
  var errorTypes = new ts.Map();
49132
49101
  var anyType = createIntrinsicType(1 /* Any */, "any");
49133
- var autoType = createIntrinsicType(1 /* Any */, "any");
49102
+ var autoType = createIntrinsicType(1 /* Any */, "any", 262144 /* NonInferrableType */);
49134
49103
  var wildcardType = createIntrinsicType(1 /* Any */, "any");
49135
49104
  var errorType = createIntrinsicType(1 /* Any */, "error");
49136
49105
  var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved");
49137
- var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */);
49138
49106
  var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
49139
49107
  var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
49140
49108
  var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown");
@@ -49163,8 +49131,7 @@ var ts;
49163
49131
  var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol");
49164
49132
  var voidType = createIntrinsicType(16384 /* Void */, "void");
49165
49133
  var neverType = createIntrinsicType(131072 /* Never */, "never");
49166
- var silentNeverType = createIntrinsicType(131072 /* Never */, "never");
49167
- var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */);
49134
+ var silentNeverType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */);
49168
49135
  var implicitNeverType = createIntrinsicType(131072 /* Never */, "never");
49169
49136
  var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never");
49170
49137
  var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object");
@@ -56902,11 +56869,7 @@ var ts;
56902
56869
  if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) {
56903
56870
  reportImplicitAny(element, anyType);
56904
56871
  }
56905
- // When we're including the pattern in the type (an indication we're obtaining a contextual type), we
56906
- // use the non-inferrable any type. Inference will never directly infer this type, but it is possible
56907
- // to infer a type that contains it, e.g. for a binding pattern like [foo] or { foo }. In such cases,
56908
- // widening of the binding pattern type substitutes a regular any for the non-inferrable any.
56909
- return includePatternInType ? nonInferrableAnyType : anyType;
56872
+ return anyType;
56910
56873
  }
56911
56874
  // Return the type implied by an object binding pattern
56912
56875
  function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
@@ -60692,13 +60655,13 @@ var ts;
60692
60655
  }
60693
60656
  // This function is used to propagate certain flags when creating new object type references and union types.
60694
60657
  // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type
60695
- // of an object literal or the anyFunctionType. This is because there are operations in the type checker
60658
+ // of an object literal or a non-inferrable type. This is because there are operations in the type checker
60696
60659
  // that care about the presence of such types at arbitrary depth in a containing type.
60697
60660
  function getPropagatingFlagsOfTypes(types, excludeKinds) {
60698
60661
  var result = 0;
60699
60662
  for (var _i = 0, types_8 = types; _i < types_8.length; _i++) {
60700
60663
  var type = types_8[_i];
60701
- if (!(type.flags & excludeKinds)) {
60664
+ if (excludeKinds === undefined || !(type.flags & excludeKinds)) {
60702
60665
  result |= ts.getObjectFlags(type);
60703
60666
  }
60704
60667
  }
@@ -60710,7 +60673,7 @@ var ts;
60710
60673
  if (!type) {
60711
60674
  type = createObjectType(4 /* Reference */, target.symbol);
60712
60675
  target.instantiations.set(id, type);
60713
- type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0;
60676
+ type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0;
60714
60677
  type.target = target;
60715
60678
  type.resolvedTypeArguments = typeArguments;
60716
60679
  }
@@ -64144,6 +64107,7 @@ var ts;
64144
64107
  result.mapper = mapper;
64145
64108
  result.aliasSymbol = aliasSymbol || type.aliasSymbol;
64146
64109
  result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
64110
+ result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
64147
64111
  return result;
64148
64112
  }
64149
64113
  function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
@@ -69096,10 +69060,13 @@ var ts;
69096
69060
  propagationType = savePropagationType;
69097
69061
  return;
69098
69062
  }
69099
- if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
69100
- // Source and target are types originating in the same generic type alias declaration.
69101
- // Simply infer from source type arguments to target type arguments.
69102
- inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
69063
+ if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) {
69064
+ if (source.aliasTypeArguments) {
69065
+ // Source and target are types originating in the same generic type alias declaration.
69066
+ // Simply infer from source type arguments to target type arguments.
69067
+ inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
69068
+ }
69069
+ // And if there weren't any type arguments, there's no reason to run inference as the types must be the same.
69103
69070
  return;
69104
69071
  }
69105
69072
  if (source === target && source.flags & 3145728 /* UnionOrIntersection */) {
@@ -69155,18 +69122,26 @@ var ts;
69155
69122
  target = getActualTypeVariable(target);
69156
69123
  }
69157
69124
  if (target.flags & 8650752 /* TypeVariable */) {
69158
- // If target is a type parameter, make an inference, unless the source type contains
69159
- // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions).
69160
- // Because the anyFunctionType is internal, it should not be exposed to the user by adding
69161
- // it as an inference candidate. Hopefully, a better candidate will come along that does
69162
- // not contain anyFunctionType when we come back to this argument for its second round
69163
- // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
69164
- // when constructing types from type parameters that had no inference candidates).
69165
- if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
69125
+ // Skip inference if the source is "blocked", which is used by the language service to
69126
+ // prevent inference on nodes currently being edited.
69127
+ if (isFromInferenceBlockedSource(source)) {
69166
69128
  return;
69167
69129
  }
69168
69130
  var inference = getInferenceInfoForType(target);
69169
69131
  if (inference) {
69132
+ // If target is a type parameter, make an inference, unless the source type contains
69133
+ // a "non-inferrable" type. Types with this flag set are markers used to prevent inference.
69134
+ //
69135
+ // For example:
69136
+ // - anyFunctionType is a wildcard type that's used to avoid contextually typing functions;
69137
+ // it's internal, so should not be exposed to the user by adding it as a candidate.
69138
+ // - autoType (and autoArrayType) is a special "any" used in control flow; like anyFunctionType,
69139
+ // it's internal and should not be observable.
69140
+ // - silentNeverType is returned by getInferredType when instantiating a generic function for
69141
+ // inference (and a type variable has no mapping).
69142
+ //
69143
+ // This flag is infectious; if we produce Box<never> (where never is silentNeverType), Box<never> is
69144
+ // also non-inferrable.
69170
69145
  if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) {
69171
69146
  return;
69172
69147
  }
@@ -69709,20 +69684,17 @@ var ts;
69709
69684
  var sourceLen = sourceSignatures.length;
69710
69685
  var targetLen = targetSignatures.length;
69711
69686
  var len = sourceLen < targetLen ? sourceLen : targetLen;
69712
- var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */);
69713
69687
  for (var i = 0; i < len; i++) {
69714
- inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters);
69688
+ inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]));
69715
69689
  }
69716
69690
  }
69717
- function inferFromSignature(source, target, skipParameters) {
69718
- if (!skipParameters) {
69719
- var saveBivariant = bivariant;
69720
- var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
69721
- // Once we descend into a bivariant signature we remain bivariant for all nested inferences
69722
- bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */;
69723
- applyToParameterTypes(source, target, inferFromContravariantTypes);
69724
- bivariant = saveBivariant;
69725
- }
69691
+ function inferFromSignature(source, target) {
69692
+ var saveBivariant = bivariant;
69693
+ var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
69694
+ // Once we descend into a bivariant signature we remain bivariant for all nested inferences
69695
+ bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */;
69696
+ applyToParameterTypes(source, target, inferFromContravariantTypes);
69697
+ bivariant = saveBivariant;
69726
69698
  applyToReturnTypes(source, target, inferFromTypes);
69727
69699
  }
69728
69700
  function inferFromIndexTypes(source, target) {
@@ -77228,7 +77200,7 @@ var ts;
77228
77200
  // returns a function type, we choose to defer processing. This narrowly permits function composition
77229
77201
  // operators to flow inferences through return types, but otherwise processes calls right away. We
77230
77202
  // use the resolvingSignature singleton to indicate that we deferred processing. This result will be
77231
- // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and
77203
+ // propagated out and eventually turned into silentNeverType (a type that is assignable to anything and
77232
77204
  // from which we never make inferences).
77233
77205
  if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
77234
77206
  skippedGenericFunction(node, checkMode);
@@ -77781,8 +77753,8 @@ var ts;
77781
77753
  var signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode);
77782
77754
  if (signature === resolvingSignature) {
77783
77755
  // CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that
77784
- // returns a function type. We defer checking and return nonInferrableType.
77785
- return nonInferrableType;
77756
+ // returns a function type. We defer checking and return silentNeverType.
77757
+ return silentNeverType;
77786
77758
  }
77787
77759
  checkDeprecatedSignature(signature, node);
77788
77760
  if (node.expression.kind === 106 /* SuperKeyword */) {
@@ -84408,9 +84380,14 @@ var ts;
84408
84380
  function unwrapReturnType(returnType, functionFlags) {
84409
84381
  var isGenerator = !!(functionFlags & 1 /* Generator */);
84410
84382
  var isAsync = !!(functionFlags & 2 /* Async */);
84411
- return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType :
84412
- isAsync ? getAwaitedTypeNoAlias(returnType) || errorType :
84413
- returnType;
84383
+ if (isGenerator) {
84384
+ var returnIterationType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync);
84385
+ if (!returnIterationType) {
84386
+ return errorType;
84387
+ }
84388
+ return isAsync ? getAwaitedTypeNoAlias(unwrapAwaitedType(returnIterationType)) : returnIterationType;
84389
+ }
84390
+ return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType;
84414
84391
  }
84415
84392
  function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
84416
84393
  var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
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.20220714",
5
+ "version": "4.8.0-dev.20220715",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [