typescript 4.7.0-dev.20220328 → 4.7.0-dev.20220329
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 +75 -100
- package/lib/tsserver.js +92 -120
- package/lib/tsserverlibrary.js +92 -120
- package/lib/typescript.js +92 -120
- package/lib/typescriptServices.js +92 -120
- package/lib/typingsInstaller.js +86 -112
- package/package.json +1 -1
|
@@ -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.20220329";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -13606,7 +13606,9 @@ var ts;
|
|
|
13606
13606
|
|| kind === 174 /* CallSignature */
|
|
13607
13607
|
|| kind === 166 /* PropertySignature */
|
|
13608
13608
|
|| kind === 168 /* MethodSignature */
|
|
13609
|
-
|| kind === 176 /* IndexSignature
|
|
13609
|
+
|| kind === 176 /* IndexSignature */
|
|
13610
|
+
|| kind === 172 /* GetAccessor */
|
|
13611
|
+
|| kind === 173 /* SetAccessor */;
|
|
13610
13612
|
}
|
|
13611
13613
|
ts.isTypeElement = isTypeElement;
|
|
13612
13614
|
function isClassOrTypeElement(node) {
|
|
@@ -47588,6 +47590,7 @@ var ts;
|
|
|
47588
47590
|
TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType";
|
|
47589
47591
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 6] = "ResolvedTypeArguments";
|
|
47590
47592
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseTypes"] = 7] = "ResolvedBaseTypes";
|
|
47593
|
+
TypeSystemPropertyName[TypeSystemPropertyName["WriteType"] = 8] = "WriteType";
|
|
47591
47594
|
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
|
|
47592
47595
|
var CheckMode;
|
|
47593
47596
|
(function (CheckMode) {
|
|
@@ -49102,6 +49105,10 @@ var ts;
|
|
|
49102
49105
|
}
|
|
49103
49106
|
}
|
|
49104
49107
|
}
|
|
49108
|
+
function isConstAssertion(location) {
|
|
49109
|
+
return (ts.isAssertionExpression(location) && ts.isConstTypeReference(location.type))
|
|
49110
|
+
|| (ts.isJSDocTypeTag(location) && ts.isConstTypeReference(location.typeExpression));
|
|
49111
|
+
}
|
|
49105
49112
|
/**
|
|
49106
49113
|
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
|
49107
49114
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
@@ -49127,6 +49134,11 @@ var ts;
|
|
|
49127
49134
|
var grandparent;
|
|
49128
49135
|
var isInExternalModule = false;
|
|
49129
49136
|
loop: while (location) {
|
|
49137
|
+
if (name === "const" && isConstAssertion(location)) {
|
|
49138
|
+
// `const` in an `as const` has no symbol, but issues no error because there is no *actual* lookup of the type
|
|
49139
|
+
// (it refers to the constant type of the expression instead)
|
|
49140
|
+
return undefined;
|
|
49141
|
+
}
|
|
49130
49142
|
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
|
49131
49143
|
if (location.locals && !isGlobalSourceFile(location)) {
|
|
49132
49144
|
if (result = lookup(location.locals, name, meaning)) {
|
|
@@ -55075,6 +55087,8 @@ var ts;
|
|
|
55075
55087
|
return !!target.resolvedTypeArguments;
|
|
55076
55088
|
case 7 /* ResolvedBaseTypes */:
|
|
55077
55089
|
return !!target.baseTypesResolved;
|
|
55090
|
+
case 8 /* WriteType */:
|
|
55091
|
+
return !!getSymbolLinks(target).writeType;
|
|
55078
55092
|
}
|
|
55079
55093
|
return ts.Debug.assertNever(propertyName);
|
|
55080
55094
|
}
|
|
@@ -55992,6 +56006,11 @@ var ts;
|
|
|
55992
56006
|
}
|
|
55993
56007
|
return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
|
|
55994
56008
|
}
|
|
56009
|
+
if (ts.isAccessor(declaration)) {
|
|
56010
|
+
// Binding of certain patterns in JS code will occasionally mark symbols as both properties
|
|
56011
|
+
// and accessors. Here we dispatch to accessor resolution if needed.
|
|
56012
|
+
return getTypeOfAccessors(symbol);
|
|
56013
|
+
}
|
|
55995
56014
|
// Handle variable, parameter or property
|
|
55996
56015
|
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55997
56016
|
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
|
@@ -56055,9 +56074,6 @@ var ts;
|
|
|
56055
56074
|
else if (ts.isEnumMember(declaration)) {
|
|
56056
56075
|
type = getTypeOfEnumMember(symbol);
|
|
56057
56076
|
}
|
|
56058
|
-
else if (ts.isAccessor(declaration)) {
|
|
56059
|
-
type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type");
|
|
56060
|
-
}
|
|
56061
56077
|
else {
|
|
56062
56078
|
return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
|
|
56063
56079
|
}
|
|
@@ -56096,87 +56112,61 @@ var ts;
|
|
|
56096
56112
|
}
|
|
56097
56113
|
function getTypeOfAccessors(symbol) {
|
|
56098
56114
|
var links = getSymbolLinks(symbol);
|
|
56099
|
-
|
|
56100
|
-
|
|
56101
|
-
|
|
56102
|
-
|
|
56103
|
-
return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true));
|
|
56104
|
-
}
|
|
56105
|
-
function getTypeOfAccessorsWorker(symbol, writing) {
|
|
56106
|
-
if (writing === void 0) { writing = false; }
|
|
56107
|
-
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
56108
|
-
return errorType;
|
|
56109
|
-
}
|
|
56110
|
-
var type = resolveTypeOfAccessors(symbol, writing);
|
|
56111
|
-
if (!popTypeResolution()) {
|
|
56115
|
+
if (!links.type) {
|
|
56116
|
+
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
56117
|
+
return errorType;
|
|
56118
|
+
}
|
|
56112
56119
|
var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */);
|
|
56113
|
-
|
|
56114
|
-
|
|
56115
|
-
|
|
56120
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
56121
|
+
// We try to resolve a getter type annotation, a setter type annotation, or a getter function
|
|
56122
|
+
// body return type inference, in that order.
|
|
56123
|
+
var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) ||
|
|
56124
|
+
getAnnotatedAccessorType(getter) ||
|
|
56125
|
+
getAnnotatedAccessorType(setter) ||
|
|
56126
|
+
getter && getter.body && getReturnTypeFromBody(getter);
|
|
56127
|
+
if (!type) {
|
|
56128
|
+
if (setter && !isPrivateWithinAmbient(setter)) {
|
|
56129
|
+
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
56130
|
+
}
|
|
56131
|
+
else if (getter && !isPrivateWithinAmbient(getter)) {
|
|
56132
|
+
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
56133
|
+
}
|
|
56134
|
+
type = anyType;
|
|
56135
|
+
}
|
|
56136
|
+
if (!popTypeResolution()) {
|
|
56137
|
+
if (getAnnotatedAccessorTypeNode(getter)) {
|
|
56138
|
+
error(getter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56139
|
+
}
|
|
56140
|
+
else if (getAnnotatedAccessorTypeNode(setter)) {
|
|
56141
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56116
56142
|
}
|
|
56117
|
-
else if (noImplicitAny) {
|
|
56143
|
+
else if (getter && noImplicitAny) {
|
|
56118
56144
|
error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
|
|
56119
56145
|
}
|
|
56146
|
+
type = anyType;
|
|
56120
56147
|
}
|
|
56121
|
-
type =
|
|
56148
|
+
links.type = type;
|
|
56122
56149
|
}
|
|
56123
|
-
return type;
|
|
56150
|
+
return links.type;
|
|
56124
56151
|
}
|
|
56125
|
-
function
|
|
56126
|
-
|
|
56127
|
-
|
|
56128
|
-
|
|
56129
|
-
|
|
56130
|
-
if (writing) {
|
|
56131
|
-
var setterType_1 = getAnnotatedAccessorType(setter);
|
|
56132
|
-
if (setterType_1) {
|
|
56133
|
-
return instantiateTypeIfNeeded(setterType_1, symbol);
|
|
56134
|
-
}
|
|
56135
|
-
}
|
|
56136
|
-
// Else defer to the getter type
|
|
56137
|
-
if (getter && ts.isInJSFile(getter)) {
|
|
56138
|
-
var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
|
|
56139
|
-
if (jsDocType) {
|
|
56140
|
-
return instantiateTypeIfNeeded(jsDocType, symbol);
|
|
56141
|
-
}
|
|
56142
|
-
}
|
|
56143
|
-
// Try to see if the user specified a return type on the get-accessor.
|
|
56144
|
-
var getterType = getAnnotatedAccessorType(getter);
|
|
56145
|
-
if (getterType) {
|
|
56146
|
-
return instantiateTypeIfNeeded(getterType, symbol);
|
|
56147
|
-
}
|
|
56148
|
-
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
|
56149
|
-
var setterType = getAnnotatedAccessorType(setter);
|
|
56150
|
-
if (setterType) {
|
|
56151
|
-
return setterType;
|
|
56152
|
-
}
|
|
56153
|
-
// If there are no specified types, try to infer it from the body of the get accessor if it exists.
|
|
56154
|
-
if (getter && getter.body) {
|
|
56155
|
-
var returnTypeFromBody = getReturnTypeFromBody(getter);
|
|
56156
|
-
return instantiateTypeIfNeeded(returnTypeFromBody, symbol);
|
|
56157
|
-
}
|
|
56158
|
-
// Otherwise, fall back to 'any'.
|
|
56159
|
-
if (setter) {
|
|
56160
|
-
if (!isPrivateWithinAmbient(setter)) {
|
|
56161
|
-
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
56162
|
-
}
|
|
56163
|
-
return anyType;
|
|
56164
|
-
}
|
|
56165
|
-
else if (getter) {
|
|
56166
|
-
ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
|
|
56167
|
-
if (!isPrivateWithinAmbient(getter)) {
|
|
56168
|
-
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
56152
|
+
function getWriteTypeOfAccessors(symbol) {
|
|
56153
|
+
var links = getSymbolLinks(symbol);
|
|
56154
|
+
if (!links.writeType) {
|
|
56155
|
+
if (!pushTypeResolution(symbol, 8 /* WriteType */)) {
|
|
56156
|
+
return errorType;
|
|
56169
56157
|
}
|
|
56170
|
-
|
|
56171
|
-
|
|
56172
|
-
|
|
56173
|
-
|
|
56174
|
-
|
|
56175
|
-
|
|
56176
|
-
|
|
56158
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
56159
|
+
var writeType = getAnnotatedAccessorType(setter);
|
|
56160
|
+
if (!popTypeResolution()) {
|
|
56161
|
+
if (getAnnotatedAccessorTypeNode(setter)) {
|
|
56162
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56163
|
+
}
|
|
56164
|
+
writeType = anyType;
|
|
56177
56165
|
}
|
|
56178
|
-
|
|
56166
|
+
// Absent an explicit setter type annotation we use the read type of the accessor.
|
|
56167
|
+
links.writeType = writeType || getTypeOfAccessors(symbol);
|
|
56179
56168
|
}
|
|
56169
|
+
return links.writeType;
|
|
56180
56170
|
}
|
|
56181
56171
|
function getBaseTypeVariableOfClass(symbol) {
|
|
56182
56172
|
var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
|
|
@@ -56258,17 +56248,11 @@ var ts;
|
|
|
56258
56248
|
}
|
|
56259
56249
|
function getTypeOfInstantiatedSymbol(symbol) {
|
|
56260
56250
|
var links = getSymbolLinks(symbol);
|
|
56261
|
-
|
|
56262
|
-
|
|
56263
|
-
|
|
56264
|
-
|
|
56265
|
-
|
|
56266
|
-
if (!popTypeResolution()) {
|
|
56267
|
-
type = reportCircularityError(symbol);
|
|
56268
|
-
}
|
|
56269
|
-
links.type = type;
|
|
56270
|
-
}
|
|
56271
|
-
return links.type;
|
|
56251
|
+
return links.type || (links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper));
|
|
56252
|
+
}
|
|
56253
|
+
function getWriteTypeOfInstantiatedSymbol(symbol) {
|
|
56254
|
+
var links = getSymbolLinks(symbol);
|
|
56255
|
+
return links.writeType || (links.writeType = instantiateType(getWriteTypeOfSymbol(links.target), links.mapper));
|
|
56272
56256
|
}
|
|
56273
56257
|
function reportCircularityError(symbol) {
|
|
56274
56258
|
var declaration = symbol.valueDeclaration;
|
|
@@ -56305,35 +56289,23 @@ var ts;
|
|
|
56305
56289
|
return links.writeType;
|
|
56306
56290
|
}
|
|
56307
56291
|
/**
|
|
56308
|
-
* Distinct write types come only from set accessors, but union and intersection
|
|
56309
|
-
* properties deriving from set accessors will either pre-compute or defer the
|
|
56310
|
-
*
|
|
56311
|
-
* this, we will assume that any deferred type or transient symbol may have a
|
|
56312
|
-
* `writeType` (or a deferred write type ready to be computed) that should be
|
|
56313
|
-
* used before looking for set accessor declarations.
|
|
56292
|
+
* Distinct write types come only from set accessors, but synthetic union and intersection
|
|
56293
|
+
* properties deriving from set accessors will either pre-compute or defer the union or
|
|
56294
|
+
* intersection of the writeTypes of their constituents.
|
|
56314
56295
|
*/
|
|
56315
56296
|
function getWriteTypeOfSymbol(symbol) {
|
|
56316
56297
|
var checkFlags = ts.getCheckFlags(symbol);
|
|
56317
|
-
if (
|
|
56318
|
-
|
|
56319
|
-
|
|
56320
|
-
|
|
56321
|
-
|
|
56298
|
+
if (symbol.flags & 4 /* Property */) {
|
|
56299
|
+
return checkFlags & 2 /* SyntheticProperty */ ?
|
|
56300
|
+
checkFlags & 65536 /* DeferredType */ ?
|
|
56301
|
+
getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
|
|
56302
|
+
symbol.writeType || symbol.type :
|
|
56303
|
+
getTypeOfSymbol(symbol);
|
|
56322
56304
|
}
|
|
56323
|
-
if (symbol.flags & 33554432 /* Transient */) {
|
|
56324
|
-
var writeType = symbol.writeType;
|
|
56325
|
-
if (writeType) {
|
|
56326
|
-
return writeType;
|
|
56327
|
-
}
|
|
56328
|
-
}
|
|
56329
|
-
return getSetAccessorTypeOfSymbol(symbol);
|
|
56330
|
-
}
|
|
56331
|
-
function getSetAccessorTypeOfSymbol(symbol) {
|
|
56332
56305
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
56333
|
-
|
|
56334
|
-
|
|
56335
|
-
|
|
56336
|
-
}
|
|
56306
|
+
return checkFlags & 1 /* Instantiated */ ?
|
|
56307
|
+
getWriteTypeOfInstantiatedSymbol(symbol) :
|
|
56308
|
+
getWriteTypeOfAccessors(symbol);
|
|
56337
56309
|
}
|
|
56338
56310
|
return getTypeOfSymbol(symbol);
|
|
56339
56311
|
}
|
|
@@ -70804,7 +70776,7 @@ var ts;
|
|
|
70804
70776
|
}
|
|
70805
70777
|
}
|
|
70806
70778
|
if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) {
|
|
70807
|
-
return
|
|
70779
|
+
return getWriteTypeOfAccessors(location.parent.symbol);
|
|
70808
70780
|
}
|
|
70809
70781
|
// The location isn't a reference to the given symbol, meaning we're being asked
|
|
70810
70782
|
// a hypothetical question of what type the symbol would have if there was a reference
|
|
@@ -82007,6 +81979,8 @@ var ts;
|
|
|
82007
81979
|
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
82008
81980
|
? condExpr.right
|
|
82009
81981
|
: condExpr;
|
|
81982
|
+
if (ts.isModuleExportsAccessExpression(location))
|
|
81983
|
+
return;
|
|
82010
81984
|
var type = checkTruthinessExpression(location);
|
|
82011
81985
|
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
82012
81986
|
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
|
@@ -126684,12 +126658,8 @@ var ts;
|
|
|
126684
126658
|
}
|
|
126685
126659
|
}
|
|
126686
126660
|
ts.findNextToken = findNextToken;
|
|
126687
|
-
/**
|
|
126688
|
-
* Finds the rightmost token satisfying `token.end <= position`,
|
|
126689
|
-
* excluding `JsxText` tokens containing only whitespace.
|
|
126690
|
-
*/
|
|
126691
126661
|
function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) {
|
|
126692
|
-
var result = find(startNode || sourceFile);
|
|
126662
|
+
var result = find((startNode || sourceFile));
|
|
126693
126663
|
ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result)));
|
|
126694
126664
|
return result;
|
|
126695
126665
|
function find(n) {
|
|
@@ -145947,6 +145917,7 @@ var ts;
|
|
|
145947
145917
|
return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); });
|
|
145948
145918
|
}
|
|
145949
145919
|
function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) {
|
|
145920
|
+
var _b;
|
|
145950
145921
|
var options = _a.options, getRules = _a.getRules, host = _a.host;
|
|
145951
145922
|
// formatting context is used by rules provider
|
|
145952
145923
|
var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options);
|
|
@@ -145978,11 +145949,12 @@ var ts;
|
|
|
145978
145949
|
}
|
|
145979
145950
|
}
|
|
145980
145951
|
if (previousRange && formattingScanner.getStartPos() >= originalRange.end) {
|
|
145981
|
-
var
|
|
145952
|
+
var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() :
|
|
145982
145953
|
formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token :
|
|
145983
145954
|
undefined;
|
|
145984
|
-
if (
|
|
145985
|
-
|
|
145955
|
+
if (tokenInfo) {
|
|
145956
|
+
var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent;
|
|
145957
|
+
processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent,
|
|
145986
145958
|
/*dynamicIndentation*/ undefined);
|
|
145987
145959
|
}
|
|
145988
145960
|
}
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -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.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220329";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -13401,7 +13401,9 @@ var ts;
|
|
|
13401
13401
|
|| kind === 174 /* CallSignature */
|
|
13402
13402
|
|| kind === 166 /* PropertySignature */
|
|
13403
13403
|
|| kind === 168 /* MethodSignature */
|
|
13404
|
-
|| kind === 176 /* IndexSignature
|
|
13404
|
+
|| kind === 176 /* IndexSignature */
|
|
13405
|
+
|| kind === 172 /* GetAccessor */
|
|
13406
|
+
|| kind === 173 /* SetAccessor */;
|
|
13405
13407
|
}
|
|
13406
13408
|
ts.isTypeElement = isTypeElement;
|
|
13407
13409
|
function isClassOrTypeElement(node) {
|
|
@@ -47383,6 +47385,7 @@ var ts;
|
|
|
47383
47385
|
TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType";
|
|
47384
47386
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 6] = "ResolvedTypeArguments";
|
|
47385
47387
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseTypes"] = 7] = "ResolvedBaseTypes";
|
|
47388
|
+
TypeSystemPropertyName[TypeSystemPropertyName["WriteType"] = 8] = "WriteType";
|
|
47386
47389
|
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
|
|
47387
47390
|
var CheckMode;
|
|
47388
47391
|
(function (CheckMode) {
|
|
@@ -48897,6 +48900,10 @@ var ts;
|
|
|
48897
48900
|
}
|
|
48898
48901
|
}
|
|
48899
48902
|
}
|
|
48903
|
+
function isConstAssertion(location) {
|
|
48904
|
+
return (ts.isAssertionExpression(location) && ts.isConstTypeReference(location.type))
|
|
48905
|
+
|| (ts.isJSDocTypeTag(location) && ts.isConstTypeReference(location.typeExpression));
|
|
48906
|
+
}
|
|
48900
48907
|
/**
|
|
48901
48908
|
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
|
48902
48909
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
@@ -48922,6 +48929,11 @@ var ts;
|
|
|
48922
48929
|
var grandparent;
|
|
48923
48930
|
var isInExternalModule = false;
|
|
48924
48931
|
loop: while (location) {
|
|
48932
|
+
if (name === "const" && isConstAssertion(location)) {
|
|
48933
|
+
// `const` in an `as const` has no symbol, but issues no error because there is no *actual* lookup of the type
|
|
48934
|
+
// (it refers to the constant type of the expression instead)
|
|
48935
|
+
return undefined;
|
|
48936
|
+
}
|
|
48925
48937
|
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
|
48926
48938
|
if (location.locals && !isGlobalSourceFile(location)) {
|
|
48927
48939
|
if (result = lookup(location.locals, name, meaning)) {
|
|
@@ -54870,6 +54882,8 @@ var ts;
|
|
|
54870
54882
|
return !!target.resolvedTypeArguments;
|
|
54871
54883
|
case 7 /* ResolvedBaseTypes */:
|
|
54872
54884
|
return !!target.baseTypesResolved;
|
|
54885
|
+
case 8 /* WriteType */:
|
|
54886
|
+
return !!getSymbolLinks(target).writeType;
|
|
54873
54887
|
}
|
|
54874
54888
|
return ts.Debug.assertNever(propertyName);
|
|
54875
54889
|
}
|
|
@@ -55787,6 +55801,11 @@ var ts;
|
|
|
55787
55801
|
}
|
|
55788
55802
|
return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
|
|
55789
55803
|
}
|
|
55804
|
+
if (ts.isAccessor(declaration)) {
|
|
55805
|
+
// Binding of certain patterns in JS code will occasionally mark symbols as both properties
|
|
55806
|
+
// and accessors. Here we dispatch to accessor resolution if needed.
|
|
55807
|
+
return getTypeOfAccessors(symbol);
|
|
55808
|
+
}
|
|
55790
55809
|
// Handle variable, parameter or property
|
|
55791
55810
|
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55792
55811
|
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
|
@@ -55850,9 +55869,6 @@ var ts;
|
|
|
55850
55869
|
else if (ts.isEnumMember(declaration)) {
|
|
55851
55870
|
type = getTypeOfEnumMember(symbol);
|
|
55852
55871
|
}
|
|
55853
|
-
else if (ts.isAccessor(declaration)) {
|
|
55854
|
-
type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type");
|
|
55855
|
-
}
|
|
55856
55872
|
else {
|
|
55857
55873
|
return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
|
|
55858
55874
|
}
|
|
@@ -55891,87 +55907,61 @@ var ts;
|
|
|
55891
55907
|
}
|
|
55892
55908
|
function getTypeOfAccessors(symbol) {
|
|
55893
55909
|
var links = getSymbolLinks(symbol);
|
|
55894
|
-
|
|
55895
|
-
|
|
55896
|
-
|
|
55897
|
-
|
|
55898
|
-
return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true));
|
|
55899
|
-
}
|
|
55900
|
-
function getTypeOfAccessorsWorker(symbol, writing) {
|
|
55901
|
-
if (writing === void 0) { writing = false; }
|
|
55902
|
-
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55903
|
-
return errorType;
|
|
55904
|
-
}
|
|
55905
|
-
var type = resolveTypeOfAccessors(symbol, writing);
|
|
55906
|
-
if (!popTypeResolution()) {
|
|
55910
|
+
if (!links.type) {
|
|
55911
|
+
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55912
|
+
return errorType;
|
|
55913
|
+
}
|
|
55907
55914
|
var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */);
|
|
55908
|
-
|
|
55909
|
-
|
|
55910
|
-
|
|
55915
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
55916
|
+
// We try to resolve a getter type annotation, a setter type annotation, or a getter function
|
|
55917
|
+
// body return type inference, in that order.
|
|
55918
|
+
var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) ||
|
|
55919
|
+
getAnnotatedAccessorType(getter) ||
|
|
55920
|
+
getAnnotatedAccessorType(setter) ||
|
|
55921
|
+
getter && getter.body && getReturnTypeFromBody(getter);
|
|
55922
|
+
if (!type) {
|
|
55923
|
+
if (setter && !isPrivateWithinAmbient(setter)) {
|
|
55924
|
+
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
55925
|
+
}
|
|
55926
|
+
else if (getter && !isPrivateWithinAmbient(getter)) {
|
|
55927
|
+
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
55928
|
+
}
|
|
55929
|
+
type = anyType;
|
|
55930
|
+
}
|
|
55931
|
+
if (!popTypeResolution()) {
|
|
55932
|
+
if (getAnnotatedAccessorTypeNode(getter)) {
|
|
55933
|
+
error(getter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55911
55934
|
}
|
|
55912
|
-
else if (
|
|
55935
|
+
else if (getAnnotatedAccessorTypeNode(setter)) {
|
|
55936
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55937
|
+
}
|
|
55938
|
+
else if (getter && noImplicitAny) {
|
|
55913
55939
|
error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
|
|
55914
55940
|
}
|
|
55941
|
+
type = anyType;
|
|
55915
55942
|
}
|
|
55916
|
-
type =
|
|
55943
|
+
links.type = type;
|
|
55917
55944
|
}
|
|
55918
|
-
return type;
|
|
55945
|
+
return links.type;
|
|
55919
55946
|
}
|
|
55920
|
-
function
|
|
55921
|
-
|
|
55922
|
-
|
|
55923
|
-
|
|
55924
|
-
|
|
55925
|
-
if (writing) {
|
|
55926
|
-
var setterType_1 = getAnnotatedAccessorType(setter);
|
|
55927
|
-
if (setterType_1) {
|
|
55928
|
-
return instantiateTypeIfNeeded(setterType_1, symbol);
|
|
55929
|
-
}
|
|
55930
|
-
}
|
|
55931
|
-
// Else defer to the getter type
|
|
55932
|
-
if (getter && ts.isInJSFile(getter)) {
|
|
55933
|
-
var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
|
|
55934
|
-
if (jsDocType) {
|
|
55935
|
-
return instantiateTypeIfNeeded(jsDocType, symbol);
|
|
55936
|
-
}
|
|
55937
|
-
}
|
|
55938
|
-
// Try to see if the user specified a return type on the get-accessor.
|
|
55939
|
-
var getterType = getAnnotatedAccessorType(getter);
|
|
55940
|
-
if (getterType) {
|
|
55941
|
-
return instantiateTypeIfNeeded(getterType, symbol);
|
|
55942
|
-
}
|
|
55943
|
-
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
|
55944
|
-
var setterType = getAnnotatedAccessorType(setter);
|
|
55945
|
-
if (setterType) {
|
|
55946
|
-
return setterType;
|
|
55947
|
-
}
|
|
55948
|
-
// If there are no specified types, try to infer it from the body of the get accessor if it exists.
|
|
55949
|
-
if (getter && getter.body) {
|
|
55950
|
-
var returnTypeFromBody = getReturnTypeFromBody(getter);
|
|
55951
|
-
return instantiateTypeIfNeeded(returnTypeFromBody, symbol);
|
|
55952
|
-
}
|
|
55953
|
-
// Otherwise, fall back to 'any'.
|
|
55954
|
-
if (setter) {
|
|
55955
|
-
if (!isPrivateWithinAmbient(setter)) {
|
|
55956
|
-
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
55957
|
-
}
|
|
55958
|
-
return anyType;
|
|
55959
|
-
}
|
|
55960
|
-
else if (getter) {
|
|
55961
|
-
ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
|
|
55962
|
-
if (!isPrivateWithinAmbient(getter)) {
|
|
55963
|
-
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
55947
|
+
function getWriteTypeOfAccessors(symbol) {
|
|
55948
|
+
var links = getSymbolLinks(symbol);
|
|
55949
|
+
if (!links.writeType) {
|
|
55950
|
+
if (!pushTypeResolution(symbol, 8 /* WriteType */)) {
|
|
55951
|
+
return errorType;
|
|
55964
55952
|
}
|
|
55965
|
-
|
|
55966
|
-
|
|
55967
|
-
|
|
55968
|
-
|
|
55969
|
-
|
|
55970
|
-
|
|
55971
|
-
|
|
55953
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
55954
|
+
var writeType = getAnnotatedAccessorType(setter);
|
|
55955
|
+
if (!popTypeResolution()) {
|
|
55956
|
+
if (getAnnotatedAccessorTypeNode(setter)) {
|
|
55957
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55958
|
+
}
|
|
55959
|
+
writeType = anyType;
|
|
55972
55960
|
}
|
|
55973
|
-
|
|
55961
|
+
// Absent an explicit setter type annotation we use the read type of the accessor.
|
|
55962
|
+
links.writeType = writeType || getTypeOfAccessors(symbol);
|
|
55974
55963
|
}
|
|
55964
|
+
return links.writeType;
|
|
55975
55965
|
}
|
|
55976
55966
|
function getBaseTypeVariableOfClass(symbol) {
|
|
55977
55967
|
var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
|
|
@@ -56053,17 +56043,11 @@ var ts;
|
|
|
56053
56043
|
}
|
|
56054
56044
|
function getTypeOfInstantiatedSymbol(symbol) {
|
|
56055
56045
|
var links = getSymbolLinks(symbol);
|
|
56056
|
-
|
|
56057
|
-
|
|
56058
|
-
|
|
56059
|
-
|
|
56060
|
-
|
|
56061
|
-
if (!popTypeResolution()) {
|
|
56062
|
-
type = reportCircularityError(symbol);
|
|
56063
|
-
}
|
|
56064
|
-
links.type = type;
|
|
56065
|
-
}
|
|
56066
|
-
return links.type;
|
|
56046
|
+
return links.type || (links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper));
|
|
56047
|
+
}
|
|
56048
|
+
function getWriteTypeOfInstantiatedSymbol(symbol) {
|
|
56049
|
+
var links = getSymbolLinks(symbol);
|
|
56050
|
+
return links.writeType || (links.writeType = instantiateType(getWriteTypeOfSymbol(links.target), links.mapper));
|
|
56067
56051
|
}
|
|
56068
56052
|
function reportCircularityError(symbol) {
|
|
56069
56053
|
var declaration = symbol.valueDeclaration;
|
|
@@ -56100,35 +56084,23 @@ var ts;
|
|
|
56100
56084
|
return links.writeType;
|
|
56101
56085
|
}
|
|
56102
56086
|
/**
|
|
56103
|
-
* Distinct write types come only from set accessors, but union and intersection
|
|
56104
|
-
* properties deriving from set accessors will either pre-compute or defer the
|
|
56105
|
-
*
|
|
56106
|
-
* this, we will assume that any deferred type or transient symbol may have a
|
|
56107
|
-
* `writeType` (or a deferred write type ready to be computed) that should be
|
|
56108
|
-
* used before looking for set accessor declarations.
|
|
56087
|
+
* Distinct write types come only from set accessors, but synthetic union and intersection
|
|
56088
|
+
* properties deriving from set accessors will either pre-compute or defer the union or
|
|
56089
|
+
* intersection of the writeTypes of their constituents.
|
|
56109
56090
|
*/
|
|
56110
56091
|
function getWriteTypeOfSymbol(symbol) {
|
|
56111
56092
|
var checkFlags = ts.getCheckFlags(symbol);
|
|
56112
|
-
if (
|
|
56113
|
-
|
|
56114
|
-
|
|
56115
|
-
|
|
56116
|
-
|
|
56093
|
+
if (symbol.flags & 4 /* Property */) {
|
|
56094
|
+
return checkFlags & 2 /* SyntheticProperty */ ?
|
|
56095
|
+
checkFlags & 65536 /* DeferredType */ ?
|
|
56096
|
+
getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
|
|
56097
|
+
symbol.writeType || symbol.type :
|
|
56098
|
+
getTypeOfSymbol(symbol);
|
|
56117
56099
|
}
|
|
56118
|
-
if (symbol.flags & 33554432 /* Transient */) {
|
|
56119
|
-
var writeType = symbol.writeType;
|
|
56120
|
-
if (writeType) {
|
|
56121
|
-
return writeType;
|
|
56122
|
-
}
|
|
56123
|
-
}
|
|
56124
|
-
return getSetAccessorTypeOfSymbol(symbol);
|
|
56125
|
-
}
|
|
56126
|
-
function getSetAccessorTypeOfSymbol(symbol) {
|
|
56127
56100
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
56128
|
-
|
|
56129
|
-
|
|
56130
|
-
|
|
56131
|
-
}
|
|
56101
|
+
return checkFlags & 1 /* Instantiated */ ?
|
|
56102
|
+
getWriteTypeOfInstantiatedSymbol(symbol) :
|
|
56103
|
+
getWriteTypeOfAccessors(symbol);
|
|
56132
56104
|
}
|
|
56133
56105
|
return getTypeOfSymbol(symbol);
|
|
56134
56106
|
}
|
|
@@ -70599,7 +70571,7 @@ var ts;
|
|
|
70599
70571
|
}
|
|
70600
70572
|
}
|
|
70601
70573
|
if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) {
|
|
70602
|
-
return
|
|
70574
|
+
return getWriteTypeOfAccessors(location.parent.symbol);
|
|
70603
70575
|
}
|
|
70604
70576
|
// The location isn't a reference to the given symbol, meaning we're being asked
|
|
70605
70577
|
// a hypothetical question of what type the symbol would have if there was a reference
|
|
@@ -81802,6 +81774,8 @@ var ts;
|
|
|
81802
81774
|
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
81803
81775
|
? condExpr.right
|
|
81804
81776
|
: condExpr;
|
|
81777
|
+
if (ts.isModuleExportsAccessExpression(location))
|
|
81778
|
+
return;
|
|
81805
81779
|
var type = checkTruthinessExpression(location);
|
|
81806
81780
|
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
81807
81781
|
if (getFalsyFlags(type) || isPropertyExpressionCast)
|