typescript 4.7.0-dev.20220328 → 4.7.0-dev.20220331
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/protocol.d.ts +30 -0
- package/lib/tsc.js +163 -139
- package/lib/tsserver.js +618 -351
- package/lib/tsserverlibrary.d.ts +38 -0
- package/lib/tsserverlibrary.js +618 -351
- package/lib/typescript.d.ts +8 -0
- package/lib/typescript.js +600 -349
- package/lib/typescriptServices.d.ts +8 -0
- package/lib/typescriptServices.js +600 -349
- package/lib/typingsInstaller.js +181 -153
- package/package.json +1 -1
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.20220331";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -9484,6 +9484,7 @@ var ts;
|
|
|
9484
9484
|
An_expanded_version_of_this_information_showing_all_possible_compiler_options: diag(6928, ts.DiagnosticCategory.Message, "An_expanded_version_of_this_information_showing_all_possible_compiler_options_6928", "An expanded version of this information, showing all possible compiler options"),
|
|
9485
9485
|
Compiles_the_current_project_with_additional_settings: diag(6929, ts.DiagnosticCategory.Message, "Compiles_the_current_project_with_additional_settings_6929", "Compiles the current project, with additional settings."),
|
|
9486
9486
|
true_for_ES2022_and_above_including_ESNext: diag(6930, ts.DiagnosticCategory.Message, "true_for_ES2022_and_above_including_ESNext_6930", "`true` for ES2022 and above, including ESNext."),
|
|
9487
|
+
List_of_file_name_suffixes_to_search_when_resolving_a_module: diag(6931, ts.DiagnosticCategory.Error, "List_of_file_name_suffixes_to_search_when_resolving_a_module_6931", "List of file name suffixes to search when resolving a module."),
|
|
9487
9488
|
Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."),
|
|
9488
9489
|
Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."),
|
|
9489
9490
|
Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."),
|
|
@@ -13401,7 +13402,9 @@ var ts;
|
|
|
13401
13402
|
|| kind === 174 /* CallSignature */
|
|
13402
13403
|
|| kind === 166 /* PropertySignature */
|
|
13403
13404
|
|| kind === 168 /* MethodSignature */
|
|
13404
|
-
|| kind === 176 /* IndexSignature
|
|
13405
|
+
|| kind === 176 /* IndexSignature */
|
|
13406
|
+
|| kind === 172 /* GetAccessor */
|
|
13407
|
+
|| kind === 173 /* SetAccessor */;
|
|
13405
13408
|
}
|
|
13406
13409
|
ts.isTypeElement = isTypeElement;
|
|
13407
13410
|
function isClassOrTypeElement(node) {
|
|
@@ -39476,6 +39479,18 @@ var ts;
|
|
|
39476
39479
|
description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
|
|
39477
39480
|
defaultValueDescription: false,
|
|
39478
39481
|
},
|
|
39482
|
+
{
|
|
39483
|
+
name: "moduleSuffixes",
|
|
39484
|
+
type: "list",
|
|
39485
|
+
element: {
|
|
39486
|
+
name: "suffix",
|
|
39487
|
+
type: "string",
|
|
39488
|
+
},
|
|
39489
|
+
listPreserveFalsyValues: true,
|
|
39490
|
+
affectsModuleResolution: true,
|
|
39491
|
+
category: ts.Diagnostics.Modules,
|
|
39492
|
+
description: ts.Diagnostics.List_of_file_name_suffixes_to_search_when_resolving_a_module,
|
|
39493
|
+
},
|
|
39479
39494
|
// Source Maps
|
|
39480
39495
|
{
|
|
39481
39496
|
name: "sourceRoot",
|
|
@@ -41402,7 +41417,7 @@ var ts;
|
|
|
41402
41417
|
if (option.type === "list") {
|
|
41403
41418
|
var listOption_1 = option;
|
|
41404
41419
|
if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
|
|
41405
|
-
return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
|
|
41420
|
+
return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return listOption_1.listPreserveFalsyValues ? true : !!v; });
|
|
41406
41421
|
}
|
|
41407
41422
|
return value;
|
|
41408
41423
|
}
|
|
@@ -41443,7 +41458,7 @@ var ts;
|
|
|
41443
41458
|
}
|
|
41444
41459
|
}
|
|
41445
41460
|
function convertJsonOptionOfListType(option, values, basePath, errors) {
|
|
41446
|
-
return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
|
|
41461
|
+
return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return option.listPreserveFalsyValues ? true : !!v; });
|
|
41447
41462
|
}
|
|
41448
41463
|
/**
|
|
41449
41464
|
* Tests for a path that ends in a recursive directory wildcard.
|
|
@@ -43069,6 +43084,15 @@ var ts;
|
|
|
43069
43084
|
}
|
|
43070
43085
|
/** Return the file if it exists. */
|
|
43071
43086
|
function tryFile(fileName, onlyRecordFailures, state) {
|
|
43087
|
+
var _a, _b;
|
|
43088
|
+
if (!((_a = state.compilerOptions.moduleSuffixes) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
43089
|
+
return tryFileLookup(fileName, onlyRecordFailures, state);
|
|
43090
|
+
}
|
|
43091
|
+
var ext = (_b = ts.tryGetExtensionFromPath(fileName)) !== null && _b !== void 0 ? _b : "";
|
|
43092
|
+
var fileNameNoExtension = ext ? ts.removeExtension(fileName, ext) : fileName;
|
|
43093
|
+
return ts.forEach(state.compilerOptions.moduleSuffixes, function (suffix) { return tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state); });
|
|
43094
|
+
}
|
|
43095
|
+
function tryFileLookup(fileName, onlyRecordFailures, state) {
|
|
43072
43096
|
if (!onlyRecordFailures) {
|
|
43073
43097
|
if (state.host.fileExists(fileName)) {
|
|
43074
43098
|
if (state.traceEnabled) {
|
|
@@ -47383,6 +47407,7 @@ var ts;
|
|
|
47383
47407
|
TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType";
|
|
47384
47408
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 6] = "ResolvedTypeArguments";
|
|
47385
47409
|
TypeSystemPropertyName[TypeSystemPropertyName["ResolvedBaseTypes"] = 7] = "ResolvedBaseTypes";
|
|
47410
|
+
TypeSystemPropertyName[TypeSystemPropertyName["WriteType"] = 8] = "WriteType";
|
|
47386
47411
|
})(TypeSystemPropertyName || (TypeSystemPropertyName = {}));
|
|
47387
47412
|
var CheckMode;
|
|
47388
47413
|
(function (CheckMode) {
|
|
@@ -47392,7 +47417,8 @@ var ts;
|
|
|
47392
47417
|
CheckMode[CheckMode["SkipContextSensitive"] = 4] = "SkipContextSensitive";
|
|
47393
47418
|
CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions";
|
|
47394
47419
|
CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp";
|
|
47395
|
-
CheckMode[CheckMode["
|
|
47420
|
+
CheckMode[CheckMode["IsForStringLiteralArgumentCompletions"] = 32] = "IsForStringLiteralArgumentCompletions";
|
|
47421
|
+
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
47396
47422
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
47397
47423
|
// we need to preserve generic types instead of substituting them for constraints
|
|
47398
47424
|
})(CheckMode || (CheckMode = {}));
|
|
@@ -47730,26 +47756,10 @@ var ts;
|
|
|
47730
47756
|
if (!node) {
|
|
47731
47757
|
return undefined;
|
|
47732
47758
|
}
|
|
47733
|
-
|
|
47734
|
-
|
|
47735
|
-
if (contextFlags & 4 /* Completions */ && containingCall) {
|
|
47736
|
-
var toMarkSkip = node;
|
|
47737
|
-
do {
|
|
47738
|
-
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
47739
|
-
toMarkSkip = toMarkSkip.parent;
|
|
47740
|
-
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47741
|
-
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
47742
|
-
}
|
|
47743
|
-
var result = getContextualType(node, contextFlags);
|
|
47744
|
-
if (contextFlags & 4 /* Completions */ && containingCall) {
|
|
47745
|
-
var toMarkSkip = node;
|
|
47746
|
-
do {
|
|
47747
|
-
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
47748
|
-
toMarkSkip = toMarkSkip.parent;
|
|
47749
|
-
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47750
|
-
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
47759
|
+
if (contextFlags & 4 /* Completions */) {
|
|
47760
|
+
return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); });
|
|
47751
47761
|
}
|
|
47752
|
-
return
|
|
47762
|
+
return getContextualType(node, contextFlags);
|
|
47753
47763
|
},
|
|
47754
47764
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
47755
47765
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
@@ -47769,6 +47779,9 @@ var ts;
|
|
|
47769
47779
|
getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
|
|
47770
47780
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */);
|
|
47771
47781
|
},
|
|
47782
|
+
getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) {
|
|
47783
|
+
return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument);
|
|
47784
|
+
},
|
|
47772
47785
|
getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
|
|
47773
47786
|
return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */);
|
|
47774
47787
|
},
|
|
@@ -47921,10 +47934,34 @@ var ts;
|
|
|
47921
47934
|
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
47922
47935
|
getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
|
|
47923
47936
|
};
|
|
47924
|
-
function
|
|
47937
|
+
function runWithInferenceBlockedFromSourceNode(node, fn) {
|
|
47938
|
+
var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
|
|
47939
|
+
var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
|
|
47940
|
+
if (containingCall) {
|
|
47941
|
+
var toMarkSkip = node;
|
|
47942
|
+
do {
|
|
47943
|
+
getNodeLinks(toMarkSkip).skipDirectInference = true;
|
|
47944
|
+
toMarkSkip = toMarkSkip.parent;
|
|
47945
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47946
|
+
getNodeLinks(containingCall).resolvedSignature = undefined;
|
|
47947
|
+
}
|
|
47948
|
+
var result = fn();
|
|
47949
|
+
if (containingCall) {
|
|
47950
|
+
var toMarkSkip = node;
|
|
47951
|
+
do {
|
|
47952
|
+
getNodeLinks(toMarkSkip).skipDirectInference = undefined;
|
|
47953
|
+
toMarkSkip = toMarkSkip.parent;
|
|
47954
|
+
} while (toMarkSkip && toMarkSkip !== containingCall);
|
|
47955
|
+
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
|
47956
|
+
}
|
|
47957
|
+
return result;
|
|
47958
|
+
}
|
|
47959
|
+
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode, editingArgument) {
|
|
47925
47960
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
47926
47961
|
apparentArgumentCount = argumentCount;
|
|
47927
|
-
var res = node ?
|
|
47962
|
+
var res = !node ? undefined :
|
|
47963
|
+
editingArgument ? runWithInferenceBlockedFromSourceNode(editingArgument, function () { return getResolvedSignature(node, candidatesOutArray, checkMode); }) :
|
|
47964
|
+
getResolvedSignature(node, candidatesOutArray, checkMode);
|
|
47928
47965
|
apparentArgumentCount = undefined;
|
|
47929
47966
|
return res;
|
|
47930
47967
|
}
|
|
@@ -48897,6 +48934,10 @@ var ts;
|
|
|
48897
48934
|
}
|
|
48898
48935
|
}
|
|
48899
48936
|
}
|
|
48937
|
+
function isConstAssertion(location) {
|
|
48938
|
+
return (ts.isAssertionExpression(location) && ts.isConstTypeReference(location.type))
|
|
48939
|
+
|| (ts.isJSDocTypeTag(location) && ts.isConstTypeReference(location.typeExpression));
|
|
48940
|
+
}
|
|
48900
48941
|
/**
|
|
48901
48942
|
* Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
|
48902
48943
|
* the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
|
@@ -48922,6 +48963,11 @@ var ts;
|
|
|
48922
48963
|
var grandparent;
|
|
48923
48964
|
var isInExternalModule = false;
|
|
48924
48965
|
loop: while (location) {
|
|
48966
|
+
if (name === "const" && isConstAssertion(location)) {
|
|
48967
|
+
// `const` in an `as const` has no symbol, but issues no error because there is no *actual* lookup of the type
|
|
48968
|
+
// (it refers to the constant type of the expression instead)
|
|
48969
|
+
return undefined;
|
|
48970
|
+
}
|
|
48925
48971
|
// Locals of a source file are not in scope (because they get merged into the global symbol table)
|
|
48926
48972
|
if (location.locals && !isGlobalSourceFile(location)) {
|
|
48927
48973
|
if (result = lookup(location.locals, name, meaning)) {
|
|
@@ -52042,7 +52088,15 @@ var ts;
|
|
|
52042
52088
|
if (!ts.nodeIsSynthesized(node) && ts.getParseTreeNode(node) === node) {
|
|
52043
52089
|
return node;
|
|
52044
52090
|
}
|
|
52045
|
-
return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext)), node);
|
|
52091
|
+
return ts.setTextRange(ts.factory.cloneNode(ts.visitEachChild(node, deepCloneOrReuseNode, ts.nullTransformationContext, deepCloneOrReuseNodes)), node);
|
|
52092
|
+
}
|
|
52093
|
+
function deepCloneOrReuseNodes(nodes, visitor, test, start, count) {
|
|
52094
|
+
if (nodes && nodes.length === 0) {
|
|
52095
|
+
// Ensure we explicitly make a copy of an empty array; visitNodes will not do this unless the array has elements,
|
|
52096
|
+
// which can lead to us reusing the same empty NodeArray more than once within the same AST during type noding.
|
|
52097
|
+
return ts.setTextRange(ts.factory.createNodeArray(/*nodes*/ undefined, nodes.hasTrailingComma), nodes);
|
|
52098
|
+
}
|
|
52099
|
+
return ts.visitNodes(nodes, visitor, test, start, count);
|
|
52046
52100
|
}
|
|
52047
52101
|
}
|
|
52048
52102
|
function createTypeNodeFromObjectType(type) {
|
|
@@ -54870,6 +54924,8 @@ var ts;
|
|
|
54870
54924
|
return !!target.resolvedTypeArguments;
|
|
54871
54925
|
case 7 /* ResolvedBaseTypes */:
|
|
54872
54926
|
return !!target.baseTypesResolved;
|
|
54927
|
+
case 8 /* WriteType */:
|
|
54928
|
+
return !!getSymbolLinks(target).writeType;
|
|
54873
54929
|
}
|
|
54874
54930
|
return ts.Debug.assertNever(propertyName);
|
|
54875
54931
|
}
|
|
@@ -55047,7 +55103,7 @@ var ts;
|
|
|
55047
55103
|
}
|
|
55048
55104
|
/** Return the inferred type for a binding element */
|
|
55049
55105
|
function getTypeForBindingElement(declaration) {
|
|
55050
|
-
var checkMode = declaration.dotDotDotToken ?
|
|
55106
|
+
var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
55051
55107
|
var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode);
|
|
55052
55108
|
return parentType && getBindingElementTypeFromParentType(declaration, parentType);
|
|
55053
55109
|
}
|
|
@@ -55787,6 +55843,11 @@ var ts;
|
|
|
55787
55843
|
}
|
|
55788
55844
|
return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
|
|
55789
55845
|
}
|
|
55846
|
+
if (ts.isAccessor(declaration)) {
|
|
55847
|
+
// Binding of certain patterns in JS code will occasionally mark symbols as both properties
|
|
55848
|
+
// and accessors. Here we dispatch to accessor resolution if needed.
|
|
55849
|
+
return getTypeOfAccessors(symbol);
|
|
55850
|
+
}
|
|
55790
55851
|
// Handle variable, parameter or property
|
|
55791
55852
|
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55792
55853
|
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
|
@@ -55850,9 +55911,6 @@ var ts;
|
|
|
55850
55911
|
else if (ts.isEnumMember(declaration)) {
|
|
55851
55912
|
type = getTypeOfEnumMember(symbol);
|
|
55852
55913
|
}
|
|
55853
|
-
else if (ts.isAccessor(declaration)) {
|
|
55854
|
-
type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type");
|
|
55855
|
-
}
|
|
55856
55914
|
else {
|
|
55857
55915
|
return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
|
|
55858
55916
|
}
|
|
@@ -55891,87 +55949,61 @@ var ts;
|
|
|
55891
55949
|
}
|
|
55892
55950
|
function getTypeOfAccessors(symbol) {
|
|
55893
55951
|
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()) {
|
|
55952
|
+
if (!links.type) {
|
|
55953
|
+
if (!pushTypeResolution(symbol, 0 /* Type */)) {
|
|
55954
|
+
return errorType;
|
|
55955
|
+
}
|
|
55907
55956
|
var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */);
|
|
55908
|
-
|
|
55909
|
-
|
|
55910
|
-
|
|
55957
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
55958
|
+
// We try to resolve a getter type annotation, a setter type annotation, or a getter function
|
|
55959
|
+
// body return type inference, in that order.
|
|
55960
|
+
var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) ||
|
|
55961
|
+
getAnnotatedAccessorType(getter) ||
|
|
55962
|
+
getAnnotatedAccessorType(setter) ||
|
|
55963
|
+
getter && getter.body && getReturnTypeFromBody(getter);
|
|
55964
|
+
if (!type) {
|
|
55965
|
+
if (setter && !isPrivateWithinAmbient(setter)) {
|
|
55966
|
+
errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
|
55967
|
+
}
|
|
55968
|
+
else if (getter && !isPrivateWithinAmbient(getter)) {
|
|
55969
|
+
errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
|
55911
55970
|
}
|
|
55912
|
-
|
|
55971
|
+
type = anyType;
|
|
55972
|
+
}
|
|
55973
|
+
if (!popTypeResolution()) {
|
|
55974
|
+
if (getAnnotatedAccessorTypeNode(getter)) {
|
|
55975
|
+
error(getter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55976
|
+
}
|
|
55977
|
+
else if (getAnnotatedAccessorTypeNode(setter)) {
|
|
55978
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
55979
|
+
}
|
|
55980
|
+
else if (getter && noImplicitAny) {
|
|
55913
55981
|
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
55982
|
}
|
|
55983
|
+
type = anyType;
|
|
55915
55984
|
}
|
|
55916
|
-
type =
|
|
55985
|
+
links.type = type;
|
|
55917
55986
|
}
|
|
55918
|
-
return type;
|
|
55987
|
+
return links.type;
|
|
55919
55988
|
}
|
|
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));
|
|
55989
|
+
function getWriteTypeOfAccessors(symbol) {
|
|
55990
|
+
var links = getSymbolLinks(symbol);
|
|
55991
|
+
if (!links.writeType) {
|
|
55992
|
+
if (!pushTypeResolution(symbol, 8 /* WriteType */)) {
|
|
55993
|
+
return errorType;
|
|
55964
55994
|
}
|
|
55965
|
-
|
|
55966
|
-
|
|
55967
|
-
|
|
55968
|
-
|
|
55969
|
-
|
|
55970
|
-
|
|
55971
|
-
|
|
55995
|
+
var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */);
|
|
55996
|
+
var writeType = getAnnotatedAccessorType(setter);
|
|
55997
|
+
if (!popTypeResolution()) {
|
|
55998
|
+
if (getAnnotatedAccessorTypeNode(setter)) {
|
|
55999
|
+
error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
|
|
56000
|
+
}
|
|
56001
|
+
writeType = anyType;
|
|
55972
56002
|
}
|
|
55973
|
-
|
|
56003
|
+
// Absent an explicit setter type annotation we use the read type of the accessor.
|
|
56004
|
+
links.writeType = writeType || getTypeOfAccessors(symbol);
|
|
55974
56005
|
}
|
|
56006
|
+
return links.writeType;
|
|
55975
56007
|
}
|
|
55976
56008
|
function getBaseTypeVariableOfClass(symbol) {
|
|
55977
56009
|
var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
|
|
@@ -56053,17 +56085,11 @@ var ts;
|
|
|
56053
56085
|
}
|
|
56054
56086
|
function getTypeOfInstantiatedSymbol(symbol) {
|
|
56055
56087
|
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;
|
|
56088
|
+
return links.type || (links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper));
|
|
56089
|
+
}
|
|
56090
|
+
function getWriteTypeOfInstantiatedSymbol(symbol) {
|
|
56091
|
+
var links = getSymbolLinks(symbol);
|
|
56092
|
+
return links.writeType || (links.writeType = instantiateType(getWriteTypeOfSymbol(links.target), links.mapper));
|
|
56067
56093
|
}
|
|
56068
56094
|
function reportCircularityError(symbol) {
|
|
56069
56095
|
var declaration = symbol.valueDeclaration;
|
|
@@ -56100,35 +56126,23 @@ var ts;
|
|
|
56100
56126
|
return links.writeType;
|
|
56101
56127
|
}
|
|
56102
56128
|
/**
|
|
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.
|
|
56129
|
+
* Distinct write types come only from set accessors, but synthetic union and intersection
|
|
56130
|
+
* properties deriving from set accessors will either pre-compute or defer the union or
|
|
56131
|
+
* intersection of the writeTypes of their constituents.
|
|
56109
56132
|
*/
|
|
56110
56133
|
function getWriteTypeOfSymbol(symbol) {
|
|
56111
56134
|
var checkFlags = ts.getCheckFlags(symbol);
|
|
56112
|
-
if (
|
|
56113
|
-
|
|
56114
|
-
|
|
56115
|
-
|
|
56116
|
-
|
|
56117
|
-
|
|
56118
|
-
if (symbol.flags & 33554432 /* Transient */) {
|
|
56119
|
-
var writeType = symbol.writeType;
|
|
56120
|
-
if (writeType) {
|
|
56121
|
-
return writeType;
|
|
56122
|
-
}
|
|
56135
|
+
if (symbol.flags & 4 /* Property */) {
|
|
56136
|
+
return checkFlags & 2 /* SyntheticProperty */ ?
|
|
56137
|
+
checkFlags & 65536 /* DeferredType */ ?
|
|
56138
|
+
getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
|
|
56139
|
+
symbol.writeType || symbol.type :
|
|
56140
|
+
getTypeOfSymbol(symbol);
|
|
56123
56141
|
}
|
|
56124
|
-
return getSetAccessorTypeOfSymbol(symbol);
|
|
56125
|
-
}
|
|
56126
|
-
function getSetAccessorTypeOfSymbol(symbol) {
|
|
56127
56142
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
56128
|
-
|
|
56129
|
-
|
|
56130
|
-
|
|
56131
|
-
}
|
|
56143
|
+
return checkFlags & 1 /* Instantiated */ ?
|
|
56144
|
+
getWriteTypeOfInstantiatedSymbol(symbol) :
|
|
56145
|
+
getWriteTypeOfAccessors(symbol);
|
|
56132
56146
|
}
|
|
56133
56147
|
return getTypeOfSymbol(symbol);
|
|
56134
56148
|
}
|
|
@@ -68217,7 +68231,7 @@ var ts;
|
|
|
68217
68231
|
for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
|
|
68218
68232
|
var targetProp = properties_3[_i];
|
|
68219
68233
|
var sourceProp = getPropertyOfType(source, targetProp.escapedName);
|
|
68220
|
-
if (sourceProp) {
|
|
68234
|
+
if (sourceProp && !ts.some(sourceProp.declarations, hasSkipDirectInferenceFlag)) {
|
|
68221
68235
|
inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
|
|
68222
68236
|
}
|
|
68223
68237
|
}
|
|
@@ -70599,7 +70613,7 @@ var ts;
|
|
|
70599
70613
|
}
|
|
70600
70614
|
}
|
|
70601
70615
|
if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) {
|
|
70602
|
-
return
|
|
70616
|
+
return getWriteTypeOfAccessors(location.parent.symbol);
|
|
70603
70617
|
}
|
|
70604
70618
|
// The location isn't a reference to the given symbol, meaning we're being asked
|
|
70605
70619
|
// a hypothetical question of what type the symbol would have if there was a reference
|
|
@@ -70691,7 +70705,7 @@ var ts;
|
|
|
70691
70705
|
// as we want the type of a rest element to be generic when possible.
|
|
70692
70706
|
var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) &&
|
|
70693
70707
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
70694
|
-
(checkMode && checkMode &
|
|
70708
|
+
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
70695
70709
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
70696
70710
|
: getContextualType(node));
|
|
70697
70711
|
return contextualType && !isGenericType(contextualType);
|
|
@@ -70812,7 +70826,7 @@ var ts;
|
|
|
70812
70826
|
if (func.parameters.length >= 2 && isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
|
|
70813
70827
|
var contextualSignature = getContextualSignature(func);
|
|
70814
70828
|
if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) {
|
|
70815
|
-
var restType = getTypeOfSymbol(contextualSignature.parameters[0]);
|
|
70829
|
+
var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0]));
|
|
70816
70830
|
if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) {
|
|
70817
70831
|
var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode);
|
|
70818
70832
|
var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0);
|
|
@@ -71630,7 +71644,7 @@ var ts;
|
|
|
71630
71644
|
var parent = declaration.parent.parent;
|
|
71631
71645
|
var name = declaration.propertyName || declaration.name;
|
|
71632
71646
|
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
71633
|
-
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ?
|
|
71647
|
+
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
71634
71648
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
71635
71649
|
return undefined;
|
|
71636
71650
|
if (parent.name.kind === 202 /* ArrayBindingPattern */) {
|
|
@@ -72117,9 +72131,14 @@ var ts;
|
|
|
72117
72131
|
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
72118
72132
|
}
|
|
72119
72133
|
// For other purposes (e.g. determining whether to produce literal types) we only
|
|
72120
|
-
// incorporate inferences made from the return type in a function call.
|
|
72134
|
+
// incorporate inferences made from the return type in a function call. We remove
|
|
72135
|
+
// the 'boolean' type from the contextual type such that contextually typed boolean
|
|
72136
|
+
// literals actually end up widening to 'boolean' (see #48363).
|
|
72121
72137
|
if (inferenceContext.returnMapper) {
|
|
72122
|
-
|
|
72138
|
+
var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
|
|
72139
|
+
return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ?
|
|
72140
|
+
filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) :
|
|
72141
|
+
type;
|
|
72123
72142
|
}
|
|
72124
72143
|
}
|
|
72125
72144
|
}
|
|
@@ -74684,7 +74703,7 @@ var ts;
|
|
|
74684
74703
|
}
|
|
74685
74704
|
for (var i = 0; i < argCount; i++) {
|
|
74686
74705
|
var arg = args[i];
|
|
74687
|
-
if (arg.kind !== 227 /* OmittedExpression */) {
|
|
74706
|
+
if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74688
74707
|
var paramType = getTypeAtPosition(signature, i);
|
|
74689
74708
|
var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
74690
74709
|
inferTypes(context.inferences, argType, paramType);
|
|
@@ -75369,7 +75388,7 @@ var ts;
|
|
|
75369
75388
|
}
|
|
75370
75389
|
}
|
|
75371
75390
|
}
|
|
75372
|
-
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
|
|
75391
|
+
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
|
|
75373
75392
|
function addImplementationSuccessElaboration(failed, diagnostic) {
|
|
75374
75393
|
var _a, _b;
|
|
75375
75394
|
var oldCandidatesForArgumentError = candidatesForArgumentError;
|
|
@@ -75470,14 +75489,14 @@ var ts;
|
|
|
75470
75489
|
}
|
|
75471
75490
|
}
|
|
75472
75491
|
// No signature was applicable. We have already reported the errors for the invalid signature.
|
|
75473
|
-
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
|
|
75492
|
+
function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray, checkMode) {
|
|
75474
75493
|
ts.Debug.assert(candidates.length > 0); // Else should not have called this.
|
|
75475
75494
|
checkNodeDeferred(node);
|
|
75476
75495
|
// Normally we will combine overloads. Skip this if they have type parameters since that's hard to combine.
|
|
75477
75496
|
// Don't do this if there is a `candidatesOutArray`,
|
|
75478
75497
|
// because then we want the chosen best candidate to be one of the overloads, not a combination.
|
|
75479
75498
|
return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
|
|
75480
|
-
? pickLongestCandidateSignature(node, candidates, args)
|
|
75499
|
+
? pickLongestCandidateSignature(node, candidates, args, checkMode)
|
|
75481
75500
|
: createUnionOfSignaturesForOverloadFailure(candidates);
|
|
75482
75501
|
}
|
|
75483
75502
|
function createUnionOfSignaturesForOverloadFailure(candidates) {
|
|
@@ -75525,7 +75544,7 @@ var ts;
|
|
|
75525
75544
|
// This function is currently only used for erroneous overloads, so it's good enough to just use the first source.
|
|
75526
75545
|
return createSymbolWithType(ts.first(sources), type);
|
|
75527
75546
|
}
|
|
75528
|
-
function pickLongestCandidateSignature(node, candidates, args) {
|
|
75547
|
+
function pickLongestCandidateSignature(node, candidates, args, checkMode) {
|
|
75529
75548
|
// Pick the longest signature. This way we can get a contextual type for cases like:
|
|
75530
75549
|
// declare function f(a: { xa: number; xb: number; }, b: number);
|
|
75531
75550
|
// f({ |
|
|
@@ -75541,7 +75560,7 @@ var ts;
|
|
|
75541
75560
|
var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
|
|
75542
75561
|
var instantiated = typeArgumentNodes
|
|
75543
75562
|
? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
|
|
75544
|
-
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
|
|
75563
|
+
: inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode);
|
|
75545
75564
|
candidates[bestIndex] = instantiated;
|
|
75546
75565
|
return instantiated;
|
|
75547
75566
|
}
|
|
@@ -75555,9 +75574,9 @@ var ts;
|
|
|
75555
75574
|
}
|
|
75556
75575
|
return typeArguments;
|
|
75557
75576
|
}
|
|
75558
|
-
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
|
|
75577
|
+
function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) {
|
|
75559
75578
|
var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */);
|
|
75560
|
-
var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75579
|
+
var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
75561
75580
|
return createSignatureInstantiation(candidate, typeArgumentTypes);
|
|
75562
75581
|
}
|
|
75563
75582
|
function getLongestCandidateIndex(candidates, argsCount) {
|
|
@@ -81623,7 +81642,7 @@ var ts;
|
|
|
81623
81642
|
}
|
|
81624
81643
|
// check private/protected variable access
|
|
81625
81644
|
var parent = node.parent.parent;
|
|
81626
|
-
var parentCheckMode = node.dotDotDotToken ?
|
|
81645
|
+
var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */;
|
|
81627
81646
|
var parentType = getTypeForBindingElementParent(parent, parentCheckMode);
|
|
81628
81647
|
var name = node.propertyName || node.name;
|
|
81629
81648
|
if (parentType && !ts.isBindingPattern(name)) {
|
|
@@ -81802,6 +81821,8 @@ var ts;
|
|
|
81802
81821
|
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
81803
81822
|
? condExpr.right
|
|
81804
81823
|
: condExpr;
|
|
81824
|
+
if (ts.isModuleExportsAccessExpression(location))
|
|
81825
|
+
return;
|
|
81805
81826
|
var type = checkTruthinessExpression(location);
|
|
81806
81827
|
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
81807
81828
|
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
|
@@ -116719,6 +116740,13 @@ var ts;
|
|
|
116719
116740
|
return "skip";
|
|
116720
116741
|
}
|
|
116721
116742
|
break;
|
|
116743
|
+
case 270 /* ImportSpecifier */:
|
|
116744
|
+
case 275 /* ExportSpecifier */:
|
|
116745
|
+
if (node.isTypeOnly) {
|
|
116746
|
+
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type"));
|
|
116747
|
+
return "skip";
|
|
116748
|
+
}
|
|
116749
|
+
break;
|
|
116722
116750
|
case 265 /* ImportEqualsDeclaration */:
|
|
116723
116751
|
diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
|
|
116724
116752
|
return "skip";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "4.7.0-dev.
|
|
5
|
+
"version": "4.7.0-dev.20220331",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|