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
package/lib/tsc.js
CHANGED
|
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
69
|
var ts;
|
|
70
70
|
(function (ts) {
|
|
71
71
|
ts.versionMajorMinor = "4.7";
|
|
72
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
72
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220329";
|
|
73
73
|
var NativeCollections;
|
|
74
74
|
(function (NativeCollections) {
|
|
75
75
|
var globals = typeof globalThis !== "undefined" ? globalThis :
|
|
@@ -10092,7 +10092,9 @@ var ts;
|
|
|
10092
10092
|
|| kind === 174
|
|
10093
10093
|
|| kind === 166
|
|
10094
10094
|
|| kind === 168
|
|
10095
|
-
|| kind === 176
|
|
10095
|
+
|| kind === 176
|
|
10096
|
+
|| kind === 172
|
|
10097
|
+
|| kind === 173;
|
|
10096
10098
|
}
|
|
10097
10099
|
ts.isTypeElement = isTypeElement;
|
|
10098
10100
|
function isClassOrTypeElement(node) {
|
|
@@ -40140,6 +40142,10 @@ var ts;
|
|
|
40140
40142
|
}
|
|
40141
40143
|
}
|
|
40142
40144
|
}
|
|
40145
|
+
function isConstAssertion(location) {
|
|
40146
|
+
return (ts.isAssertionExpression(location) && ts.isConstTypeReference(location.type))
|
|
40147
|
+
|| (ts.isJSDocTypeTag(location) && ts.isConstTypeReference(location.typeExpression));
|
|
40148
|
+
}
|
|
40143
40149
|
function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSpellingSuggstions) {
|
|
40144
40150
|
if (excludeGlobals === void 0) { excludeGlobals = false; }
|
|
40145
40151
|
if (getSpellingSuggstions === void 0) { getSpellingSuggstions = true; }
|
|
@@ -40158,6 +40164,9 @@ var ts;
|
|
|
40158
40164
|
var grandparent;
|
|
40159
40165
|
var isInExternalModule = false;
|
|
40160
40166
|
loop: while (location) {
|
|
40167
|
+
if (name === "const" && isConstAssertion(location)) {
|
|
40168
|
+
return undefined;
|
|
40169
|
+
}
|
|
40161
40170
|
if (location.locals && !isGlobalSourceFile(location)) {
|
|
40162
40171
|
if (result = lookup(location.locals, name, meaning)) {
|
|
40163
40172
|
var useResult = true;
|
|
@@ -45282,6 +45291,8 @@ var ts;
|
|
|
45282
45291
|
return !!target.resolvedTypeArguments;
|
|
45283
45292
|
case 7:
|
|
45284
45293
|
return !!target.baseTypesResolved;
|
|
45294
|
+
case 8:
|
|
45295
|
+
return !!getSymbolLinks(target).writeType;
|
|
45285
45296
|
}
|
|
45286
45297
|
return ts.Debug.assertNever(propertyName);
|
|
45287
45298
|
}
|
|
@@ -46069,6 +46080,9 @@ var ts;
|
|
|
46069
46080
|
}
|
|
46070
46081
|
return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
|
|
46071
46082
|
}
|
|
46083
|
+
if (ts.isAccessor(declaration)) {
|
|
46084
|
+
return getTypeOfAccessors(symbol);
|
|
46085
|
+
}
|
|
46072
46086
|
if (!pushTypeResolution(symbol, 0)) {
|
|
46073
46087
|
if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
|
|
46074
46088
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
@@ -46127,9 +46141,6 @@ var ts;
|
|
|
46127
46141
|
else if (ts.isEnumMember(declaration)) {
|
|
46128
46142
|
type = getTypeOfEnumMember(symbol);
|
|
46129
46143
|
}
|
|
46130
|
-
else if (ts.isAccessor(declaration)) {
|
|
46131
|
-
type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type");
|
|
46132
|
-
}
|
|
46133
46144
|
else {
|
|
46134
46145
|
return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
|
|
46135
46146
|
}
|
|
@@ -46167,81 +46178,58 @@ var ts;
|
|
|
46167
46178
|
}
|
|
46168
46179
|
function getTypeOfAccessors(symbol) {
|
|
46169
46180
|
var links = getSymbolLinks(symbol);
|
|
46170
|
-
|
|
46171
|
-
|
|
46172
|
-
|
|
46173
|
-
|
|
46174
|
-
return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, true));
|
|
46175
|
-
}
|
|
46176
|
-
function getTypeOfAccessorsWorker(symbol, writing) {
|
|
46177
|
-
if (writing === void 0) { writing = false; }
|
|
46178
|
-
if (!pushTypeResolution(symbol, 0)) {
|
|
46179
|
-
return errorType;
|
|
46180
|
-
}
|
|
46181
|
-
var type = resolveTypeOfAccessors(symbol, writing);
|
|
46182
|
-
if (!popTypeResolution()) {
|
|
46181
|
+
if (!links.type) {
|
|
46182
|
+
if (!pushTypeResolution(symbol, 0)) {
|
|
46183
|
+
return errorType;
|
|
46184
|
+
}
|
|
46183
46185
|
var getter = ts.getDeclarationOfKind(symbol, 172);
|
|
46184
|
-
|
|
46185
|
-
|
|
46186
|
-
|
|
46186
|
+
var setter = ts.getDeclarationOfKind(symbol, 173);
|
|
46187
|
+
var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) ||
|
|
46188
|
+
getAnnotatedAccessorType(getter) ||
|
|
46189
|
+
getAnnotatedAccessorType(setter) ||
|
|
46190
|
+
getter && getter.body && getReturnTypeFromBody(getter);
|
|
46191
|
+
if (!type) {
|
|
46192
|
+
if (setter && !isPrivateWithinAmbient(setter)) {
|
|
46193
|
+
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
46194
|
+
}
|
|
46195
|
+
else if (getter && !isPrivateWithinAmbient(getter)) {
|
|
46196
|
+
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
46197
|
+
}
|
|
46198
|
+
type = anyType;
|
|
46199
|
+
}
|
|
46200
|
+
if (!popTypeResolution()) {
|
|
46201
|
+
if (getAnnotatedAccessorTypeNode(getter)) {
|
|
46202
|
+
error(getter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
46203
|
+
}
|
|
46204
|
+
else if (getAnnotatedAccessorTypeNode(setter)) {
|
|
46205
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
46187
46206
|
}
|
|
46188
|
-
else if (noImplicitAny) {
|
|
46207
|
+
else if (getter && noImplicitAny) {
|
|
46189
46208
|
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));
|
|
46190
46209
|
}
|
|
46210
|
+
type = anyType;
|
|
46191
46211
|
}
|
|
46192
|
-
type =
|
|
46212
|
+
links.type = type;
|
|
46193
46213
|
}
|
|
46194
|
-
return type;
|
|
46214
|
+
return links.type;
|
|
46195
46215
|
}
|
|
46196
|
-
function
|
|
46197
|
-
|
|
46198
|
-
|
|
46199
|
-
|
|
46200
|
-
|
|
46201
|
-
var setterType_1 = getAnnotatedAccessorType(setter);
|
|
46202
|
-
if (setterType_1) {
|
|
46203
|
-
return instantiateTypeIfNeeded(setterType_1, symbol);
|
|
46204
|
-
}
|
|
46205
|
-
}
|
|
46206
|
-
if (getter && ts.isInJSFile(getter)) {
|
|
46207
|
-
var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
|
|
46208
|
-
if (jsDocType) {
|
|
46209
|
-
return instantiateTypeIfNeeded(jsDocType, symbol);
|
|
46210
|
-
}
|
|
46211
|
-
}
|
|
46212
|
-
var getterType = getAnnotatedAccessorType(getter);
|
|
46213
|
-
if (getterType) {
|
|
46214
|
-
return instantiateTypeIfNeeded(getterType, symbol);
|
|
46215
|
-
}
|
|
46216
|
-
var setterType = getAnnotatedAccessorType(setter);
|
|
46217
|
-
if (setterType) {
|
|
46218
|
-
return setterType;
|
|
46219
|
-
}
|
|
46220
|
-
if (getter && getter.body) {
|
|
46221
|
-
var returnTypeFromBody = getReturnTypeFromBody(getter);
|
|
46222
|
-
return instantiateTypeIfNeeded(returnTypeFromBody, symbol);
|
|
46223
|
-
}
|
|
46224
|
-
if (setter) {
|
|
46225
|
-
if (!isPrivateWithinAmbient(setter)) {
|
|
46226
|
-
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
46227
|
-
}
|
|
46228
|
-
return anyType;
|
|
46229
|
-
}
|
|
46230
|
-
else if (getter) {
|
|
46231
|
-
ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
|
|
46232
|
-
if (!isPrivateWithinAmbient(getter)) {
|
|
46233
|
-
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
46216
|
+
function getWriteTypeOfAccessors(symbol) {
|
|
46217
|
+
var links = getSymbolLinks(symbol);
|
|
46218
|
+
if (!links.writeType) {
|
|
46219
|
+
if (!pushTypeResolution(symbol, 8)) {
|
|
46220
|
+
return errorType;
|
|
46234
46221
|
}
|
|
46235
|
-
|
|
46236
|
-
|
|
46237
|
-
|
|
46238
|
-
|
|
46239
|
-
|
|
46240
|
-
|
|
46241
|
-
|
|
46222
|
+
var setter = ts.getDeclarationOfKind(symbol, 173);
|
|
46223
|
+
var writeType = getAnnotatedAccessorType(setter);
|
|
46224
|
+
if (!popTypeResolution()) {
|
|
46225
|
+
if (getAnnotatedAccessorTypeNode(setter)) {
|
|
46226
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
46227
|
+
}
|
|
46228
|
+
writeType = anyType;
|
|
46242
46229
|
}
|
|
46243
|
-
|
|
46230
|
+
links.writeType = writeType || getTypeOfAccessors(symbol);
|
|
46244
46231
|
}
|
|
46232
|
+
return links.writeType;
|
|
46245
46233
|
}
|
|
46246
46234
|
function getBaseTypeVariableOfClass(symbol) {
|
|
46247
46235
|
var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
|
|
@@ -46317,17 +46305,11 @@ var ts;
|
|
|
46317
46305
|
}
|
|
46318
46306
|
function getTypeOfInstantiatedSymbol(symbol) {
|
|
46319
46307
|
var links = getSymbolLinks(symbol);
|
|
46320
|
-
|
|
46321
|
-
|
|
46322
|
-
|
|
46323
|
-
|
|
46324
|
-
|
|
46325
|
-
if (!popTypeResolution()) {
|
|
46326
|
-
type = reportCircularityError(symbol);
|
|
46327
|
-
}
|
|
46328
|
-
links.type = type;
|
|
46329
|
-
}
|
|
46330
|
-
return links.type;
|
|
46308
|
+
return links.type || (links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper));
|
|
46309
|
+
}
|
|
46310
|
+
function getWriteTypeOfInstantiatedSymbol(symbol) {
|
|
46311
|
+
var links = getSymbolLinks(symbol);
|
|
46312
|
+
return links.writeType || (links.writeType = instantiateType(getWriteTypeOfSymbol(links.target), links.mapper));
|
|
46331
46313
|
}
|
|
46332
46314
|
function reportCircularityError(symbol) {
|
|
46333
46315
|
var declaration = symbol.valueDeclaration;
|
|
@@ -46360,26 +46342,17 @@ var ts;
|
|
|
46360
46342
|
}
|
|
46361
46343
|
function getWriteTypeOfSymbol(symbol) {
|
|
46362
46344
|
var checkFlags = ts.getCheckFlags(symbol);
|
|
46363
|
-
if (
|
|
46364
|
-
|
|
46365
|
-
|
|
46366
|
-
|
|
46367
|
-
|
|
46345
|
+
if (symbol.flags & 4) {
|
|
46346
|
+
return checkFlags & 2 ?
|
|
46347
|
+
checkFlags & 65536 ?
|
|
46348
|
+
getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
|
|
46349
|
+
symbol.writeType || symbol.type :
|
|
46350
|
+
getTypeOfSymbol(symbol);
|
|
46368
46351
|
}
|
|
46369
|
-
if (symbol.flags & 33554432) {
|
|
46370
|
-
var writeType = symbol.writeType;
|
|
46371
|
-
if (writeType) {
|
|
46372
|
-
return writeType;
|
|
46373
|
-
}
|
|
46374
|
-
}
|
|
46375
|
-
return getSetAccessorTypeOfSymbol(symbol);
|
|
46376
|
-
}
|
|
46377
|
-
function getSetAccessorTypeOfSymbol(symbol) {
|
|
46378
46352
|
if (symbol.flags & 98304) {
|
|
46379
|
-
|
|
46380
|
-
|
|
46381
|
-
|
|
46382
|
-
}
|
|
46353
|
+
return checkFlags & 1 ?
|
|
46354
|
+
getWriteTypeOfInstantiatedSymbol(symbol) :
|
|
46355
|
+
getWriteTypeOfAccessors(symbol);
|
|
46383
46356
|
}
|
|
46384
46357
|
return getTypeOfSymbol(symbol);
|
|
46385
46358
|
}
|
|
@@ -59024,7 +58997,7 @@ var ts;
|
|
|
59024
58997
|
}
|
|
59025
58998
|
}
|
|
59026
58999
|
if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) {
|
|
59027
|
-
return
|
|
59000
|
+
return getWriteTypeOfAccessors(location.parent.symbol);
|
|
59028
59001
|
}
|
|
59029
59002
|
return getNonMissingTypeOfSymbol(symbol);
|
|
59030
59003
|
}
|
|
@@ -68590,6 +68563,8 @@ var ts;
|
|
|
68590
68563
|
(condExpr.operatorToken.kind === 56 || condExpr.operatorToken.kind === 55)
|
|
68591
68564
|
? condExpr.right
|
|
68592
68565
|
: condExpr;
|
|
68566
|
+
if (ts.isModuleExportsAccessExpression(location))
|
|
68567
|
+
return;
|
|
68593
68568
|
var type = checkTruthinessExpression(location);
|
|
68594
68569
|
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
68595
68570
|
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220329";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -13412,7 +13412,9 @@ var ts;
|
|
|
13412
13412
|
|| kind === 174 /* CallSignature */
|
|
13413
13413
|
|| kind === 166 /* PropertySignature */
|
|
13414
13414
|
|| kind === 168 /* MethodSignature */
|
|
13415
|
-
|| kind === 176 /* IndexSignature
|
|
13415
|
+
|| kind === 176 /* IndexSignature */
|
|
13416
|
+
|| kind === 172 /* GetAccessor */
|
|
13417
|
+
|| kind === 173 /* SetAccessor */;
|
|
13416
13418
|
}
|
|
13417
13419
|
ts.isTypeElement = isTypeElement;
|
|
13418
13420
|
function isClassOrTypeElement(node) {
|
|
@@ -47394,6 +47396,7 @@ var ts;
|
|
|
47394
47396
|
TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType";
|
|
47395
47397
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 6] = "ResolvedTypeArguments";
|
|
47396
47398
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseTypes"] = 7] = "ResolvedBaseTypes";
|
|
47399
|
+
TypeSystemPropertyName[TypeSystemPropertyName["WriteType"] = 8] = "WriteType";
|
|
47397
47400
|
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
|
|
47398
47401
|
var CheckMode;
|
|
47399
47402
|
(function (CheckMode) {
|
|
@@ -48908,6 +48911,10 @@ var ts;
|
|
|
48908
48911
|
}
|
|
48909
48912
|
}
|
|
48910
48913
|
}
|
|
48914
|
+
function isConstAssertion(location) {
|
|
48915
|
+
return (ts.isAssertionExpression(location) && ts.isConstTypeReference(location.type))
|
|
48916
|
+
|| (ts.isJSDocTypeTag(location) && ts.isConstTypeReference(location.typeExpression));
|
|
48917
|
+
}
|
|
48911
48918
|
/**
|
|
48912
48919
|
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
|
48913
48920
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
@@ -48933,6 +48940,11 @@ var ts;
|
|
|
48933
48940
|
var grandparent;
|
|
48934
48941
|
var isInExternalModule = false;
|
|
48935
48942
|
loop: while (location) {
|
|
48943
|
+
if (name === "const" && isConstAssertion(location)) {
|
|
48944
|
+
// `const` in an `as const` has no symbol, but issues no error because there is no *actual* lookup of the type
|
|
48945
|
+
// (it refers to the constant type of the expression instead)
|
|
48946
|
+
return undefined;
|
|
48947
|
+
}
|
|
48936
48948
|
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
|
48937
48949
|
if (location.locals && !isGlobalSourceFile(location)) {
|
|
48938
48950
|
if (result = lookup(location.locals, name, meaning)) {
|
|
@@ -54881,6 +54893,8 @@ var ts;
|
|
|
54881
54893
|
return !!target.resolvedTypeArguments;
|
|
54882
54894
|
case 7 /* ResolvedBaseTypes */:
|
|
54883
54895
|
return !!target.baseTypesResolved;
|
|
54896
|
+
case 8 /* WriteType */:
|
|
54897
|
+
return !!getSymbolLinks(target).writeType;
|
|
54884
54898
|
}
|
|
54885
54899
|
return ts.Debug.assertNever(propertyName);
|
|
54886
54900
|
}
|
|
@@ -55798,6 +55812,11 @@ var ts;
|
|
|
55798
55812
|
}
|
|
55799
55813
|
return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
|
|
55800
55814
|
}
|
|
55815
|
+
if (ts.isAccessor(declaration)) {
|
|
55816
|
+
// Binding of certain patterns in JS code will occasionally mark symbols as both properties
|
|
55817
|
+
// and accessors. Here we dispatch to accessor resolution if needed.
|
|
55818
|
+
return getTypeOfAccessors(symbol);
|
|
55819
|
+
}
|
|
55801
55820
|
// Handle variable, parameter or property
|
|
55802
55821
|
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55803
55822
|
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
|
@@ -55861,9 +55880,6 @@ var ts;
|
|
|
55861
55880
|
else if (ts.isEnumMember(declaration)) {
|
|
55862
55881
|
type = getTypeOfEnumMember(symbol);
|
|
55863
55882
|
}
|
|
55864
|
-
else if (ts.isAccessor(declaration)) {
|
|
55865
|
-
type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type");
|
|
55866
|
-
}
|
|
55867
55883
|
else {
|
|
55868
55884
|
return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
|
|
55869
55885
|
}
|
|
@@ -55902,87 +55918,61 @@ var ts;
|
|
|
55902
55918
|
}
|
|
55903
55919
|
function getTypeOfAccessors(symbol) {
|
|
55904
55920
|
var links = getSymbolLinks(symbol);
|
|
55905
|
-
|
|
55906
|
-
|
|
55907
|
-
|
|
55908
|
-
|
|
55909
|
-
return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true));
|
|
55910
|
-
}
|
|
55911
|
-
function getTypeOfAccessorsWorker(symbol, writing) {
|
|
55912
|
-
if (writing === void 0) { writing = false; }
|
|
55913
|
-
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55914
|
-
return errorType;
|
|
55915
|
-
}
|
|
55916
|
-
var type = resolveTypeOfAccessors(symbol, writing);
|
|
55917
|
-
if (!popTypeResolution()) {
|
|
55921
|
+
if (!links.type) {
|
|
55922
|
+
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55923
|
+
return errorType;
|
|
55924
|
+
}
|
|
55918
55925
|
var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */);
|
|
55919
|
-
|
|
55920
|
-
|
|
55921
|
-
|
|
55926
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
55927
|
+
// We try to resolve a getter type annotation, a setter type annotation, or a getter function
|
|
55928
|
+
// body return type inference, in that order.
|
|
55929
|
+
var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) ||
|
|
55930
|
+
getAnnotatedAccessorType(getter) ||
|
|
55931
|
+
getAnnotatedAccessorType(setter) ||
|
|
55932
|
+
getter && getter.body && getReturnTypeFromBody(getter);
|
|
55933
|
+
if (!type) {
|
|
55934
|
+
if (setter && !isPrivateWithinAmbient(setter)) {
|
|
55935
|
+
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
55936
|
+
}
|
|
55937
|
+
else if (getter && !isPrivateWithinAmbient(getter)) {
|
|
55938
|
+
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
55939
|
+
}
|
|
55940
|
+
type = anyType;
|
|
55941
|
+
}
|
|
55942
|
+
if (!popTypeResolution()) {
|
|
55943
|
+
if (getAnnotatedAccessorTypeNode(getter)) {
|
|
55944
|
+
error(getter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55945
|
+
}
|
|
55946
|
+
else if (getAnnotatedAccessorTypeNode(setter)) {
|
|
55947
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55922
55948
|
}
|
|
55923
|
-
else if (noImplicitAny) {
|
|
55949
|
+
else if (getter && noImplicitAny) {
|
|
55924
55950
|
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));
|
|
55925
55951
|
}
|
|
55952
|
+
type = anyType;
|
|
55926
55953
|
}
|
|
55927
|
-
type =
|
|
55954
|
+
links.type = type;
|
|
55928
55955
|
}
|
|
55929
|
-
return type;
|
|
55956
|
+
return links.type;
|
|
55930
55957
|
}
|
|
55931
|
-
function
|
|
55932
|
-
|
|
55933
|
-
|
|
55934
|
-
|
|
55935
|
-
|
|
55936
|
-
if (writing) {
|
|
55937
|
-
var setterType_1 = getAnnotatedAccessorType(setter);
|
|
55938
|
-
if (setterType_1) {
|
|
55939
|
-
return instantiateTypeIfNeeded(setterType_1, symbol);
|
|
55940
|
-
}
|
|
55941
|
-
}
|
|
55942
|
-
// Else defer to the getter type
|
|
55943
|
-
if (getter && ts.isInJSFile(getter)) {
|
|
55944
|
-
var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
|
|
55945
|
-
if (jsDocType) {
|
|
55946
|
-
return instantiateTypeIfNeeded(jsDocType, symbol);
|
|
55947
|
-
}
|
|
55948
|
-
}
|
|
55949
|
-
// Try to see if the user specified a return type on the get-accessor.
|
|
55950
|
-
var getterType = getAnnotatedAccessorType(getter);
|
|
55951
|
-
if (getterType) {
|
|
55952
|
-
return instantiateTypeIfNeeded(getterType, symbol);
|
|
55953
|
-
}
|
|
55954
|
-
// If the user didn't specify a return type, try to use the set-accessor's parameter type.
|
|
55955
|
-
var setterType = getAnnotatedAccessorType(setter);
|
|
55956
|
-
if (setterType) {
|
|
55957
|
-
return setterType;
|
|
55958
|
-
}
|
|
55959
|
-
// If there are no specified types, try to infer it from the body of the get accessor if it exists.
|
|
55960
|
-
if (getter && getter.body) {
|
|
55961
|
-
var returnTypeFromBody = getReturnTypeFromBody(getter);
|
|
55962
|
-
return instantiateTypeIfNeeded(returnTypeFromBody, symbol);
|
|
55963
|
-
}
|
|
55964
|
-
// Otherwise, fall back to 'any'.
|
|
55965
|
-
if (setter) {
|
|
55966
|
-
if (!isPrivateWithinAmbient(setter)) {
|
|
55967
|
-
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
55968
|
-
}
|
|
55969
|
-
return anyType;
|
|
55970
|
-
}
|
|
55971
|
-
else if (getter) {
|
|
55972
|
-
ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
|
|
55973
|
-
if (!isPrivateWithinAmbient(getter)) {
|
|
55974
|
-
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
55958
|
+
function getWriteTypeOfAccessors(symbol) {
|
|
55959
|
+
var links = getSymbolLinks(symbol);
|
|
55960
|
+
if (!links.writeType) {
|
|
55961
|
+
if (!pushTypeResolution(symbol, 8 /* WriteType */)) {
|
|
55962
|
+
return errorType;
|
|
55975
55963
|
}
|
|
55976
|
-
|
|
55977
|
-
|
|
55978
|
-
|
|
55979
|
-
|
|
55980
|
-
|
|
55981
|
-
|
|
55982
|
-
|
|
55964
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
55965
|
+
var writeType = getAnnotatedAccessorType(setter);
|
|
55966
|
+
if (!popTypeResolution()) {
|
|
55967
|
+
if (getAnnotatedAccessorTypeNode(setter)) {
|
|
55968
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55969
|
+
}
|
|
55970
|
+
writeType = anyType;
|
|
55983
55971
|
}
|
|
55984
|
-
|
|
55972
|
+
// Absent an explicit setter type annotation we use the read type of the accessor.
|
|
55973
|
+
links.writeType = writeType || getTypeOfAccessors(symbol);
|
|
55985
55974
|
}
|
|
55975
|
+
return links.writeType;
|
|
55986
55976
|
}
|
|
55987
55977
|
function getBaseTypeVariableOfClass(symbol) {
|
|
55988
55978
|
var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
|
|
@@ -56064,17 +56054,11 @@ var ts;
|
|
|
56064
56054
|
}
|
|
56065
56055
|
function getTypeOfInstantiatedSymbol(symbol) {
|
|
56066
56056
|
var links = getSymbolLinks(symbol);
|
|
56067
|
-
|
|
56068
|
-
|
|
56069
|
-
|
|
56070
|
-
|
|
56071
|
-
|
|
56072
|
-
if (!popTypeResolution()) {
|
|
56073
|
-
type = reportCircularityError(symbol);
|
|
56074
|
-
}
|
|
56075
|
-
links.type = type;
|
|
56076
|
-
}
|
|
56077
|
-
return links.type;
|
|
56057
|
+
return links.type || (links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper));
|
|
56058
|
+
}
|
|
56059
|
+
function getWriteTypeOfInstantiatedSymbol(symbol) {
|
|
56060
|
+
var links = getSymbolLinks(symbol);
|
|
56061
|
+
return links.writeType || (links.writeType = instantiateType(getWriteTypeOfSymbol(links.target), links.mapper));
|
|
56078
56062
|
}
|
|
56079
56063
|
function reportCircularityError(symbol) {
|
|
56080
56064
|
var declaration = symbol.valueDeclaration;
|
|
@@ -56111,35 +56095,23 @@ var ts;
|
|
|
56111
56095
|
return links.writeType;
|
|
56112
56096
|
}
|
|
56113
56097
|
/**
|
|
56114
|
-
* Distinct write types come only from set accessors, but union and intersection
|
|
56115
|
-
* properties deriving from set accessors will either pre-compute or defer the
|
|
56116
|
-
*
|
|
56117
|
-
* this, we will assume that any deferred type or transient symbol may have a
|
|
56118
|
-
* `writeType` (or a deferred write type ready to be computed) that should be
|
|
56119
|
-
* used before looking for set accessor declarations.
|
|
56098
|
+
* Distinct write types come only from set accessors, but synthetic union and intersection
|
|
56099
|
+
* properties deriving from set accessors will either pre-compute or defer the union or
|
|
56100
|
+
* intersection of the writeTypes of their constituents.
|
|
56120
56101
|
*/
|
|
56121
56102
|
function getWriteTypeOfSymbol(symbol) {
|
|
56122
56103
|
var checkFlags = ts.getCheckFlags(symbol);
|
|
56123
|
-
if (
|
|
56124
|
-
|
|
56125
|
-
|
|
56126
|
-
|
|
56127
|
-
|
|
56104
|
+
if (symbol.flags & 4 /* Property */) {
|
|
56105
|
+
return checkFlags & 2 /* SyntheticProperty */ ?
|
|
56106
|
+
checkFlags & 65536 /* DeferredType */ ?
|
|
56107
|
+
getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
|
|
56108
|
+
symbol.writeType || symbol.type :
|
|
56109
|
+
getTypeOfSymbol(symbol);
|
|
56128
56110
|
}
|
|
56129
|
-
if (symbol.flags & 33554432 /* Transient */) {
|
|
56130
|
-
var writeType = symbol.writeType;
|
|
56131
|
-
if (writeType) {
|
|
56132
|
-
return writeType;
|
|
56133
|
-
}
|
|
56134
|
-
}
|
|
56135
|
-
return getSetAccessorTypeOfSymbol(symbol);
|
|
56136
|
-
}
|
|
56137
|
-
function getSetAccessorTypeOfSymbol(symbol) {
|
|
56138
56111
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
56139
|
-
|
|
56140
|
-
|
|
56141
|
-
|
|
56142
|
-
}
|
|
56112
|
+
return checkFlags & 1 /* Instantiated */ ?
|
|
56113
|
+
getWriteTypeOfInstantiatedSymbol(symbol) :
|
|
56114
|
+
getWriteTypeOfAccessors(symbol);
|
|
56143
56115
|
}
|
|
56144
56116
|
return getTypeOfSymbol(symbol);
|
|
56145
56117
|
}
|
|
@@ -70610,7 +70582,7 @@ var ts;
|
|
|
70610
70582
|
}
|
|
70611
70583
|
}
|
|
70612
70584
|
if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) {
|
|
70613
|
-
return
|
|
70585
|
+
return getWriteTypeOfAccessors(location.parent.symbol);
|
|
70614
70586
|
}
|
|
70615
70587
|
// The location isn't a reference to the given symbol, meaning we're being asked
|
|
70616
70588
|
// a hypothetical question of what type the symbol would have if there was a reference
|
|
@@ -81813,6 +81785,8 @@ var ts;
|
|
|
81813
81785
|
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
81814
81786
|
? condExpr.right
|
|
81815
81787
|
: condExpr;
|
|
81788
|
+
if (ts.isModuleExportsAccessExpression(location))
|
|
81789
|
+
return;
|
|
81816
81790
|
var type = checkTruthinessExpression(location);
|
|
81817
81791
|
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
81818
81792
|
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
|
@@ -126073,12 +126047,8 @@ var ts;
|
|
|
126073
126047
|
}
|
|
126074
126048
|
}
|
|
126075
126049
|
ts.findNextToken = findNextToken;
|
|
126076
|
-
/**
|
|
126077
|
-
* Finds the rightmost token satisfying `token.end <= position`,
|
|
126078
|
-
* excluding `JsxText` tokens containing only whitespace.
|
|
126079
|
-
*/
|
|
126080
126050
|
function findPrecedingToken(position, sourceFile, startNode, excludeJsdoc) {
|
|
126081
|
-
var result = find(startNode || sourceFile);
|
|
126051
|
+
var result = find((startNode || sourceFile));
|
|
126082
126052
|
ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result)));
|
|
126083
126053
|
return result;
|
|
126084
126054
|
function find(n) {
|
|
@@ -145336,6 +145306,7 @@ var ts;
|
|
|
145336
145306
|
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); });
|
|
145337
145307
|
}
|
|
145338
145308
|
function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) {
|
|
145309
|
+
var _b;
|
|
145339
145310
|
var options = _a.options, getRules = _a.getRules, host = _a.host;
|
|
145340
145311
|
// formatting context is used by rules provider
|
|
145341
145312
|
var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options);
|
|
@@ -145367,11 +145338,12 @@ var ts;
|
|
|
145367
145338
|
}
|
|
145368
145339
|
}
|
|
145369
145340
|
if (previousRange && formattingScanner.getStartPos() >= originalRange.end) {
|
|
145370
|
-
var
|
|
145341
|
+
var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() :
|
|
145371
145342
|
formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token :
|
|
145372
145343
|
undefined;
|
|
145373
|
-
if (
|
|
145374
|
-
|
|
145344
|
+
if (tokenInfo) {
|
|
145345
|
+
var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent;
|
|
145346
|
+
processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent,
|
|
145375
145347
|
/*dynamicIndentation*/ undefined);
|
|
145376
145348
|
}
|
|
145377
145349
|
}
|