typescript 4.8.0-dev.20220712 → 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.
- package/lib/lib.es2015.collection.d.ts +62 -1
- package/lib/tsc.js +36 -43
- package/lib/tsserver.js +76 -76
- package/lib/tsserverlibrary.js +76 -76
- package/lib/typescript.js +76 -76
- package/lib/typescriptServices.js +76 -76
- package/lib/typingsInstaller.js +58 -73
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -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.
|
|
306
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220715";
|
|
307
307
|
/* @internal */
|
|
308
308
|
var Comparison;
|
|
309
309
|
(function (Comparison) {
|
|
@@ -47075,37 +47075,6 @@ var ts;
|
|
|
47075
47075
|
typeLiteralSymbol.members.set(symbol.escapedName, symbol);
|
|
47076
47076
|
}
|
|
47077
47077
|
function bindObjectLiteralExpression(node) {
|
|
47078
|
-
var ElementKind;
|
|
47079
|
-
(function (ElementKind) {
|
|
47080
|
-
ElementKind[ElementKind["Property"] = 1] = "Property";
|
|
47081
|
-
ElementKind[ElementKind["Accessor"] = 2] = "Accessor";
|
|
47082
|
-
})(ElementKind || (ElementKind = {}));
|
|
47083
|
-
if (inStrictMode && !ts.isAssignmentTarget(node)) {
|
|
47084
|
-
var seen = new ts.Map();
|
|
47085
|
-
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
|
47086
|
-
var prop = _a[_i];
|
|
47087
|
-
if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) {
|
|
47088
|
-
continue;
|
|
47089
|
-
}
|
|
47090
|
-
var identifier = prop.name;
|
|
47091
|
-
// ECMA-262 11.1.5 Object Initializer
|
|
47092
|
-
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
|
47093
|
-
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and
|
|
47094
|
-
// IsDataDescriptor(propId.descriptor) is true.
|
|
47095
|
-
// b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true.
|
|
47096
|
-
// c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true.
|
|
47097
|
-
// d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true
|
|
47098
|
-
// and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields
|
|
47099
|
-
var currentKind = prop.kind === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */
|
|
47100
|
-
? 1 /* Property */
|
|
47101
|
-
: 2 /* Accessor */;
|
|
47102
|
-
var existingKind = seen.get(identifier.escapedText);
|
|
47103
|
-
if (!existingKind) {
|
|
47104
|
-
seen.set(identifier.escapedText, currentKind);
|
|
47105
|
-
continue;
|
|
47106
|
-
}
|
|
47107
|
-
}
|
|
47108
|
-
}
|
|
47109
47078
|
return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */);
|
|
47110
47079
|
}
|
|
47111
47080
|
function bindJsxAttributes(node) {
|
|
@@ -49344,11 +49313,10 @@ var ts;
|
|
|
49344
49313
|
var unresolvedSymbols = new ts.Map();
|
|
49345
49314
|
var errorTypes = new ts.Map();
|
|
49346
49315
|
var anyType = createIntrinsicType(1 /* Any */, "any");
|
|
49347
|
-
var autoType = createIntrinsicType(1 /* Any */, "any");
|
|
49316
|
+
var autoType = createIntrinsicType(1 /* Any */, "any", 262144 /* NonInferrableType */);
|
|
49348
49317
|
var wildcardType = createIntrinsicType(1 /* Any */, "any");
|
|
49349
49318
|
var errorType = createIntrinsicType(1 /* Any */, "error");
|
|
49350
49319
|
var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved");
|
|
49351
|
-
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */);
|
|
49352
49320
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
49353
49321
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
49354
49322
|
var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
@@ -49377,8 +49345,7 @@ var ts;
|
|
|
49377
49345
|
var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol");
|
|
49378
49346
|
var voidType = createIntrinsicType(16384 /* Void */, "void");
|
|
49379
49347
|
var neverType = createIntrinsicType(131072 /* Never */, "never");
|
|
49380
|
-
var silentNeverType = createIntrinsicType(131072 /* Never */, "never");
|
|
49381
|
-
var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */);
|
|
49348
|
+
var silentNeverType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */);
|
|
49382
49349
|
var implicitNeverType = createIntrinsicType(131072 /* Never */, "never");
|
|
49383
49350
|
var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never");
|
|
49384
49351
|
var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object");
|
|
@@ -57116,11 +57083,7 @@ var ts;
|
|
|
57116
57083
|
if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) {
|
|
57117
57084
|
reportImplicitAny(element, anyType);
|
|
57118
57085
|
}
|
|
57119
|
-
|
|
57120
|
-
// use the non-inferrable any type. Inference will never directly infer this type, but it is possible
|
|
57121
|
-
// to infer a type that contains it, e.g. for a binding pattern like [foo] or { foo }. In such cases,
|
|
57122
|
-
// widening of the binding pattern type substitutes a regular any for the non-inferrable any.
|
|
57123
|
-
return includePatternInType ? nonInferrableAnyType : anyType;
|
|
57086
|
+
return anyType;
|
|
57124
57087
|
}
|
|
57125
57088
|
// Return the type implied by an object binding pattern
|
|
57126
57089
|
function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
|
|
@@ -60906,13 +60869,13 @@ var ts;
|
|
|
60906
60869
|
}
|
|
60907
60870
|
// This function is used to propagate certain flags when creating new object type references and union types.
|
|
60908
60871
|
// It is only necessary to do so if a constituent type might be the undefined type, the null type, the type
|
|
60909
|
-
// of an object literal or
|
|
60872
|
+
// of an object literal or a non-inferrable type. This is because there are operations in the type checker
|
|
60910
60873
|
// that care about the presence of such types at arbitrary depth in a containing type.
|
|
60911
60874
|
function getPropagatingFlagsOfTypes(types, excludeKinds) {
|
|
60912
60875
|
var result = 0;
|
|
60913
60876
|
for (var _i = 0, types_8 = types; _i < types_8.length; _i++) {
|
|
60914
60877
|
var type = types_8[_i];
|
|
60915
|
-
if (!(type.flags & excludeKinds)) {
|
|
60878
|
+
if (excludeKinds === undefined || !(type.flags & excludeKinds)) {
|
|
60916
60879
|
result |= ts.getObjectFlags(type);
|
|
60917
60880
|
}
|
|
60918
60881
|
}
|
|
@@ -60924,7 +60887,7 @@ var ts;
|
|
|
60924
60887
|
if (!type) {
|
|
60925
60888
|
type = createObjectType(4 /* Reference */, target.symbol);
|
|
60926
60889
|
target.instantiations.set(id, type);
|
|
60927
|
-
type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments
|
|
60890
|
+
type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0;
|
|
60928
60891
|
type.target = target;
|
|
60929
60892
|
type.resolvedTypeArguments = typeArguments;
|
|
60930
60893
|
}
|
|
@@ -64358,6 +64321,7 @@ var ts;
|
|
|
64358
64321
|
result.mapper = mapper;
|
|
64359
64322
|
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
64360
64323
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
|
|
64324
|
+
result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0;
|
|
64361
64325
|
return result;
|
|
64362
64326
|
}
|
|
64363
64327
|
function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
@@ -69310,10 +69274,13 @@ var ts;
|
|
|
69310
69274
|
propagationType = savePropagationType;
|
|
69311
69275
|
return;
|
|
69312
69276
|
}
|
|
69313
|
-
if (source.aliasSymbol && source.
|
|
69314
|
-
|
|
69315
|
-
|
|
69316
|
-
|
|
69277
|
+
if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) {
|
|
69278
|
+
if (source.aliasTypeArguments) {
|
|
69279
|
+
// Source and target are types originating in the same generic type alias declaration.
|
|
69280
|
+
// Simply infer from source type arguments to target type arguments.
|
|
69281
|
+
inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
|
|
69282
|
+
}
|
|
69283
|
+
// And if there weren't any type arguments, there's no reason to run inference as the types must be the same.
|
|
69317
69284
|
return;
|
|
69318
69285
|
}
|
|
69319
69286
|
if (source === target && source.flags & 3145728 /* UnionOrIntersection */) {
|
|
@@ -69369,18 +69336,26 @@ var ts;
|
|
|
69369
69336
|
target = getActualTypeVariable(target);
|
|
69370
69337
|
}
|
|
69371
69338
|
if (target.flags & 8650752 /* TypeVariable */) {
|
|
69372
|
-
//
|
|
69373
|
-
//
|
|
69374
|
-
|
|
69375
|
-
// it as an inference candidate. Hopefully, a better candidate will come along that does
|
|
69376
|
-
// not contain anyFunctionType when we come back to this argument for its second round
|
|
69377
|
-
// of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
|
|
69378
|
-
// when constructing types from type parameters that had no inference candidates).
|
|
69379
|
-
if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
|
|
69339
|
+
// Skip inference if the source is "blocked", which is used by the language service to
|
|
69340
|
+
// prevent inference on nodes currently being edited.
|
|
69341
|
+
if (isFromInferenceBlockedSource(source)) {
|
|
69380
69342
|
return;
|
|
69381
69343
|
}
|
|
69382
69344
|
var inference = getInferenceInfoForType(target);
|
|
69383
69345
|
if (inference) {
|
|
69346
|
+
// If target is a type parameter, make an inference, unless the source type contains
|
|
69347
|
+
// a "non-inferrable" type. Types with this flag set are markers used to prevent inference.
|
|
69348
|
+
//
|
|
69349
|
+
// For example:
|
|
69350
|
+
// - anyFunctionType is a wildcard type that's used to avoid contextually typing functions;
|
|
69351
|
+
// it's internal, so should not be exposed to the user by adding it as a candidate.
|
|
69352
|
+
// - autoType (and autoArrayType) is a special "any" used in control flow; like anyFunctionType,
|
|
69353
|
+
// it's internal and should not be observable.
|
|
69354
|
+
// - silentNeverType is returned by getInferredType when instantiating a generic function for
|
|
69355
|
+
// inference (and a type variable has no mapping).
|
|
69356
|
+
//
|
|
69357
|
+
// This flag is infectious; if we produce Box<never> (where never is silentNeverType), Box<never> is
|
|
69358
|
+
// also non-inferrable.
|
|
69384
69359
|
if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) {
|
|
69385
69360
|
return;
|
|
69386
69361
|
}
|
|
@@ -69923,20 +69898,17 @@ var ts;
|
|
|
69923
69898
|
var sourceLen = sourceSignatures.length;
|
|
69924
69899
|
var targetLen = targetSignatures.length;
|
|
69925
69900
|
var len = sourceLen < targetLen ? sourceLen : targetLen;
|
|
69926
|
-
var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */);
|
|
69927
69901
|
for (var i = 0; i < len; i++) {
|
|
69928
|
-
inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])
|
|
69902
|
+
inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]));
|
|
69929
69903
|
}
|
|
69930
69904
|
}
|
|
69931
|
-
function inferFromSignature(source, target
|
|
69932
|
-
|
|
69933
|
-
|
|
69934
|
-
|
|
69935
|
-
|
|
69936
|
-
|
|
69937
|
-
|
|
69938
|
-
bivariant = saveBivariant;
|
|
69939
|
-
}
|
|
69905
|
+
function inferFromSignature(source, target) {
|
|
69906
|
+
var saveBivariant = bivariant;
|
|
69907
|
+
var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
|
|
69908
|
+
// Once we descend into a bivariant signature we remain bivariant for all nested inferences
|
|
69909
|
+
bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */;
|
|
69910
|
+
applyToParameterTypes(source, target, inferFromContravariantTypes);
|
|
69911
|
+
bivariant = saveBivariant;
|
|
69940
69912
|
applyToReturnTypes(source, target, inferFromTypes);
|
|
69941
69913
|
}
|
|
69942
69914
|
function inferFromIndexTypes(source, target) {
|
|
@@ -73520,6 +73492,14 @@ var ts;
|
|
|
73520
73492
|
var lhsType = getTypeOfExpression(e.expression);
|
|
73521
73493
|
return ts.isPrivateIdentifier(e.name) ? tryGetPrivateIdentifierPropertyOfType(lhsType, e.name) : getPropertyOfType(lhsType, e.name.escapedText);
|
|
73522
73494
|
}
|
|
73495
|
+
if (ts.isElementAccessExpression(e)) {
|
|
73496
|
+
var propType = checkExpressionCached(e.argumentExpression);
|
|
73497
|
+
if (!isTypeUsableAsPropertyName(propType)) {
|
|
73498
|
+
return undefined;
|
|
73499
|
+
}
|
|
73500
|
+
var lhsType = getTypeOfExpression(e.expression);
|
|
73501
|
+
return getPropertyOfType(lhsType, getPropertyNameFromType(propType));
|
|
73502
|
+
}
|
|
73523
73503
|
return undefined;
|
|
73524
73504
|
function tryGetPrivateIdentifierPropertyOfType(type, id) {
|
|
73525
73505
|
var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(id.escapedText, id);
|
|
@@ -77434,7 +77414,7 @@ var ts;
|
|
|
77434
77414
|
// returns a function type, we choose to defer processing. This narrowly permits function composition
|
|
77435
77415
|
// operators to flow inferences through return types, but otherwise processes calls right away. We
|
|
77436
77416
|
// use the resolvingSignature singleton to indicate that we deferred processing. This result will be
|
|
77437
|
-
// propagated out and eventually turned into
|
|
77417
|
+
// propagated out and eventually turned into silentNeverType (a type that is assignable to anything and
|
|
77438
77418
|
// from which we never make inferences).
|
|
77439
77419
|
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
|
|
77440
77420
|
skippedGenericFunction(node, checkMode);
|
|
@@ -77987,8 +77967,8 @@ var ts;
|
|
|
77987
77967
|
var signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode);
|
|
77988
77968
|
if (signature === resolvingSignature) {
|
|
77989
77969
|
// CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that
|
|
77990
|
-
// returns a function type. We defer checking and return
|
|
77991
|
-
return
|
|
77970
|
+
// returns a function type. We defer checking and return silentNeverType.
|
|
77971
|
+
return silentNeverType;
|
|
77992
77972
|
}
|
|
77993
77973
|
checkDeprecatedSignature(signature, node);
|
|
77994
77974
|
if (node.expression.kind === 106 /* SuperKeyword */) {
|
|
@@ -84614,9 +84594,14 @@ var ts;
|
|
|
84614
84594
|
function unwrapReturnType(returnType, functionFlags) {
|
|
84615
84595
|
var isGenerator = !!(functionFlags & 1 /* Generator */);
|
|
84616
84596
|
var isAsync = !!(functionFlags & 2 /* Async */);
|
|
84617
|
-
|
|
84618
|
-
|
|
84619
|
-
|
|
84597
|
+
if (isGenerator) {
|
|
84598
|
+
var returnIterationType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync);
|
|
84599
|
+
if (!returnIterationType) {
|
|
84600
|
+
return errorType;
|
|
84601
|
+
}
|
|
84602
|
+
return isAsync ? getAwaitedTypeNoAlias(unwrapAwaitedType(returnIterationType)) : returnIterationType;
|
|
84603
|
+
}
|
|
84604
|
+
return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType;
|
|
84620
84605
|
}
|
|
84621
84606
|
function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
|
|
84622
84607
|
var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
|
|
@@ -145324,7 +145309,7 @@ var ts;
|
|
|
145324
145309
|
var SmartSelectionRange;
|
|
145325
145310
|
(function (SmartSelectionRange) {
|
|
145326
145311
|
function getSmartSelectionRange(pos, sourceFile) {
|
|
145327
|
-
var _a;
|
|
145312
|
+
var _a, _b;
|
|
145328
145313
|
var selectionRange = {
|
|
145329
145314
|
textSpan: ts.createTextSpanFromBounds(sourceFile.getFullStart(), sourceFile.getEnd())
|
|
145330
145315
|
};
|
|
@@ -145376,6 +145361,17 @@ var ts;
|
|
|
145376
145361
|
if (ts.hasJSDocNodes(node) && ((_a = node.jsDoc) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
145377
145362
|
pushSelectionRange(ts.first(node.jsDoc).getStart(), end);
|
|
145378
145363
|
}
|
|
145364
|
+
// (#39618 & #49807)
|
|
145365
|
+
// When the node is a SyntaxList and its first child has a JSDoc comment, then the node's
|
|
145366
|
+
// `start` (which usually is the result of calling `node.getStart()`) points to the first
|
|
145367
|
+
// token after the JSDoc comment. So, we have to make sure we'd pushed the selection
|
|
145368
|
+
// covering the JSDoc comment before diving further.
|
|
145369
|
+
if (ts.isSyntaxList(node)) {
|
|
145370
|
+
var firstChild = node.getChildren()[0];
|
|
145371
|
+
if (firstChild && ts.hasJSDocNodes(firstChild) && ((_b = firstChild.jsDoc) === null || _b === void 0 ? void 0 : _b.length) && firstChild.getStart() !== node.pos) {
|
|
145372
|
+
start = Math.min(start, ts.first(firstChild.jsDoc).getStart());
|
|
145373
|
+
}
|
|
145374
|
+
}
|
|
145379
145375
|
pushSelectionRange(start, end);
|
|
145380
145376
|
// String literals should have a stop both inside and outside their quotes.
|
|
145381
145377
|
if (ts.isStringLiteral(node) || ts.isTemplateLiteral(node)) {
|
|
@@ -145449,6 +145445,7 @@ var ts;
|
|
|
145449
145445
|
* other as well as of other top-level statements and declarations.
|
|
145450
145446
|
*/
|
|
145451
145447
|
function getSelectionChildren(node) {
|
|
145448
|
+
var _a;
|
|
145452
145449
|
// Group top-level imports
|
|
145453
145450
|
if (ts.isSourceFile(node)) {
|
|
145454
145451
|
return groupChildren(node.getChildAt(0).getChildren(), isImport);
|
|
@@ -145464,7 +145461,7 @@ var ts;
|
|
|
145464
145461
|
// because it allows the mapped type to become an object type with a
|
|
145465
145462
|
// few keystrokes.
|
|
145466
145463
|
if (ts.isMappedTypeNode(node)) {
|
|
145467
|
-
var
|
|
145464
|
+
var _b = node.getChildren(), openBraceToken = _b[0], children = _b.slice(1);
|
|
145468
145465
|
var closeBraceToken = ts.Debug.checkDefined(children.pop());
|
|
145469
145466
|
ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */);
|
|
145470
145467
|
ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */);
|
|
@@ -145495,10 +145492,13 @@ var ts;
|
|
|
145495
145492
|
var children = groupChildren(node.getChildren(), function (child) {
|
|
145496
145493
|
return child === node.name || ts.contains(node.modifiers, child);
|
|
145497
145494
|
});
|
|
145498
|
-
|
|
145495
|
+
var firstJSDocChild = ((_a = children[0]) === null || _a === void 0 ? void 0 : _a.kind) === 320 /* JSDoc */ ? children[0] : undefined;
|
|
145496
|
+
var withJSDocSeparated = firstJSDocChild ? children.slice(1) : children;
|
|
145497
|
+
var splittedChildren = splitChildren(withJSDocSeparated, function (_a) {
|
|
145499
145498
|
var kind = _a.kind;
|
|
145500
145499
|
return kind === 58 /* ColonToken */;
|
|
145501
145500
|
});
|
|
145501
|
+
return firstJSDocChild ? [firstJSDocChild, createSyntaxList(splittedChildren)] : splittedChildren;
|
|
145502
145502
|
}
|
|
145503
145503
|
// Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`.
|
|
145504
145504
|
if (ts.isParameter(node)) {
|
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.
|
|
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
|
-
|
|
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
|
|
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
|
|
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.
|
|
69305
|
-
|
|
69306
|
-
|
|
69307
|
-
|
|
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
|
-
//
|
|
69364
|
-
//
|
|
69365
|
-
|
|
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])
|
|
69893
|
+
inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]));
|
|
69920
69894
|
}
|
|
69921
69895
|
}
|
|
69922
|
-
function inferFromSignature(source, target
|
|
69923
|
-
|
|
69924
|
-
|
|
69925
|
-
|
|
69926
|
-
|
|
69927
|
-
|
|
69928
|
-
|
|
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) {
|
|
@@ -73511,6 +73483,14 @@ var ts;
|
|
|
73511
73483
|
var lhsType = getTypeOfExpression(e.expression);
|
|
73512
73484
|
return ts.isPrivateIdentifier(e.name) ? tryGetPrivateIdentifierPropertyOfType(lhsType, e.name) : getPropertyOfType(lhsType, e.name.escapedText);
|
|
73513
73485
|
}
|
|
73486
|
+
if (ts.isElementAccessExpression(e)) {
|
|
73487
|
+
var propType = checkExpressionCached(e.argumentExpression);
|
|
73488
|
+
if (!isTypeUsableAsPropertyName(propType)) {
|
|
73489
|
+
return undefined;
|
|
73490
|
+
}
|
|
73491
|
+
var lhsType = getTypeOfExpression(e.expression);
|
|
73492
|
+
return getPropertyOfType(lhsType, getPropertyNameFromType(propType));
|
|
73493
|
+
}
|
|
73514
73494
|
return undefined;
|
|
73515
73495
|
function tryGetPrivateIdentifierPropertyOfType(type, id) {
|
|
73516
73496
|
var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(id.escapedText, id);
|
|
@@ -77425,7 +77405,7 @@ var ts;
|
|
|
77425
77405
|
// returns a function type, we choose to defer processing. This narrowly permits function composition
|
|
77426
77406
|
// operators to flow inferences through return types, but otherwise processes calls right away. We
|
|
77427
77407
|
// use the resolvingSignature singleton to indicate that we deferred processing. This result will be
|
|
77428
|
-
// propagated out and eventually turned into
|
|
77408
|
+
// propagated out and eventually turned into silentNeverType (a type that is assignable to anything and
|
|
77429
77409
|
// from which we never make inferences).
|
|
77430
77410
|
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
|
|
77431
77411
|
skippedGenericFunction(node, checkMode);
|
|
@@ -77978,8 +77958,8 @@ var ts;
|
|
|
77978
77958
|
var signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode);
|
|
77979
77959
|
if (signature === resolvingSignature) {
|
|
77980
77960
|
// CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that
|
|
77981
|
-
// returns a function type. We defer checking and return
|
|
77982
|
-
return
|
|
77961
|
+
// returns a function type. We defer checking and return silentNeverType.
|
|
77962
|
+
return silentNeverType;
|
|
77983
77963
|
}
|
|
77984
77964
|
checkDeprecatedSignature(signature, node);
|
|
77985
77965
|
if (node.expression.kind === 106 /* SuperKeyword */) {
|
|
@@ -84605,9 +84585,14 @@ var ts;
|
|
|
84605
84585
|
function unwrapReturnType(returnType, functionFlags) {
|
|
84606
84586
|
var isGenerator = !!(functionFlags & 1 /* Generator */);
|
|
84607
84587
|
var isAsync = !!(functionFlags & 2 /* Async */);
|
|
84608
|
-
|
|
84609
|
-
|
|
84610
|
-
|
|
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;
|
|
84611
84596
|
}
|
|
84612
84597
|
function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
|
|
84613
84598
|
var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
|
|
@@ -145315,7 +145300,7 @@ var ts;
|
|
|
145315
145300
|
var SmartSelectionRange;
|
|
145316
145301
|
(function (SmartSelectionRange) {
|
|
145317
145302
|
function getSmartSelectionRange(pos, sourceFile) {
|
|
145318
|
-
var _a;
|
|
145303
|
+
var _a, _b;
|
|
145319
145304
|
var selectionRange = {
|
|
145320
145305
|
textSpan: ts.createTextSpanFromBounds(sourceFile.getFullStart(), sourceFile.getEnd())
|
|
145321
145306
|
};
|
|
@@ -145367,6 +145352,17 @@ var ts;
|
|
|
145367
145352
|
if (ts.hasJSDocNodes(node) && ((_a = node.jsDoc) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
145368
145353
|
pushSelectionRange(ts.first(node.jsDoc).getStart(), end);
|
|
145369
145354
|
}
|
|
145355
|
+
// (#39618 & #49807)
|
|
145356
|
+
// When the node is a SyntaxList and its first child has a JSDoc comment, then the node's
|
|
145357
|
+
// `start` (which usually is the result of calling `node.getStart()`) points to the first
|
|
145358
|
+
// token after the JSDoc comment. So, we have to make sure we'd pushed the selection
|
|
145359
|
+
// covering the JSDoc comment before diving further.
|
|
145360
|
+
if (ts.isSyntaxList(node)) {
|
|
145361
|
+
var firstChild = node.getChildren()[0];
|
|
145362
|
+
if (firstChild && ts.hasJSDocNodes(firstChild) && ((_b = firstChild.jsDoc) === null || _b === void 0 ? void 0 : _b.length) && firstChild.getStart() !== node.pos) {
|
|
145363
|
+
start = Math.min(start, ts.first(firstChild.jsDoc).getStart());
|
|
145364
|
+
}
|
|
145365
|
+
}
|
|
145370
145366
|
pushSelectionRange(start, end);
|
|
145371
145367
|
// String literals should have a stop both inside and outside their quotes.
|
|
145372
145368
|
if (ts.isStringLiteral(node) || ts.isTemplateLiteral(node)) {
|
|
@@ -145440,6 +145436,7 @@ var ts;
|
|
|
145440
145436
|
* other as well as of other top-level statements and declarations.
|
|
145441
145437
|
*/
|
|
145442
145438
|
function getSelectionChildren(node) {
|
|
145439
|
+
var _a;
|
|
145443
145440
|
// Group top-level imports
|
|
145444
145441
|
if (ts.isSourceFile(node)) {
|
|
145445
145442
|
return groupChildren(node.getChildAt(0).getChildren(), isImport);
|
|
@@ -145455,7 +145452,7 @@ var ts;
|
|
|
145455
145452
|
// because it allows the mapped type to become an object type with a
|
|
145456
145453
|
// few keystrokes.
|
|
145457
145454
|
if (ts.isMappedTypeNode(node)) {
|
|
145458
|
-
var
|
|
145455
|
+
var _b = node.getChildren(), openBraceToken = _b[0], children = _b.slice(1);
|
|
145459
145456
|
var closeBraceToken = ts.Debug.checkDefined(children.pop());
|
|
145460
145457
|
ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */);
|
|
145461
145458
|
ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */);
|
|
@@ -145486,10 +145483,13 @@ var ts;
|
|
|
145486
145483
|
var children = groupChildren(node.getChildren(), function (child) {
|
|
145487
145484
|
return child === node.name || ts.contains(node.modifiers, child);
|
|
145488
145485
|
});
|
|
145489
|
-
|
|
145486
|
+
var firstJSDocChild = ((_a = children[0]) === null || _a === void 0 ? void 0 : _a.kind) === 320 /* JSDoc */ ? children[0] : undefined;
|
|
145487
|
+
var withJSDocSeparated = firstJSDocChild ? children.slice(1) : children;
|
|
145488
|
+
var splittedChildren = splitChildren(withJSDocSeparated, function (_a) {
|
|
145490
145489
|
var kind = _a.kind;
|
|
145491
145490
|
return kind === 58 /* ColonToken */;
|
|
145492
145491
|
});
|
|
145492
|
+
return firstJSDocChild ? [firstJSDocChild, createSyntaxList(splittedChildren)] : splittedChildren;
|
|
145493
145493
|
}
|
|
145494
145494
|
// Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`.
|
|
145495
145495
|
if (ts.isParameter(node)) {
|