typescript 4.8.0-dev.20220704 → 4.8.0-dev.20220707
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/lib.es2022.error.d.ts +2 -2
- package/lib/tsc.js +182 -122
- package/lib/tsserver.js +224 -152
- package/lib/tsserverlibrary.d.ts +9 -1
- package/lib/tsserverlibrary.js +224 -152
- package/lib/typescript.d.ts +9 -1
- package/lib/typescript.js +224 -152
- package/lib/typescriptServices.d.ts +9 -1
- package/lib/typescriptServices.js +224 -152
- package/lib/typingsInstaller.js +195 -136
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -303,7 +303,7 @@ var ts;
|
|
|
303
303
|
// The following is baselined as a literal template type without intervention
|
|
304
304
|
/** The version of the TypeScript compiler release */
|
|
305
305
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
306
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
306
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220707";
|
|
307
307
|
/* @internal */
|
|
308
308
|
var Comparison;
|
|
309
309
|
(function (Comparison) {
|
|
@@ -2988,6 +2988,22 @@ var ts;
|
|
|
2988
2988
|
return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true);
|
|
2989
2989
|
}
|
|
2990
2990
|
Debug.formatFlowFlags = formatFlowFlags;
|
|
2991
|
+
function formatRelationComparisonResult(result) {
|
|
2992
|
+
return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true);
|
|
2993
|
+
}
|
|
2994
|
+
Debug.formatRelationComparisonResult = formatRelationComparisonResult;
|
|
2995
|
+
function formatCheckMode(mode) {
|
|
2996
|
+
return formatEnum(mode, ts.CheckMode, /*isFlags*/ true);
|
|
2997
|
+
}
|
|
2998
|
+
Debug.formatCheckMode = formatCheckMode;
|
|
2999
|
+
function formatSignatureCheckMode(mode) {
|
|
3000
|
+
return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true);
|
|
3001
|
+
}
|
|
3002
|
+
Debug.formatSignatureCheckMode = formatSignatureCheckMode;
|
|
3003
|
+
function formatTypeFacts(facts) {
|
|
3004
|
+
return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true);
|
|
3005
|
+
}
|
|
3006
|
+
Debug.formatTypeFacts = formatTypeFacts;
|
|
2991
3007
|
var isDebugInfoEnabled = false;
|
|
2992
3008
|
var extendedDebugModule;
|
|
2993
3009
|
function extendedDebug() {
|
|
@@ -4940,6 +4956,7 @@ var ts;
|
|
|
4940
4956
|
NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4941
4957
|
NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4942
4958
|
NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4959
|
+
NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
|
|
4943
4960
|
// Error handling
|
|
4944
4961
|
NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
|
|
4945
4962
|
NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
|
|
@@ -4980,6 +4997,7 @@ var ts;
|
|
|
4980
4997
|
TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4981
4998
|
TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4982
4999
|
TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
5000
|
+
TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
|
|
4983
5001
|
// Error Handling
|
|
4984
5002
|
TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType";
|
|
4985
5003
|
// TypeFormatFlags exclusive
|
|
@@ -4991,7 +5009,7 @@ var ts;
|
|
|
4991
5009
|
TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument";
|
|
4992
5010
|
TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias";
|
|
4993
5011
|
/** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike";
|
|
4994
|
-
TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] =
|
|
5012
|
+
TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask";
|
|
4995
5013
|
})(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
|
|
4996
5014
|
var SymbolFormatFlags;
|
|
4997
5015
|
(function (SymbolFormatFlags) {
|
|
@@ -19723,7 +19741,8 @@ var ts;
|
|
|
19723
19741
|
function getDeclarationModifierFlagsFromSymbol(s, isWrite) {
|
|
19724
19742
|
if (isWrite === void 0) { isWrite = false; }
|
|
19725
19743
|
if (s.valueDeclaration) {
|
|
19726
|
-
var declaration = (isWrite && s.declarations && ts.find(s.declarations,
|
|
19744
|
+
var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration))
|
|
19745
|
+
|| (s.flags & 32768 /* GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration;
|
|
19727
19746
|
var flags = ts.getCombinedModifierFlags(declaration);
|
|
19728
19747
|
return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */;
|
|
19729
19748
|
}
|
|
@@ -20398,7 +20417,7 @@ var ts;
|
|
|
20398
20417
|
// Excludes declaration files - they still require an explicit `export {}` or the like
|
|
20399
20418
|
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
|
20400
20419
|
// that aren't esm-mode (meaning not in a `type: module` scope).
|
|
20401
|
-
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20420
|
+
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20402
20421
|
}
|
|
20403
20422
|
function getSetExternalModuleIndicator(options) {
|
|
20404
20423
|
// TODO: Should this callback be cached?
|
|
@@ -20421,10 +20440,7 @@ var ts;
|
|
|
20421
20440
|
if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
|
|
20422
20441
|
checks.push(isFileModuleFromUsingJSXTag);
|
|
20423
20442
|
}
|
|
20424
|
-
|
|
20425
|
-
if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
20426
|
-
checks.push(isFileForcedToBeModuleByFormat);
|
|
20427
|
-
}
|
|
20443
|
+
checks.push(isFileForcedToBeModuleByFormat);
|
|
20428
20444
|
var combined_1 = ts.or.apply(void 0, checks);
|
|
20429
20445
|
var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
|
|
20430
20446
|
return callback;
|
|
@@ -34144,10 +34160,10 @@ var ts;
|
|
|
34144
34160
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
34145
34161
|
var modifiers = parseModifiers();
|
|
34146
34162
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
34147
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */);
|
|
34163
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */, 4 /* Type */);
|
|
34148
34164
|
}
|
|
34149
34165
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
34150
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */);
|
|
34166
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */, 4 /* Type */);
|
|
34151
34167
|
}
|
|
34152
34168
|
if (isIndexSignature()) {
|
|
34153
34169
|
return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers);
|
|
@@ -36193,10 +36209,10 @@ var ts;
|
|
|
36193
36209
|
var decorators = parseDecorators();
|
|
36194
36210
|
var modifiers = parseModifiers();
|
|
36195
36211
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
36196
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
36212
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
36197
36213
|
}
|
|
36198
36214
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
36199
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
36215
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
36200
36216
|
}
|
|
36201
36217
|
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
|
36202
36218
|
var tokenIsIdentifier = isIdentifier();
|
|
@@ -36888,9 +36904,15 @@ var ts;
|
|
|
36888
36904
|
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */);
|
|
36889
36905
|
}
|
|
36890
36906
|
function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
|
|
36891
|
-
if (token() !== 18 /* OpenBraceToken */
|
|
36892
|
-
|
|
36893
|
-
|
|
36907
|
+
if (token() !== 18 /* OpenBraceToken */) {
|
|
36908
|
+
if (flags & 4 /* Type */) {
|
|
36909
|
+
parseTypeMemberSemicolon();
|
|
36910
|
+
return;
|
|
36911
|
+
}
|
|
36912
|
+
if (canParseSemicolon()) {
|
|
36913
|
+
parseSemicolon();
|
|
36914
|
+
return;
|
|
36915
|
+
}
|
|
36894
36916
|
}
|
|
36895
36917
|
return parseFunctionBlock(flags, diagnosticMessage);
|
|
36896
36918
|
}
|
|
@@ -37094,12 +37116,12 @@ var ts;
|
|
|
37094
37116
|
}
|
|
37095
37117
|
return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
|
|
37096
37118
|
}
|
|
37097
|
-
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
|
|
37119
|
+
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) {
|
|
37098
37120
|
var name = parsePropertyName();
|
|
37099
37121
|
var typeParameters = parseTypeParameters();
|
|
37100
37122
|
var parameters = parseParameters(0 /* None */);
|
|
37101
37123
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
37102
|
-
var body = parseFunctionBlockOrSemicolon(
|
|
37124
|
+
var body = parseFunctionBlockOrSemicolon(flags);
|
|
37103
37125
|
var node = kind === 172 /* GetAccessor */
|
|
37104
37126
|
? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
|
|
37105
37127
|
: factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
|
|
@@ -37286,10 +37308,10 @@ var ts;
|
|
|
37286
37308
|
return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
37287
37309
|
}
|
|
37288
37310
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
37289
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
37311
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
37290
37312
|
}
|
|
37291
37313
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
37292
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
37314
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
37293
37315
|
}
|
|
37294
37316
|
if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) {
|
|
37295
37317
|
var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
@@ -48693,7 +48715,7 @@ var ts;
|
|
|
48693
48715
|
// Masks
|
|
48694
48716
|
TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
|
|
48695
48717
|
TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
|
|
48696
|
-
})(TypeFacts || (TypeFacts = {}));
|
|
48718
|
+
})(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {}));
|
|
48697
48719
|
var typeofNEFacts = new ts.Map(ts.getEntries({
|
|
48698
48720
|
string: 256 /* TypeofNEString */,
|
|
48699
48721
|
number: 512 /* TypeofNENumber */,
|
|
@@ -48728,7 +48750,7 @@ var ts;
|
|
|
48728
48750
|
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
48729
48751
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
48730
48752
|
// we need to preserve generic types instead of substituting them for constraints
|
|
48731
|
-
})(CheckMode || (CheckMode = {}));
|
|
48753
|
+
})(CheckMode = ts.CheckMode || (ts.CheckMode = {}));
|
|
48732
48754
|
var SignatureCheckMode;
|
|
48733
48755
|
(function (SignatureCheckMode) {
|
|
48734
48756
|
SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback";
|
|
@@ -48736,7 +48758,7 @@ var ts;
|
|
|
48736
48758
|
SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes";
|
|
48737
48759
|
SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity";
|
|
48738
48760
|
SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback";
|
|
48739
|
-
})(SignatureCheckMode || (SignatureCheckMode = {}));
|
|
48761
|
+
})(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {}));
|
|
48740
48762
|
var IntersectionState;
|
|
48741
48763
|
(function (IntersectionState) {
|
|
48742
48764
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
@@ -49088,7 +49110,7 @@ var ts;
|
|
|
49088
49110
|
},
|
|
49089
49111
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
49090
49112
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
49091
|
-
return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
|
|
49113
|
+
return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined;
|
|
49092
49114
|
},
|
|
49093
49115
|
getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
|
|
49094
49116
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -49096,7 +49118,7 @@ var ts;
|
|
|
49096
49118
|
},
|
|
49097
49119
|
getContextualTypeForJsxAttribute: function (nodeIn) {
|
|
49098
49120
|
var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
|
|
49099
|
-
return node && getContextualTypeForJsxAttribute(node);
|
|
49121
|
+
return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined);
|
|
49100
49122
|
},
|
|
49101
49123
|
isContextSensitive: isContextSensitive,
|
|
49102
49124
|
getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType,
|
|
@@ -49302,6 +49324,7 @@ var ts;
|
|
|
49302
49324
|
var stringMappingTypes = new ts.Map();
|
|
49303
49325
|
var substitutionTypes = new ts.Map();
|
|
49304
49326
|
var subtypeReductionCache = new ts.Map();
|
|
49327
|
+
var cachedTypes = new ts.Map();
|
|
49305
49328
|
var evolvingArrayTypes = [];
|
|
49306
49329
|
var undefinedProperties = new ts.Map();
|
|
49307
49330
|
var markerTypes = new ts.Set();
|
|
@@ -49555,6 +49578,14 @@ var ts;
|
|
|
49555
49578
|
];
|
|
49556
49579
|
initializeTypeChecker();
|
|
49557
49580
|
return checker;
|
|
49581
|
+
function getCachedType(key) {
|
|
49582
|
+
return key ? cachedTypes.get(key) : undefined;
|
|
49583
|
+
}
|
|
49584
|
+
function setCachedType(key, type) {
|
|
49585
|
+
if (key)
|
|
49586
|
+
cachedTypes.set(key, type);
|
|
49587
|
+
return type;
|
|
49588
|
+
}
|
|
49558
49589
|
function getJsxNamespace(location) {
|
|
49559
49590
|
if (location) {
|
|
49560
49591
|
var file = ts.getSourceFileOfNode(location);
|
|
@@ -52810,13 +52841,25 @@ var ts;
|
|
|
52810
52841
|
&& isDeclarationVisible(declaration.parent)) {
|
|
52811
52842
|
return addVisibleAlias(declaration, declaration);
|
|
52812
52843
|
}
|
|
52813
|
-
else if (
|
|
52814
|
-
&& ts.
|
|
52815
|
-
|
|
52816
|
-
|
|
52817
|
-
|
|
52818
|
-
|
|
52819
|
-
|
|
52844
|
+
else if (ts.isBindingElement(declaration)) {
|
|
52845
|
+
if (symbol.flags & 2097152 /* Alias */ && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement
|
|
52846
|
+
&& ts.isVariableDeclaration(declaration.parent.parent)
|
|
52847
|
+
&& ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
|
|
52848
|
+
&& !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */)
|
|
52849
|
+
&& declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file)
|
|
52850
|
+
&& isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
|
|
52851
|
+
return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
|
|
52852
|
+
}
|
|
52853
|
+
else if (symbol.flags & 2 /* BlockScopedVariable */) {
|
|
52854
|
+
var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement);
|
|
52855
|
+
if (ts.hasSyntacticModifier(variableStatement, 1 /* Export */)) {
|
|
52856
|
+
return true;
|
|
52857
|
+
}
|
|
52858
|
+
if (!isDeclarationVisible(variableStatement.parent)) {
|
|
52859
|
+
return false;
|
|
52860
|
+
}
|
|
52861
|
+
return addVisibleAlias(declaration, variableStatement);
|
|
52862
|
+
}
|
|
52820
52863
|
}
|
|
52821
52864
|
// Declaration is not visible
|
|
52822
52865
|
return false;
|
|
@@ -52949,7 +52992,7 @@ var ts;
|
|
|
52949
52992
|
}
|
|
52950
52993
|
function toNodeBuilderFlags(flags) {
|
|
52951
52994
|
if (flags === void 0) { flags = 0 /* None */; }
|
|
52952
|
-
return flags &
|
|
52995
|
+
return flags & 848330091 /* NodeBuilderFlagsMask */;
|
|
52953
52996
|
}
|
|
52954
52997
|
function isClassInstanceSide(type) {
|
|
52955
52998
|
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */)));
|
|
@@ -53337,6 +53380,10 @@ var ts;
|
|
|
53337
53380
|
}
|
|
53338
53381
|
return typeToTypeNodeHelper(type, context);
|
|
53339
53382
|
}
|
|
53383
|
+
function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) {
|
|
53384
|
+
return isMappedTypeWithKeyofConstraintDeclaration(type)
|
|
53385
|
+
&& !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */);
|
|
53386
|
+
}
|
|
53340
53387
|
function createMappedTypeNodeFromType(type) {
|
|
53341
53388
|
ts.Debug.assert(!!(type.flags & 524288 /* Object */));
|
|
53342
53389
|
var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
|
|
@@ -53346,7 +53393,7 @@ var ts;
|
|
|
53346
53393
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
53347
53394
|
// We have a { [P in keyof T]: X }
|
|
53348
53395
|
// We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
|
|
53349
|
-
if (
|
|
53396
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53350
53397
|
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
53351
53398
|
var name = typeParameterToName(newParam, context);
|
|
53352
53399
|
newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
@@ -53362,11 +53409,12 @@ var ts;
|
|
|
53362
53409
|
var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
|
|
53363
53410
|
context.approximateLength += 10;
|
|
53364
53411
|
var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
|
|
53365
|
-
if (
|
|
53412
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53366
53413
|
// homomorphic mapped type with a non-homomorphic naive inlining
|
|
53367
53414
|
// wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
|
|
53368
53415
|
// type stays homomorphic
|
|
53369
|
-
|
|
53416
|
+
var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper);
|
|
53417
|
+
return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName), originalConstraint.flags & 2 /* Unknown */ ? undefined : typeToTypeNodeHelper(originalConstraint, context))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */));
|
|
53370
53418
|
}
|
|
53371
53419
|
return result;
|
|
53372
53420
|
}
|
|
@@ -53928,7 +53976,7 @@ var ts;
|
|
|
53928
53976
|
var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
|
|
53929
53977
|
// If the expanded parameter list had a variadic in a non-trailing position, don't expand it
|
|
53930
53978
|
var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); });
|
|
53931
|
-
var thisParameter = tryGetThisParameterDeclaration(signature, context);
|
|
53979
|
+
var thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context);
|
|
53932
53980
|
if (thisParameter) {
|
|
53933
53981
|
parameters.unshift(thisParameter);
|
|
53934
53982
|
}
|
|
@@ -54987,12 +55035,11 @@ var ts;
|
|
|
54987
55035
|
if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
|
|
54988
55036
|
var oldContext = context;
|
|
54989
55037
|
context = cloneNodeBuilderContext(context);
|
|
54990
|
-
|
|
55038
|
+
serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
|
|
54991
55039
|
if (context.reportedDiagnostic) {
|
|
54992
55040
|
oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context
|
|
54993
55041
|
}
|
|
54994
55042
|
context = oldContext;
|
|
54995
|
-
return result;
|
|
54996
55043
|
}
|
|
54997
55044
|
}
|
|
54998
55045
|
// Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias
|
|
@@ -58049,7 +58096,7 @@ var ts;
|
|
|
58049
58096
|
error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
58050
58097
|
}
|
|
58051
58098
|
else {
|
|
58052
|
-
error(ts.isNamedDeclaration(declaration) ? declaration.name
|
|
58099
|
+
error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
58053
58100
|
}
|
|
58054
58101
|
}
|
|
58055
58102
|
links.declaredType = type;
|
|
@@ -66317,13 +66364,20 @@ var ts;
|
|
|
66317
66364
|
return result;
|
|
66318
66365
|
}
|
|
66319
66366
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66367
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
66368
|
+
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66369
|
+
if (result) {
|
|
66370
|
+
resetErrorInfo(saveErrorInfo);
|
|
66371
|
+
}
|
|
66372
|
+
return result;
|
|
66373
|
+
}
|
|
66374
|
+
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
|
|
66320
66375
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
66321
66376
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
66322
66377
|
}
|
|
66323
66378
|
var result;
|
|
66324
66379
|
var originalErrorInfo;
|
|
66325
66380
|
var varianceCheckFailed = false;
|
|
66326
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
66327
66381
|
var sourceFlags = source.flags;
|
|
66328
66382
|
var targetFlags = target.flags;
|
|
66329
66383
|
if (relation === identityRelation) {
|
|
@@ -66387,7 +66441,6 @@ var ts;
|
|
|
66387
66441
|
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66388
66442
|
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66389
66443
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66390
|
-
resetErrorInfo(saveErrorInfo);
|
|
66391
66444
|
return result;
|
|
66392
66445
|
}
|
|
66393
66446
|
}
|
|
@@ -66512,7 +66565,6 @@ var ts;
|
|
|
66512
66565
|
result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
|
|
66513
66566
|
}
|
|
66514
66567
|
if (result) {
|
|
66515
|
-
resetErrorInfo(saveErrorInfo);
|
|
66516
66568
|
return result;
|
|
66517
66569
|
}
|
|
66518
66570
|
if (reportErrors) {
|
|
@@ -66615,7 +66667,6 @@ var ts;
|
|
|
66615
66667
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66616
66668
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66617
66669
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
66618
|
-
resetErrorInfo(saveErrorInfo);
|
|
66619
66670
|
return 3 /* Maybe */;
|
|
66620
66671
|
}
|
|
66621
66672
|
var c = target;
|
|
@@ -66630,7 +66681,6 @@ var ts;
|
|
|
66630
66681
|
if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
|
|
66631
66682
|
result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
66632
66683
|
if (result) {
|
|
66633
|
-
resetErrorInfo(saveErrorInfo);
|
|
66634
66684
|
return result;
|
|
66635
66685
|
}
|
|
66636
66686
|
}
|
|
@@ -66662,12 +66712,10 @@ var ts;
|
|
|
66662
66712
|
var constraint = getConstraintOfType(source) || unknownType;
|
|
66663
66713
|
// hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
|
|
66664
66714
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66665
|
-
resetErrorInfo(saveErrorInfo);
|
|
66666
66715
|
return result;
|
|
66667
66716
|
}
|
|
66668
66717
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
66669
66718
|
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
66670
|
-
resetErrorInfo(saveErrorInfo);
|
|
66671
66719
|
return result;
|
|
66672
66720
|
}
|
|
66673
66721
|
if (isMappedTypeGenericIndexedAccess(source)) {
|
|
@@ -66676,7 +66724,6 @@ var ts;
|
|
|
66676
66724
|
var indexConstraint = getConstraintOfType(source.indexType);
|
|
66677
66725
|
if (indexConstraint) {
|
|
66678
66726
|
if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
|
|
66679
|
-
resetErrorInfo(saveErrorInfo);
|
|
66680
66727
|
return result;
|
|
66681
66728
|
}
|
|
66682
66729
|
}
|
|
@@ -66685,7 +66732,6 @@ var ts;
|
|
|
66685
66732
|
}
|
|
66686
66733
|
else if (sourceFlags & 4194304 /* Index */) {
|
|
66687
66734
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
66688
|
-
resetErrorInfo(saveErrorInfo);
|
|
66689
66735
|
return result;
|
|
66690
66736
|
}
|
|
66691
66737
|
}
|
|
@@ -66693,7 +66739,6 @@ var ts;
|
|
|
66693
66739
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
66694
66740
|
var constraint = getBaseConstraintOfType(source);
|
|
66695
66741
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66696
|
-
resetErrorInfo(saveErrorInfo);
|
|
66697
66742
|
return result;
|
|
66698
66743
|
}
|
|
66699
66744
|
}
|
|
@@ -66704,14 +66749,12 @@ var ts;
|
|
|
66704
66749
|
return 0 /* False */;
|
|
66705
66750
|
}
|
|
66706
66751
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66707
|
-
resetErrorInfo(saveErrorInfo);
|
|
66708
66752
|
return result;
|
|
66709
66753
|
}
|
|
66710
66754
|
}
|
|
66711
66755
|
else {
|
|
66712
66756
|
var constraint = getBaseConstraintOfType(source);
|
|
66713
66757
|
if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66714
|
-
resetErrorInfo(saveErrorInfo);
|
|
66715
66758
|
return result;
|
|
66716
66759
|
}
|
|
66717
66760
|
}
|
|
@@ -66720,7 +66763,6 @@ var ts;
|
|
|
66720
66763
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66721
66764
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66722
66765
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
66723
|
-
resetErrorInfo(saveErrorInfo);
|
|
66724
66766
|
return 3 /* Maybe */;
|
|
66725
66767
|
}
|
|
66726
66768
|
if (targetFlags & 16777216 /* Conditional */) {
|
|
@@ -66743,7 +66785,6 @@ var ts;
|
|
|
66743
66785
|
result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
|
|
66744
66786
|
}
|
|
66745
66787
|
if (result) {
|
|
66746
|
-
resetErrorInfo(saveErrorInfo);
|
|
66747
66788
|
return result;
|
|
66748
66789
|
}
|
|
66749
66790
|
}
|
|
@@ -66754,7 +66795,6 @@ var ts;
|
|
|
66754
66795
|
var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
|
|
66755
66796
|
if (distributiveConstraint) {
|
|
66756
66797
|
if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66757
|
-
resetErrorInfo(saveErrorInfo);
|
|
66758
66798
|
return result;
|
|
66759
66799
|
}
|
|
66760
66800
|
}
|
|
@@ -66764,7 +66804,6 @@ var ts;
|
|
|
66764
66804
|
var defaultConstraint = getDefaultConstraintOfConditionalType(source);
|
|
66765
66805
|
if (defaultConstraint) {
|
|
66766
66806
|
if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66767
|
-
resetErrorInfo(saveErrorInfo);
|
|
66768
66807
|
return result;
|
|
66769
66808
|
}
|
|
66770
66809
|
}
|
|
@@ -66777,7 +66816,6 @@ var ts;
|
|
|
66777
66816
|
if (isGenericMappedType(target)) {
|
|
66778
66817
|
if (isGenericMappedType(source)) {
|
|
66779
66818
|
if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
|
|
66780
|
-
resetErrorInfo(saveErrorInfo);
|
|
66781
66819
|
return result;
|
|
66782
66820
|
}
|
|
66783
66821
|
}
|
|
@@ -68232,9 +68270,14 @@ var ts;
|
|
|
68232
68270
|
type.flags & 256 /* NumberLiteral */ ? numberType :
|
|
68233
68271
|
type.flags & 2048 /* BigIntLiteral */ ? bigintType :
|
|
68234
68272
|
type.flags & 512 /* BooleanLiteral */ ? booleanType :
|
|
68235
|
-
type.flags & 1048576 /* Union */ ?
|
|
68273
|
+
type.flags & 1048576 /* Union */ ? getBaseTypeOfLiteralTypeUnion(type) :
|
|
68236
68274
|
type;
|
|
68237
68275
|
}
|
|
68276
|
+
function getBaseTypeOfLiteralTypeUnion(type) {
|
|
68277
|
+
var _a;
|
|
68278
|
+
var key = "B" + getTypeId(type);
|
|
68279
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
|
|
68280
|
+
}
|
|
68238
68281
|
function getWidenedLiteralType(type) {
|
|
68239
68282
|
return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
|
|
68240
68283
|
type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType :
|
|
@@ -70377,23 +70420,25 @@ var ts;
|
|
|
70377
70420
|
// For example, when a variable of type number | string | boolean is assigned a value of type number | boolean,
|
|
70378
70421
|
// we remove type string.
|
|
70379
70422
|
function getAssignmentReducedType(declaredType, assignedType) {
|
|
70380
|
-
|
|
70381
|
-
|
|
70382
|
-
|
|
70383
|
-
}
|
|
70384
|
-
var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
|
|
70385
|
-
if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) {
|
|
70386
|
-
reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types
|
|
70387
|
-
}
|
|
70388
|
-
// Our crude heuristic produces an invalid result in some cases: see GH#26130.
|
|
70389
|
-
// For now, when that happens, we give up and don't narrow at all. (This also
|
|
70390
|
-
// means we'll never narrow for erroneous assignments where the assigned type
|
|
70391
|
-
// is not assignable to the declared type.)
|
|
70392
|
-
if (isTypeAssignableTo(assignedType, reducedType)) {
|
|
70393
|
-
return reducedType;
|
|
70394
|
-
}
|
|
70423
|
+
var _a;
|
|
70424
|
+
if (declaredType === assignedType) {
|
|
70425
|
+
return declaredType;
|
|
70395
70426
|
}
|
|
70396
|
-
|
|
70427
|
+
if (assignedType.flags & 131072 /* Never */) {
|
|
70428
|
+
return assignedType;
|
|
70429
|
+
}
|
|
70430
|
+
var key = "A" + getTypeId(declaredType) + "," + getTypeId(assignedType);
|
|
70431
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType));
|
|
70432
|
+
}
|
|
70433
|
+
function getAssignmentReducedTypeWorker(declaredType, assignedType) {
|
|
70434
|
+
var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
|
|
70435
|
+
// Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type.
|
|
70436
|
+
var reducedType = assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
|
|
70437
|
+
// Our crude heuristic produces an invalid result in some cases: see GH#26130.
|
|
70438
|
+
// For now, when that happens, we give up and don't narrow at all. (This also
|
|
70439
|
+
// means we'll never narrow for erroneous assignments where the assigned type
|
|
70440
|
+
// is not assignable to the declared type.)
|
|
70441
|
+
return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
|
|
70397
70442
|
}
|
|
70398
70443
|
function isFunctionObjectType(type) {
|
|
70399
70444
|
// We do a quick check for a "bind" property before performing the more expensive subtype
|
|
@@ -71799,7 +71844,7 @@ var ts;
|
|
|
71799
71844
|
var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
|
|
71800
71845
|
? getTypeOfSymbol(classSymbol)
|
|
71801
71846
|
: getDeclaredTypeOfSymbol(classSymbol);
|
|
71802
|
-
return getNarrowedType(type, targetType, assumeTrue,
|
|
71847
|
+
return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
|
|
71803
71848
|
}
|
|
71804
71849
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
71805
71850
|
// We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows:
|
|
@@ -72050,9 +72095,15 @@ var ts;
|
|
|
72050
72095
|
if (!nonConstructorTypeInUnion)
|
|
72051
72096
|
return type;
|
|
72052
72097
|
}
|
|
72053
|
-
return getNarrowedType(type, targetType, assumeTrue,
|
|
72098
|
+
return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
|
|
72099
|
+
}
|
|
72100
|
+
function getNarrowedType(type, candidate, assumeTrue, checkDerived) {
|
|
72101
|
+
var _a;
|
|
72102
|
+
var key = type.flags & 1048576 /* Union */ ? "N" + getTypeId(type) + "," + getTypeId(candidate) + "," + ((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined;
|
|
72103
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived));
|
|
72054
72104
|
}
|
|
72055
|
-
function
|
|
72105
|
+
function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
|
|
72106
|
+
var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
|
|
72056
72107
|
if (!assumeTrue) {
|
|
72057
72108
|
return filterType(type, function (t) { return !isRelated(t, candidate); });
|
|
72058
72109
|
}
|
|
@@ -72100,7 +72151,7 @@ var ts;
|
|
|
72100
72151
|
var predicateArgument = getTypePredicateArgument(predicate, callExpression);
|
|
72101
72152
|
if (predicateArgument) {
|
|
72102
72153
|
if (isMatchingReference(reference, predicateArgument)) {
|
|
72103
|
-
return getNarrowedType(type, predicate.type, assumeTrue,
|
|
72154
|
+
return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false);
|
|
72104
72155
|
}
|
|
72105
72156
|
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
|
|
72106
72157
|
!(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
|
|
@@ -72108,7 +72159,7 @@ var ts;
|
|
|
72108
72159
|
}
|
|
72109
72160
|
var access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
72110
72161
|
if (access) {
|
|
72111
|
-
return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue,
|
|
72162
|
+
return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); });
|
|
72112
72163
|
}
|
|
72113
72164
|
}
|
|
72114
72165
|
}
|
|
@@ -72285,7 +72336,7 @@ var ts;
|
|
|
72285
72336
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
72286
72337
|
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
72287
72338
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
72288
|
-
: getContextualType(node));
|
|
72339
|
+
: getContextualType(node, /*contextFlags*/ undefined));
|
|
72289
72340
|
return contextualType && !isGenericType(contextualType);
|
|
72290
72341
|
}
|
|
72291
72342
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -72447,9 +72498,7 @@ var ts;
|
|
|
72447
72498
|
getNodeLinks(container).flags |= 8192 /* CaptureArguments */;
|
|
72448
72499
|
return getTypeOfSymbol(symbol);
|
|
72449
72500
|
}
|
|
72450
|
-
|
|
72451
|
-
// for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that
|
|
72452
|
-
if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
|
|
72501
|
+
if (shouldMarkIdentifierAliasReferenced(node)) {
|
|
72453
72502
|
markAliasReferenced(symbol, node);
|
|
72454
72503
|
}
|
|
72455
72504
|
var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
@@ -72583,6 +72632,25 @@ var ts;
|
|
|
72583
72632
|
}
|
|
72584
72633
|
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
|
|
72585
72634
|
}
|
|
72635
|
+
function shouldMarkIdentifierAliasReferenced(node) {
|
|
72636
|
+
var _a;
|
|
72637
|
+
var parent = node.parent;
|
|
72638
|
+
if (parent) {
|
|
72639
|
+
// A property access expression LHS? checkPropertyAccessExpression will handle that.
|
|
72640
|
+
if (ts.isPropertyAccessExpression(parent) && parent.expression === node) {
|
|
72641
|
+
return false;
|
|
72642
|
+
}
|
|
72643
|
+
// Next two check for an identifier inside a type only export.
|
|
72644
|
+
if (ts.isExportSpecifier(parent) && parent.isTypeOnly) {
|
|
72645
|
+
return false;
|
|
72646
|
+
}
|
|
72647
|
+
var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent;
|
|
72648
|
+
if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) {
|
|
72649
|
+
return false;
|
|
72650
|
+
}
|
|
72651
|
+
}
|
|
72652
|
+
return true;
|
|
72653
|
+
}
|
|
72586
72654
|
function isInsideFunctionOrInstancePropertyInitializer(node, threshold) {
|
|
72587
72655
|
return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); });
|
|
72588
72656
|
}
|
|
@@ -73132,7 +73200,7 @@ var ts;
|
|
|
73132
73200
|
// We have an object literal method. Check if the containing object literal has a contextual type
|
|
73133
73201
|
// that includes a ThisType<T>. If so, T is the contextual type for 'this'. We continue looking in
|
|
73134
73202
|
// any directly enclosing object literals.
|
|
73135
|
-
var contextualType = getApparentTypeOfContextualType(containingLiteral);
|
|
73203
|
+
var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined);
|
|
73136
73204
|
var literal = containingLiteral;
|
|
73137
73205
|
var type = contextualType;
|
|
73138
73206
|
while (type) {
|
|
@@ -73144,7 +73212,7 @@ var ts;
|
|
|
73144
73212
|
break;
|
|
73145
73213
|
}
|
|
73146
73214
|
literal = literal.parent.parent;
|
|
73147
|
-
type = getApparentTypeOfContextualType(literal);
|
|
73215
|
+
type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined);
|
|
73148
73216
|
}
|
|
73149
73217
|
// There was no contextual ThisType<T> for the containing object literal, so the contextual type
|
|
73150
73218
|
// for 'this' is the non-null form of the contextual type for the containing object literal or
|
|
@@ -73201,7 +73269,7 @@ var ts;
|
|
|
73201
73269
|
tryGetTypeAtPosition(contextualSignature, index);
|
|
73202
73270
|
}
|
|
73203
73271
|
}
|
|
73204
|
-
function getContextualTypeForVariableLikeDeclaration(declaration) {
|
|
73272
|
+
function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) {
|
|
73205
73273
|
var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
|
|
73206
73274
|
if (typeNode) {
|
|
73207
73275
|
return getTypeFromTypeNode(typeNode);
|
|
@@ -73210,18 +73278,18 @@ var ts;
|
|
|
73210
73278
|
case 164 /* Parameter */:
|
|
73211
73279
|
return getContextuallyTypedParameterType(declaration);
|
|
73212
73280
|
case 203 /* BindingElement */:
|
|
73213
|
-
return getContextualTypeForBindingElement(declaration);
|
|
73281
|
+
return getContextualTypeForBindingElement(declaration, contextFlags);
|
|
73214
73282
|
case 167 /* PropertyDeclaration */:
|
|
73215
73283
|
if (ts.isStatic(declaration)) {
|
|
73216
|
-
return getContextualTypeForStaticPropertyDeclaration(declaration);
|
|
73284
|
+
return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags);
|
|
73217
73285
|
}
|
|
73218
73286
|
// By default, do nothing and return undefined - only the above cases have context implied by a parent
|
|
73219
73287
|
}
|
|
73220
73288
|
}
|
|
73221
|
-
function getContextualTypeForBindingElement(declaration) {
|
|
73289
|
+
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
73222
73290
|
var parent = declaration.parent.parent;
|
|
73223
73291
|
var name = declaration.propertyName || declaration.name;
|
|
73224
|
-
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
73292
|
+
var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) ||
|
|
73225
73293
|
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
73226
73294
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
73227
73295
|
return undefined;
|
|
@@ -73237,8 +73305,8 @@ var ts;
|
|
|
73237
73305
|
return getTypeOfPropertyOfType(parentType, text);
|
|
73238
73306
|
}
|
|
73239
73307
|
}
|
|
73240
|
-
function getContextualTypeForStaticPropertyDeclaration(declaration) {
|
|
73241
|
-
var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent);
|
|
73308
|
+
function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) {
|
|
73309
|
+
var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags);
|
|
73242
73310
|
if (!parentType)
|
|
73243
73311
|
return undefined;
|
|
73244
73312
|
return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
|
|
@@ -73254,7 +73322,7 @@ var ts;
|
|
|
73254
73322
|
function getContextualTypeForInitializerExpression(node, contextFlags) {
|
|
73255
73323
|
var declaration = node.parent;
|
|
73256
73324
|
if (ts.hasInitializer(declaration) && node === declaration.initializer) {
|
|
73257
|
-
var result = getContextualTypeForVariableLikeDeclaration(declaration);
|
|
73325
|
+
var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags);
|
|
73258
73326
|
if (result) {
|
|
73259
73327
|
return result;
|
|
73260
73328
|
}
|
|
@@ -73264,10 +73332,10 @@ var ts;
|
|
|
73264
73332
|
}
|
|
73265
73333
|
return undefined;
|
|
73266
73334
|
}
|
|
73267
|
-
function getContextualTypeForReturnExpression(node) {
|
|
73335
|
+
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
73268
73336
|
var func = ts.getContainingFunction(node);
|
|
73269
73337
|
if (func) {
|
|
73270
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73338
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73271
73339
|
if (contextualReturnType) {
|
|
73272
73340
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73273
73341
|
if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
|
|
@@ -73297,11 +73365,11 @@ var ts;
|
|
|
73297
73365
|
}
|
|
73298
73366
|
return undefined;
|
|
73299
73367
|
}
|
|
73300
|
-
function getContextualTypeForYieldOperand(node) {
|
|
73368
|
+
function getContextualTypeForYieldOperand(node, contextFlags) {
|
|
73301
73369
|
var func = ts.getContainingFunction(node);
|
|
73302
73370
|
if (func) {
|
|
73303
73371
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73304
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73372
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73305
73373
|
if (contextualReturnType) {
|
|
73306
73374
|
return node.asteriskToken
|
|
73307
73375
|
? contextualReturnType
|
|
@@ -73325,14 +73393,14 @@ var ts;
|
|
|
73325
73393
|
}
|
|
73326
73394
|
function getContextualIterationType(kind, functionDecl) {
|
|
73327
73395
|
var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */);
|
|
73328
|
-
var contextualReturnType = getContextualReturnType(functionDecl);
|
|
73396
|
+
var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined);
|
|
73329
73397
|
if (contextualReturnType) {
|
|
73330
73398
|
return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
|
|
73331
73399
|
|| undefined;
|
|
73332
73400
|
}
|
|
73333
73401
|
return undefined;
|
|
73334
73402
|
}
|
|
73335
|
-
function getContextualReturnType(functionDecl) {
|
|
73403
|
+
function getContextualReturnType(functionDecl, contextFlags) {
|
|
73336
73404
|
// If the containing function has a return type annotation, is a constructor, or is a get accessor whose
|
|
73337
73405
|
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
|
|
73338
73406
|
var returnType = getReturnTypeFromAnnotation(functionDecl);
|
|
@@ -73347,7 +73415,7 @@ var ts;
|
|
|
73347
73415
|
}
|
|
73348
73416
|
var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl);
|
|
73349
73417
|
if (iife) {
|
|
73350
|
-
return getContextualType(iife);
|
|
73418
|
+
return getContextualType(iife, contextFlags);
|
|
73351
73419
|
}
|
|
73352
73420
|
return undefined;
|
|
73353
73421
|
}
|
|
@@ -73600,7 +73668,7 @@ var ts;
|
|
|
73600
73668
|
}
|
|
73601
73669
|
function getContextualTypeForObjectLiteralElement(element, contextFlags) {
|
|
73602
73670
|
var objectLiteral = element.parent;
|
|
73603
|
-
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element);
|
|
73671
|
+
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags);
|
|
73604
73672
|
if (propertyAssignmentType) {
|
|
73605
73673
|
return propertyAssignmentType;
|
|
73606
73674
|
}
|
|
@@ -73795,9 +73863,9 @@ var ts;
|
|
|
73795
73863
|
return getContextualTypeForInitializerExpression(node, contextFlags);
|
|
73796
73864
|
case 214 /* ArrowFunction */:
|
|
73797
73865
|
case 247 /* ReturnStatement */:
|
|
73798
|
-
return getContextualTypeForReturnExpression(node);
|
|
73866
|
+
return getContextualTypeForReturnExpression(node, contextFlags);
|
|
73799
73867
|
case 224 /* YieldExpression */:
|
|
73800
|
-
return getContextualTypeForYieldOperand(parent);
|
|
73868
|
+
return getContextualTypeForYieldOperand(parent, contextFlags);
|
|
73801
73869
|
case 218 /* AwaitExpression */:
|
|
73802
73870
|
return getContextualTypeForAwaitOperand(parent, contextFlags);
|
|
73803
73871
|
case 208 /* CallExpression */:
|
|
@@ -73845,7 +73913,7 @@ var ts;
|
|
|
73845
73913
|
}
|
|
73846
73914
|
return undefined;
|
|
73847
73915
|
function tryFindWhenConstTypeReference(node) {
|
|
73848
|
-
return getContextualType(node);
|
|
73916
|
+
return getContextualType(node, contextFlags);
|
|
73849
73917
|
}
|
|
73850
73918
|
}
|
|
73851
73919
|
function getInferenceContext(node) {
|
|
@@ -74147,7 +74215,7 @@ var ts;
|
|
|
74147
74215
|
var elementCount = elements.length;
|
|
74148
74216
|
var elementTypes = [];
|
|
74149
74217
|
var elementFlags = [];
|
|
74150
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74218
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
74151
74219
|
var inDestructuringPattern = ts.isAssignmentTarget(node);
|
|
74152
74220
|
var inConstContext = isConstContext(node);
|
|
74153
74221
|
var hasOmittedExpression = false;
|
|
@@ -74318,7 +74386,7 @@ var ts;
|
|
|
74318
74386
|
var propertiesTable = ts.createSymbolTable();
|
|
74319
74387
|
var propertiesArray = [];
|
|
74320
74388
|
var spread = emptyObjectType;
|
|
74321
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74389
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
74322
74390
|
var contextualTypeHasPattern = contextualType && contextualType.pattern &&
|
|
74323
74391
|
(contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */);
|
|
74324
74392
|
var inConstContext = isConstContext(node);
|
|
@@ -74657,7 +74725,7 @@ var ts;
|
|
|
74657
74725
|
if (explicitlySpecifyChildrenAttribute) {
|
|
74658
74726
|
error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
|
|
74659
74727
|
}
|
|
74660
|
-
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
|
|
74728
|
+
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined);
|
|
74661
74729
|
var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
|
|
74662
74730
|
// If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process
|
|
74663
74731
|
var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName);
|
|
@@ -77120,7 +77188,7 @@ var ts;
|
|
|
77120
77188
|
argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
77121
77189
|
if (inferenceContext) {
|
|
77122
77190
|
var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
77123
|
-
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext
|
|
77191
|
+
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
77124
77192
|
// If the original signature has a generic rest type, instantiation may produce a
|
|
77125
77193
|
// signature with different arity and we need to perform another arity check.
|
|
77126
77194
|
if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
|
|
@@ -78497,17 +78565,6 @@ var ts;
|
|
|
78497
78565
|
}
|
|
78498
78566
|
}
|
|
78499
78567
|
}
|
|
78500
|
-
var restType = getEffectiveRestType(context);
|
|
78501
|
-
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
78502
|
-
// The contextual signature has a generic rest parameter. We first instantiate the contextual
|
|
78503
|
-
// signature (without fixing type parameters) and assign types to contextually typed parameters.
|
|
78504
|
-
var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
|
|
78505
|
-
assignContextualParameterTypes(signature, instantiatedContext);
|
|
78506
|
-
// We then infer from a tuple type representing the parameters that correspond to the contextual
|
|
78507
|
-
// rest parameter.
|
|
78508
|
-
var restPos = getParameterCount(context) - 1;
|
|
78509
|
-
inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
|
|
78510
|
-
}
|
|
78511
78568
|
}
|
|
78512
78569
|
function assignContextualParameterTypes(signature, context) {
|
|
78513
78570
|
if (context.typeParameters) {
|
|
@@ -78700,7 +78757,7 @@ var ts;
|
|
|
78700
78757
|
var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
|
|
78701
78758
|
var contextualType = !contextualSignature ? undefined :
|
|
78702
78759
|
contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
|
|
78703
|
-
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
|
|
78760
|
+
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined);
|
|
78704
78761
|
if (isGenerator) {
|
|
78705
78762
|
yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync);
|
|
78706
78763
|
returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync);
|
|
@@ -78771,7 +78828,7 @@ var ts;
|
|
|
78771
78828
|
nextType = iterationTypes && iterationTypes.nextType;
|
|
78772
78829
|
}
|
|
78773
78830
|
else {
|
|
78774
|
-
nextType = getContextualType(yieldExpression);
|
|
78831
|
+
nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined);
|
|
78775
78832
|
}
|
|
78776
78833
|
if (nextType)
|
|
78777
78834
|
ts.pushIfUnique(nextTypes, nextType);
|
|
@@ -78980,11 +79037,16 @@ var ts;
|
|
|
78980
79037
|
if (isContextSensitive(node)) {
|
|
78981
79038
|
if (contextualSignature) {
|
|
78982
79039
|
var inferenceContext = getInferenceContext(node);
|
|
79040
|
+
var instantiatedContextualSignature = void 0;
|
|
78983
79041
|
if (checkMode && checkMode & 2 /* Inferential */) {
|
|
78984
79042
|
inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
|
|
79043
|
+
var restType = getEffectiveRestType(contextualSignature);
|
|
79044
|
+
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
79045
|
+
instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper);
|
|
79046
|
+
}
|
|
78985
79047
|
}
|
|
78986
|
-
|
|
78987
|
-
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
|
|
79048
|
+
instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ?
|
|
79049
|
+
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature);
|
|
78988
79050
|
assignContextualParameterTypes(signature, instantiatedContextualSignature);
|
|
78989
79051
|
}
|
|
78990
79052
|
else {
|
|
@@ -80226,7 +80288,7 @@ var ts;
|
|
|
80226
80288
|
type = anyType;
|
|
80227
80289
|
addLazyDiagnostic(function () {
|
|
80228
80290
|
if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
|
|
80229
|
-
var contextualType = getContextualType(node);
|
|
80291
|
+
var contextualType = getContextualType(node, /*contextFlags*/ undefined);
|
|
80230
80292
|
if (!contextualType || isTypeAny(contextualType)) {
|
|
80231
80293
|
error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
|
|
80232
80294
|
}
|
|
@@ -80267,7 +80329,7 @@ var ts;
|
|
|
80267
80329
|
texts.push(span.literal.text);
|
|
80268
80330
|
types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
|
|
80269
80331
|
}
|
|
80270
|
-
return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
|
|
80332
|
+
return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
|
|
80271
80333
|
}
|
|
80272
80334
|
function isTemplateLiteralContextualType(type) {
|
|
80273
80335
|
return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) ||
|
|
@@ -80295,7 +80357,7 @@ var ts;
|
|
|
80295
80357
|
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
|
|
80296
80358
|
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
|
|
80297
80359
|
// here would be to not mark contextually typed literals as fresh in the first place.
|
|
80298
|
-
var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
|
|
80360
|
+
var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ?
|
|
80299
80361
|
getRegularTypeOfLiteralType(type) : type;
|
|
80300
80362
|
return result;
|
|
80301
80363
|
}
|
|
@@ -80410,7 +80472,7 @@ var ts;
|
|
|
80410
80472
|
var type = checkExpression(node, checkMode, forceTuple);
|
|
80411
80473
|
return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
|
|
80412
80474
|
isTypeAssertion(node) ? type :
|
|
80413
|
-
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
|
|
80475
|
+
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined));
|
|
80414
80476
|
}
|
|
80415
80477
|
function checkPropertyAssignment(node, checkMode) {
|
|
80416
80478
|
// Do not use hasDynamicName here, because that returns false for well known symbols.
|
|
@@ -86392,7 +86454,9 @@ var ts;
|
|
|
86392
86454
|
error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
|
|
86393
86455
|
}
|
|
86394
86456
|
else {
|
|
86395
|
-
|
|
86457
|
+
if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) {
|
|
86458
|
+
markExportAsReferenced(node);
|
|
86459
|
+
}
|
|
86396
86460
|
var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
|
|
86397
86461
|
if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) {
|
|
86398
86462
|
checkExpressionCached(node.propertyName || node.name);
|
|
@@ -89753,9 +89817,6 @@ var ts;
|
|
|
89753
89817
|
else {
|
|
89754
89818
|
return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
|
89755
89819
|
}
|
|
89756
|
-
if (!isConstOrReadonly || isInvalidInitializer) {
|
|
89757
|
-
return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
|
89758
|
-
}
|
|
89759
89820
|
}
|
|
89760
89821
|
}
|
|
89761
89822
|
function checkGrammarVariableDeclaration(node) {
|
|
@@ -111540,7 +111601,7 @@ var ts;
|
|
|
111540
111601
|
return;
|
|
111541
111602
|
}
|
|
111542
111603
|
// Make sure not to write js file and source map file if any of them cannot be written
|
|
111543
|
-
if (
|
|
111604
|
+
if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) {
|
|
111544
111605
|
emitSkipped = true;
|
|
111545
111606
|
return;
|
|
111546
111607
|
}
|
|
@@ -124802,7 +124863,6 @@ var ts;
|
|
|
124802
124863
|
var parsedConfigs; // Parsed commandline and watching cached for referenced projects
|
|
124803
124864
|
var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
|
|
124804
124865
|
var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
|
|
124805
|
-
var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
|
|
124806
124866
|
var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
|
|
124807
124867
|
var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
|
|
124808
124868
|
var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files
|
|
@@ -124955,12 +125015,12 @@ var ts;
|
|
|
124955
125015
|
var program = getCurrentBuilderProgram();
|
|
124956
125016
|
if (hasChangedCompilerOptions) {
|
|
124957
125017
|
newLine = updateNewLine();
|
|
124958
|
-
if (program &&
|
|
125018
|
+
if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
|
|
124959
125019
|
resolutionCache.clear();
|
|
124960
125020
|
}
|
|
124961
125021
|
}
|
|
124962
125022
|
// All resolutions are invalid if user provided resolutions
|
|
124963
|
-
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution
|
|
125023
|
+
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
|
|
124964
125024
|
if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
|
124965
125025
|
if (hasChangedConfigFileParsingErrors) {
|
|
124966
125026
|
if (reportFileChangeDetectedOnCreateProgram) {
|
|
@@ -124976,7 +125036,6 @@ var ts;
|
|
|
124976
125036
|
}
|
|
124977
125037
|
createNewProgram(hasInvalidatedResolution);
|
|
124978
125038
|
}
|
|
124979
|
-
changesAffectResolution = false; // reset for next sync
|
|
124980
125039
|
reportFileChangeDetectedOnCreateProgram = false;
|
|
124981
125040
|
if (host.afterProgramCreate && program !== builderProgram) {
|
|
124982
125041
|
host.afterProgramCreate(builderProgram);
|
|
@@ -126357,7 +126416,7 @@ var ts;
|
|
|
126357
126416
|
}
|
|
126358
126417
|
function afterProgramDone(state, program, config) {
|
|
126359
126418
|
if (program) {
|
|
126360
|
-
if (
|
|
126419
|
+
if (state.write)
|
|
126361
126420
|
ts.listFiles(program, state.write);
|
|
126362
126421
|
if (state.host.afterProgramEmitAndDiagnostics) {
|
|
126363
126422
|
state.host.afterProgramEmitAndDiagnostics(program);
|
|
@@ -134545,7 +134604,7 @@ var ts;
|
|
|
134545
134604
|
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
134546
134605
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
134547
134606
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
134548
|
-
var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ :
|
|
134607
|
+
var builderFlags = 33554432 /* OmitThisParameter */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
|
|
134549
134608
|
switch (declaration.kind) {
|
|
134550
134609
|
case 166 /* PropertySignature */:
|
|
134551
134610
|
case 167 /* PropertyDeclaration */:
|
|
@@ -166090,20 +166149,25 @@ var ts;
|
|
|
166090
166149
|
return this.documentationComment;
|
|
166091
166150
|
};
|
|
166092
166151
|
SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) {
|
|
166093
|
-
|
|
166094
|
-
|
|
166152
|
+
if (context) {
|
|
166153
|
+
if (ts.isGetAccessor(context)) {
|
|
166095
166154
|
if (!this.contextualGetAccessorDocumentationComment) {
|
|
166096
166155
|
this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
166097
166156
|
}
|
|
166098
|
-
|
|
166099
|
-
|
|
166157
|
+
if (ts.length(this.contextualGetAccessorDocumentationComment)) {
|
|
166158
|
+
return this.contextualGetAccessorDocumentationComment;
|
|
166159
|
+
}
|
|
166160
|
+
}
|
|
166161
|
+
if (ts.isSetAccessor(context)) {
|
|
166100
166162
|
if (!this.contextualSetAccessorDocumentationComment) {
|
|
166101
166163
|
this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
166102
166164
|
}
|
|
166103
|
-
|
|
166104
|
-
|
|
166105
|
-
|
|
166165
|
+
if (ts.length(this.contextualSetAccessorDocumentationComment)) {
|
|
166166
|
+
return this.contextualSetAccessorDocumentationComment;
|
|
166167
|
+
}
|
|
166168
|
+
}
|
|
166106
166169
|
}
|
|
166170
|
+
return this.getDocumentationComment(checker);
|
|
166107
166171
|
};
|
|
166108
166172
|
SymbolObject.prototype.getJsDocTags = function (checker) {
|
|
166109
166173
|
if (this.tags === undefined) {
|
|
@@ -166112,20 +166176,25 @@ var ts;
|
|
|
166112
166176
|
return this.tags;
|
|
166113
166177
|
};
|
|
166114
166178
|
SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
|
|
166115
|
-
|
|
166116
|
-
|
|
166179
|
+
if (context) {
|
|
166180
|
+
if (ts.isGetAccessor(context)) {
|
|
166117
166181
|
if (!this.contextualGetAccessorTags) {
|
|
166118
166182
|
this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
166119
166183
|
}
|
|
166120
|
-
|
|
166121
|
-
|
|
166184
|
+
if (ts.length(this.contextualGetAccessorTags)) {
|
|
166185
|
+
return this.contextualGetAccessorTags;
|
|
166186
|
+
}
|
|
166187
|
+
}
|
|
166188
|
+
if (ts.isSetAccessor(context)) {
|
|
166122
166189
|
if (!this.contextualSetAccessorTags) {
|
|
166123
166190
|
this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
166124
166191
|
}
|
|
166125
|
-
|
|
166126
|
-
|
|
166127
|
-
|
|
166192
|
+
if (ts.length(this.contextualSetAccessorTags)) {
|
|
166193
|
+
return this.contextualSetAccessorTags;
|
|
166194
|
+
}
|
|
166195
|
+
}
|
|
166128
166196
|
}
|
|
166197
|
+
return this.getJsDocTags(checker);
|
|
166129
166198
|
};
|
|
166130
166199
|
return SymbolObject;
|
|
166131
166200
|
}());
|
|
@@ -166876,7 +166945,10 @@ var ts;
|
|
|
166876
166945
|
program = undefined; // TODO: GH#18217
|
|
166877
166946
|
lastTypesRootVersion = typeRootsVersion;
|
|
166878
166947
|
}
|
|
166879
|
-
|
|
166948
|
+
// This array is retained by the program and will be used to determine if the program is up to date,
|
|
166949
|
+
// so we need to make a copy in case the host mutates the underlying array - otherwise it would look
|
|
166950
|
+
// like every program always has the host's current list of root files.
|
|
166951
|
+
var rootFileNames = host.getScriptFileNames().slice();
|
|
166880
166952
|
// Get a fresh cache of the host information
|
|
166881
166953
|
var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
|
|
166882
166954
|
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
|