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
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220707";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -2979,6 +2979,22 @@ var ts;
|
|
|
2979
2979
|
return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true);
|
|
2980
2980
|
}
|
|
2981
2981
|
Debug.formatFlowFlags = formatFlowFlags;
|
|
2982
|
+
function formatRelationComparisonResult(result) {
|
|
2983
|
+
return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true);
|
|
2984
|
+
}
|
|
2985
|
+
Debug.formatRelationComparisonResult = formatRelationComparisonResult;
|
|
2986
|
+
function formatCheckMode(mode) {
|
|
2987
|
+
return formatEnum(mode, ts.CheckMode, /*isFlags*/ true);
|
|
2988
|
+
}
|
|
2989
|
+
Debug.formatCheckMode = formatCheckMode;
|
|
2990
|
+
function formatSignatureCheckMode(mode) {
|
|
2991
|
+
return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true);
|
|
2992
|
+
}
|
|
2993
|
+
Debug.formatSignatureCheckMode = formatSignatureCheckMode;
|
|
2994
|
+
function formatTypeFacts(facts) {
|
|
2995
|
+
return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true);
|
|
2996
|
+
}
|
|
2997
|
+
Debug.formatTypeFacts = formatTypeFacts;
|
|
2982
2998
|
var isDebugInfoEnabled = false;
|
|
2983
2999
|
var extendedDebugModule;
|
|
2984
3000
|
function extendedDebug() {
|
|
@@ -4931,6 +4947,7 @@ var ts;
|
|
|
4931
4947
|
NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4932
4948
|
NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4933
4949
|
NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4950
|
+
NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
|
|
4934
4951
|
// Error handling
|
|
4935
4952
|
NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
|
|
4936
4953
|
NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
|
|
@@ -4971,6 +4988,7 @@ var ts;
|
|
|
4971
4988
|
TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4972
4989
|
TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4973
4990
|
TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4991
|
+
TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
|
|
4974
4992
|
// Error Handling
|
|
4975
4993
|
TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType";
|
|
4976
4994
|
// TypeFormatFlags exclusive
|
|
@@ -4982,7 +5000,7 @@ var ts;
|
|
|
4982
5000
|
TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument";
|
|
4983
5001
|
TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias";
|
|
4984
5002
|
/** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike";
|
|
4985
|
-
TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] =
|
|
5003
|
+
TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask";
|
|
4986
5004
|
})(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
|
|
4987
5005
|
var SymbolFormatFlags;
|
|
4988
5006
|
(function (SymbolFormatFlags) {
|
|
@@ -19714,7 +19732,8 @@ var ts;
|
|
|
19714
19732
|
function getDeclarationModifierFlagsFromSymbol(s, isWrite) {
|
|
19715
19733
|
if (isWrite === void 0) { isWrite = false; }
|
|
19716
19734
|
if (s.valueDeclaration) {
|
|
19717
|
-
var declaration = (isWrite && s.declarations && ts.find(s.declarations,
|
|
19735
|
+
var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration))
|
|
19736
|
+
|| (s.flags & 32768 /* GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration;
|
|
19718
19737
|
var flags = ts.getCombinedModifierFlags(declaration);
|
|
19719
19738
|
return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */;
|
|
19720
19739
|
}
|
|
@@ -20389,7 +20408,7 @@ var ts;
|
|
|
20389
20408
|
// Excludes declaration files - they still require an explicit `export {}` or the like
|
|
20390
20409
|
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
|
20391
20410
|
// that aren't esm-mode (meaning not in a `type: module` scope).
|
|
20392
|
-
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20411
|
+
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20393
20412
|
}
|
|
20394
20413
|
function getSetExternalModuleIndicator(options) {
|
|
20395
20414
|
// TODO: Should this callback be cached?
|
|
@@ -20412,10 +20431,7 @@ var ts;
|
|
|
20412
20431
|
if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
|
|
20413
20432
|
checks.push(isFileModuleFromUsingJSXTag);
|
|
20414
20433
|
}
|
|
20415
|
-
|
|
20416
|
-
if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
20417
|
-
checks.push(isFileForcedToBeModuleByFormat);
|
|
20418
|
-
}
|
|
20434
|
+
checks.push(isFileForcedToBeModuleByFormat);
|
|
20419
20435
|
var combined_1 = ts.or.apply(void 0, checks);
|
|
20420
20436
|
var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
|
|
20421
20437
|
return callback;
|
|
@@ -34135,10 +34151,10 @@ var ts;
|
|
|
34135
34151
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
34136
34152
|
var modifiers = parseModifiers();
|
|
34137
34153
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
34138
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */);
|
|
34154
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */, 4 /* Type */);
|
|
34139
34155
|
}
|
|
34140
34156
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
34141
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */);
|
|
34157
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */, 4 /* Type */);
|
|
34142
34158
|
}
|
|
34143
34159
|
if (isIndexSignature()) {
|
|
34144
34160
|
return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers);
|
|
@@ -36184,10 +36200,10 @@ var ts;
|
|
|
36184
36200
|
var decorators = parseDecorators();
|
|
36185
36201
|
var modifiers = parseModifiers();
|
|
36186
36202
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
36187
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
36203
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
36188
36204
|
}
|
|
36189
36205
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
36190
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
36206
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
36191
36207
|
}
|
|
36192
36208
|
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
|
36193
36209
|
var tokenIsIdentifier = isIdentifier();
|
|
@@ -36879,9 +36895,15 @@ var ts;
|
|
|
36879
36895
|
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */);
|
|
36880
36896
|
}
|
|
36881
36897
|
function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
|
|
36882
|
-
if (token() !== 18 /* OpenBraceToken */
|
|
36883
|
-
|
|
36884
|
-
|
|
36898
|
+
if (token() !== 18 /* OpenBraceToken */) {
|
|
36899
|
+
if (flags & 4 /* Type */) {
|
|
36900
|
+
parseTypeMemberSemicolon();
|
|
36901
|
+
return;
|
|
36902
|
+
}
|
|
36903
|
+
if (canParseSemicolon()) {
|
|
36904
|
+
parseSemicolon();
|
|
36905
|
+
return;
|
|
36906
|
+
}
|
|
36885
36907
|
}
|
|
36886
36908
|
return parseFunctionBlock(flags, diagnosticMessage);
|
|
36887
36909
|
}
|
|
@@ -37085,12 +37107,12 @@ var ts;
|
|
|
37085
37107
|
}
|
|
37086
37108
|
return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
|
|
37087
37109
|
}
|
|
37088
|
-
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
|
|
37110
|
+
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) {
|
|
37089
37111
|
var name = parsePropertyName();
|
|
37090
37112
|
var typeParameters = parseTypeParameters();
|
|
37091
37113
|
var parameters = parseParameters(0 /* None */);
|
|
37092
37114
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
37093
|
-
var body = parseFunctionBlockOrSemicolon(
|
|
37115
|
+
var body = parseFunctionBlockOrSemicolon(flags);
|
|
37094
37116
|
var node = kind === 172 /* GetAccessor */
|
|
37095
37117
|
? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
|
|
37096
37118
|
: factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
|
|
@@ -37277,10 +37299,10 @@ var ts;
|
|
|
37277
37299
|
return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
37278
37300
|
}
|
|
37279
37301
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
37280
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
37302
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
37281
37303
|
}
|
|
37282
37304
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
37283
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
37305
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
37284
37306
|
}
|
|
37285
37307
|
if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) {
|
|
37286
37308
|
var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
@@ -48684,7 +48706,7 @@ var ts;
|
|
|
48684
48706
|
// Masks
|
|
48685
48707
|
TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
|
|
48686
48708
|
TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
|
|
48687
|
-
})(TypeFacts || (TypeFacts = {}));
|
|
48709
|
+
})(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {}));
|
|
48688
48710
|
var typeofNEFacts = new ts.Map(ts.getEntries({
|
|
48689
48711
|
string: 256 /* TypeofNEString */,
|
|
48690
48712
|
number: 512 /* TypeofNENumber */,
|
|
@@ -48719,7 +48741,7 @@ var ts;
|
|
|
48719
48741
|
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
48720
48742
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
48721
48743
|
// we need to preserve generic types instead of substituting them for constraints
|
|
48722
|
-
})(CheckMode || (CheckMode = {}));
|
|
48744
|
+
})(CheckMode = ts.CheckMode || (ts.CheckMode = {}));
|
|
48723
48745
|
var SignatureCheckMode;
|
|
48724
48746
|
(function (SignatureCheckMode) {
|
|
48725
48747
|
SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback";
|
|
@@ -48727,7 +48749,7 @@ var ts;
|
|
|
48727
48749
|
SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes";
|
|
48728
48750
|
SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity";
|
|
48729
48751
|
SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback";
|
|
48730
|
-
})(SignatureCheckMode || (SignatureCheckMode = {}));
|
|
48752
|
+
})(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {}));
|
|
48731
48753
|
var IntersectionState;
|
|
48732
48754
|
(function (IntersectionState) {
|
|
48733
48755
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
@@ -49079,7 +49101,7 @@ var ts;
|
|
|
49079
49101
|
},
|
|
49080
49102
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
49081
49103
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
49082
|
-
return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
|
|
49104
|
+
return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined;
|
|
49083
49105
|
},
|
|
49084
49106
|
getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
|
|
49085
49107
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -49087,7 +49109,7 @@ var ts;
|
|
|
49087
49109
|
},
|
|
49088
49110
|
getContextualTypeForJsxAttribute: function (nodeIn) {
|
|
49089
49111
|
var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
|
|
49090
|
-
return node && getContextualTypeForJsxAttribute(node);
|
|
49112
|
+
return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined);
|
|
49091
49113
|
},
|
|
49092
49114
|
isContextSensitive: isContextSensitive,
|
|
49093
49115
|
getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType,
|
|
@@ -49293,6 +49315,7 @@ var ts;
|
|
|
49293
49315
|
var stringMappingTypes = new ts.Map();
|
|
49294
49316
|
var substitutionTypes = new ts.Map();
|
|
49295
49317
|
var subtypeReductionCache = new ts.Map();
|
|
49318
|
+
var cachedTypes = new ts.Map();
|
|
49296
49319
|
var evolvingArrayTypes = [];
|
|
49297
49320
|
var undefinedProperties = new ts.Map();
|
|
49298
49321
|
var markerTypes = new ts.Set();
|
|
@@ -49546,6 +49569,14 @@ var ts;
|
|
|
49546
49569
|
];
|
|
49547
49570
|
initializeTypeChecker();
|
|
49548
49571
|
return checker;
|
|
49572
|
+
function getCachedType(key) {
|
|
49573
|
+
return key ? cachedTypes.get(key) : undefined;
|
|
49574
|
+
}
|
|
49575
|
+
function setCachedType(key, type) {
|
|
49576
|
+
if (key)
|
|
49577
|
+
cachedTypes.set(key, type);
|
|
49578
|
+
return type;
|
|
49579
|
+
}
|
|
49549
49580
|
function getJsxNamespace(location) {
|
|
49550
49581
|
if (location) {
|
|
49551
49582
|
var file = ts.getSourceFileOfNode(location);
|
|
@@ -52801,13 +52832,25 @@ var ts;
|
|
|
52801
52832
|
&& isDeclarationVisible(declaration.parent)) {
|
|
52802
52833
|
return addVisibleAlias(declaration, declaration);
|
|
52803
52834
|
}
|
|
52804
|
-
else if (
|
|
52805
|
-
&& ts.
|
|
52806
|
-
|
|
52807
|
-
|
|
52808
|
-
|
|
52809
|
-
|
|
52810
|
-
|
|
52835
|
+
else if (ts.isBindingElement(declaration)) {
|
|
52836
|
+
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
|
|
52837
|
+
&& ts.isVariableDeclaration(declaration.parent.parent)
|
|
52838
|
+
&& ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
|
|
52839
|
+
&& !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */)
|
|
52840
|
+
&& declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file)
|
|
52841
|
+
&& isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
|
|
52842
|
+
return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
|
|
52843
|
+
}
|
|
52844
|
+
else if (symbol.flags & 2 /* BlockScopedVariable */) {
|
|
52845
|
+
var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement);
|
|
52846
|
+
if (ts.hasSyntacticModifier(variableStatement, 1 /* Export */)) {
|
|
52847
|
+
return true;
|
|
52848
|
+
}
|
|
52849
|
+
if (!isDeclarationVisible(variableStatement.parent)) {
|
|
52850
|
+
return false;
|
|
52851
|
+
}
|
|
52852
|
+
return addVisibleAlias(declaration, variableStatement);
|
|
52853
|
+
}
|
|
52811
52854
|
}
|
|
52812
52855
|
// Declaration is not visible
|
|
52813
52856
|
return false;
|
|
@@ -52940,7 +52983,7 @@ var ts;
|
|
|
52940
52983
|
}
|
|
52941
52984
|
function toNodeBuilderFlags(flags) {
|
|
52942
52985
|
if (flags === void 0) { flags = 0 /* None */; }
|
|
52943
|
-
return flags &
|
|
52986
|
+
return flags & 848330091 /* NodeBuilderFlagsMask */;
|
|
52944
52987
|
}
|
|
52945
52988
|
function isClassInstanceSide(type) {
|
|
52946
52989
|
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */)));
|
|
@@ -53328,6 +53371,10 @@ var ts;
|
|
|
53328
53371
|
}
|
|
53329
53372
|
return typeToTypeNodeHelper(type, context);
|
|
53330
53373
|
}
|
|
53374
|
+
function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) {
|
|
53375
|
+
return isMappedTypeWithKeyofConstraintDeclaration(type)
|
|
53376
|
+
&& !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */);
|
|
53377
|
+
}
|
|
53331
53378
|
function createMappedTypeNodeFromType(type) {
|
|
53332
53379
|
ts.Debug.assert(!!(type.flags & 524288 /* Object */));
|
|
53333
53380
|
var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
|
|
@@ -53337,7 +53384,7 @@ var ts;
|
|
|
53337
53384
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
53338
53385
|
// We have a { [P in keyof T]: X }
|
|
53339
53386
|
// We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
|
|
53340
|
-
if (
|
|
53387
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53341
53388
|
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
53342
53389
|
var name = typeParameterToName(newParam, context);
|
|
53343
53390
|
newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
@@ -53353,11 +53400,12 @@ var ts;
|
|
|
53353
53400
|
var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
|
|
53354
53401
|
context.approximateLength += 10;
|
|
53355
53402
|
var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
|
|
53356
|
-
if (
|
|
53403
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53357
53404
|
// homomorphic mapped type with a non-homomorphic naive inlining
|
|
53358
53405
|
// wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
|
|
53359
53406
|
// type stays homomorphic
|
|
53360
|
-
|
|
53407
|
+
var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper);
|
|
53408
|
+
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 */));
|
|
53361
53409
|
}
|
|
53362
53410
|
return result;
|
|
53363
53411
|
}
|
|
@@ -53919,7 +53967,7 @@ var ts;
|
|
|
53919
53967
|
var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
|
|
53920
53968
|
// If the expanded parameter list had a variadic in a non-trailing position, don't expand it
|
|
53921
53969
|
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); });
|
|
53922
|
-
var thisParameter = tryGetThisParameterDeclaration(signature, context);
|
|
53970
|
+
var thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context);
|
|
53923
53971
|
if (thisParameter) {
|
|
53924
53972
|
parameters.unshift(thisParameter);
|
|
53925
53973
|
}
|
|
@@ -54978,12 +55026,11 @@ var ts;
|
|
|
54978
55026
|
if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
|
|
54979
55027
|
var oldContext = context;
|
|
54980
55028
|
context = cloneNodeBuilderContext(context);
|
|
54981
|
-
|
|
55029
|
+
serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
|
|
54982
55030
|
if (context.reportedDiagnostic) {
|
|
54983
55031
|
oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context
|
|
54984
55032
|
}
|
|
54985
55033
|
context = oldContext;
|
|
54986
|
-
return result;
|
|
54987
55034
|
}
|
|
54988
55035
|
}
|
|
54989
55036
|
// Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias
|
|
@@ -58040,7 +58087,7 @@ var ts;
|
|
|
58040
58087
|
error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
58041
58088
|
}
|
|
58042
58089
|
else {
|
|
58043
|
-
error(ts.isNamedDeclaration(declaration) ? declaration.name
|
|
58090
|
+
error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
58044
58091
|
}
|
|
58045
58092
|
}
|
|
58046
58093
|
links.declaredType = type;
|
|
@@ -66308,13 +66355,20 @@ var ts;
|
|
|
66308
66355
|
return result;
|
|
66309
66356
|
}
|
|
66310
66357
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66358
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
66359
|
+
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66360
|
+
if (result) {
|
|
66361
|
+
resetErrorInfo(saveErrorInfo);
|
|
66362
|
+
}
|
|
66363
|
+
return result;
|
|
66364
|
+
}
|
|
66365
|
+
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
|
|
66311
66366
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
66312
66367
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
66313
66368
|
}
|
|
66314
66369
|
var result;
|
|
66315
66370
|
var originalErrorInfo;
|
|
66316
66371
|
var varianceCheckFailed = false;
|
|
66317
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
66318
66372
|
var sourceFlags = source.flags;
|
|
66319
66373
|
var targetFlags = target.flags;
|
|
66320
66374
|
if (relation === identityRelation) {
|
|
@@ -66378,7 +66432,6 @@ var ts;
|
|
|
66378
66432
|
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66379
66433
|
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66380
66434
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66381
|
-
resetErrorInfo(saveErrorInfo);
|
|
66382
66435
|
return result;
|
|
66383
66436
|
}
|
|
66384
66437
|
}
|
|
@@ -66503,7 +66556,6 @@ var ts;
|
|
|
66503
66556
|
result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
|
|
66504
66557
|
}
|
|
66505
66558
|
if (result) {
|
|
66506
|
-
resetErrorInfo(saveErrorInfo);
|
|
66507
66559
|
return result;
|
|
66508
66560
|
}
|
|
66509
66561
|
if (reportErrors) {
|
|
@@ -66606,7 +66658,6 @@ var ts;
|
|
|
66606
66658
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66607
66659
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66608
66660
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
66609
|
-
resetErrorInfo(saveErrorInfo);
|
|
66610
66661
|
return 3 /* Maybe */;
|
|
66611
66662
|
}
|
|
66612
66663
|
var c = target;
|
|
@@ -66621,7 +66672,6 @@ var ts;
|
|
|
66621
66672
|
if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
|
|
66622
66673
|
result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
66623
66674
|
if (result) {
|
|
66624
|
-
resetErrorInfo(saveErrorInfo);
|
|
66625
66675
|
return result;
|
|
66626
66676
|
}
|
|
66627
66677
|
}
|
|
@@ -66653,12 +66703,10 @@ var ts;
|
|
|
66653
66703
|
var constraint = getConstraintOfType(source) || unknownType;
|
|
66654
66704
|
// 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
|
|
66655
66705
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66656
|
-
resetErrorInfo(saveErrorInfo);
|
|
66657
66706
|
return result;
|
|
66658
66707
|
}
|
|
66659
66708
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
66660
66709
|
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
66661
|
-
resetErrorInfo(saveErrorInfo);
|
|
66662
66710
|
return result;
|
|
66663
66711
|
}
|
|
66664
66712
|
if (isMappedTypeGenericIndexedAccess(source)) {
|
|
@@ -66667,7 +66715,6 @@ var ts;
|
|
|
66667
66715
|
var indexConstraint = getConstraintOfType(source.indexType);
|
|
66668
66716
|
if (indexConstraint) {
|
|
66669
66717
|
if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
|
|
66670
|
-
resetErrorInfo(saveErrorInfo);
|
|
66671
66718
|
return result;
|
|
66672
66719
|
}
|
|
66673
66720
|
}
|
|
@@ -66676,7 +66723,6 @@ var ts;
|
|
|
66676
66723
|
}
|
|
66677
66724
|
else if (sourceFlags & 4194304 /* Index */) {
|
|
66678
66725
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
66679
|
-
resetErrorInfo(saveErrorInfo);
|
|
66680
66726
|
return result;
|
|
66681
66727
|
}
|
|
66682
66728
|
}
|
|
@@ -66684,7 +66730,6 @@ var ts;
|
|
|
66684
66730
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
66685
66731
|
var constraint = getBaseConstraintOfType(source);
|
|
66686
66732
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66687
|
-
resetErrorInfo(saveErrorInfo);
|
|
66688
66733
|
return result;
|
|
66689
66734
|
}
|
|
66690
66735
|
}
|
|
@@ -66695,14 +66740,12 @@ var ts;
|
|
|
66695
66740
|
return 0 /* False */;
|
|
66696
66741
|
}
|
|
66697
66742
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66698
|
-
resetErrorInfo(saveErrorInfo);
|
|
66699
66743
|
return result;
|
|
66700
66744
|
}
|
|
66701
66745
|
}
|
|
66702
66746
|
else {
|
|
66703
66747
|
var constraint = getBaseConstraintOfType(source);
|
|
66704
66748
|
if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66705
|
-
resetErrorInfo(saveErrorInfo);
|
|
66706
66749
|
return result;
|
|
66707
66750
|
}
|
|
66708
66751
|
}
|
|
@@ -66711,7 +66754,6 @@ var ts;
|
|
|
66711
66754
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66712
66755
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66713
66756
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
66714
|
-
resetErrorInfo(saveErrorInfo);
|
|
66715
66757
|
return 3 /* Maybe */;
|
|
66716
66758
|
}
|
|
66717
66759
|
if (targetFlags & 16777216 /* Conditional */) {
|
|
@@ -66734,7 +66776,6 @@ var ts;
|
|
|
66734
66776
|
result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
|
|
66735
66777
|
}
|
|
66736
66778
|
if (result) {
|
|
66737
|
-
resetErrorInfo(saveErrorInfo);
|
|
66738
66779
|
return result;
|
|
66739
66780
|
}
|
|
66740
66781
|
}
|
|
@@ -66745,7 +66786,6 @@ var ts;
|
|
|
66745
66786
|
var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
|
|
66746
66787
|
if (distributiveConstraint) {
|
|
66747
66788
|
if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66748
|
-
resetErrorInfo(saveErrorInfo);
|
|
66749
66789
|
return result;
|
|
66750
66790
|
}
|
|
66751
66791
|
}
|
|
@@ -66755,7 +66795,6 @@ var ts;
|
|
|
66755
66795
|
var defaultConstraint = getDefaultConstraintOfConditionalType(source);
|
|
66756
66796
|
if (defaultConstraint) {
|
|
66757
66797
|
if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66758
|
-
resetErrorInfo(saveErrorInfo);
|
|
66759
66798
|
return result;
|
|
66760
66799
|
}
|
|
66761
66800
|
}
|
|
@@ -66768,7 +66807,6 @@ var ts;
|
|
|
66768
66807
|
if (isGenericMappedType(target)) {
|
|
66769
66808
|
if (isGenericMappedType(source)) {
|
|
66770
66809
|
if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
|
|
66771
|
-
resetErrorInfo(saveErrorInfo);
|
|
66772
66810
|
return result;
|
|
66773
66811
|
}
|
|
66774
66812
|
}
|
|
@@ -68223,9 +68261,14 @@ var ts;
|
|
|
68223
68261
|
type.flags & 256 /* NumberLiteral */ ? numberType :
|
|
68224
68262
|
type.flags & 2048 /* BigIntLiteral */ ? bigintType :
|
|
68225
68263
|
type.flags & 512 /* BooleanLiteral */ ? booleanType :
|
|
68226
|
-
type.flags & 1048576 /* Union */ ?
|
|
68264
|
+
type.flags & 1048576 /* Union */ ? getBaseTypeOfLiteralTypeUnion(type) :
|
|
68227
68265
|
type;
|
|
68228
68266
|
}
|
|
68267
|
+
function getBaseTypeOfLiteralTypeUnion(type) {
|
|
68268
|
+
var _a;
|
|
68269
|
+
var key = "B" + getTypeId(type);
|
|
68270
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
|
|
68271
|
+
}
|
|
68229
68272
|
function getWidenedLiteralType(type) {
|
|
68230
68273
|
return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
|
|
68231
68274
|
type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType :
|
|
@@ -70368,23 +70411,25 @@ var ts;
|
|
|
70368
70411
|
// For example, when a variable of type number | string | boolean is assigned a value of type number | boolean,
|
|
70369
70412
|
// we remove type string.
|
|
70370
70413
|
function getAssignmentReducedType(declaredType, assignedType) {
|
|
70371
|
-
|
|
70372
|
-
|
|
70373
|
-
|
|
70374
|
-
}
|
|
70375
|
-
var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
|
|
70376
|
-
if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) {
|
|
70377
|
-
reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types
|
|
70378
|
-
}
|
|
70379
|
-
// Our crude heuristic produces an invalid result in some cases: see GH#26130.
|
|
70380
|
-
// For now, when that happens, we give up and don't narrow at all. (This also
|
|
70381
|
-
// means we'll never narrow for erroneous assignments where the assigned type
|
|
70382
|
-
// is not assignable to the declared type.)
|
|
70383
|
-
if (isTypeAssignableTo(assignedType, reducedType)) {
|
|
70384
|
-
return reducedType;
|
|
70385
|
-
}
|
|
70414
|
+
var _a;
|
|
70415
|
+
if (declaredType === assignedType) {
|
|
70416
|
+
return declaredType;
|
|
70386
70417
|
}
|
|
70387
|
-
|
|
70418
|
+
if (assignedType.flags & 131072 /* Never */) {
|
|
70419
|
+
return assignedType;
|
|
70420
|
+
}
|
|
70421
|
+
var key = "A" + getTypeId(declaredType) + "," + getTypeId(assignedType);
|
|
70422
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType));
|
|
70423
|
+
}
|
|
70424
|
+
function getAssignmentReducedTypeWorker(declaredType, assignedType) {
|
|
70425
|
+
var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
|
|
70426
|
+
// Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type.
|
|
70427
|
+
var reducedType = assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
|
|
70428
|
+
// Our crude heuristic produces an invalid result in some cases: see GH#26130.
|
|
70429
|
+
// For now, when that happens, we give up and don't narrow at all. (This also
|
|
70430
|
+
// means we'll never narrow for erroneous assignments where the assigned type
|
|
70431
|
+
// is not assignable to the declared type.)
|
|
70432
|
+
return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
|
|
70388
70433
|
}
|
|
70389
70434
|
function isFunctionObjectType(type) {
|
|
70390
70435
|
// We do a quick check for a "bind" property before performing the more expensive subtype
|
|
@@ -71790,7 +71835,7 @@ var ts;
|
|
|
71790
71835
|
var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
|
|
71791
71836
|
? getTypeOfSymbol(classSymbol)
|
|
71792
71837
|
: getDeclaredTypeOfSymbol(classSymbol);
|
|
71793
|
-
return getNarrowedType(type, targetType, assumeTrue,
|
|
71838
|
+
return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
|
|
71794
71839
|
}
|
|
71795
71840
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
71796
71841
|
// We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows:
|
|
@@ -72041,9 +72086,15 @@ var ts;
|
|
|
72041
72086
|
if (!nonConstructorTypeInUnion)
|
|
72042
72087
|
return type;
|
|
72043
72088
|
}
|
|
72044
|
-
return getNarrowedType(type, targetType, assumeTrue,
|
|
72089
|
+
return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
|
|
72090
|
+
}
|
|
72091
|
+
function getNarrowedType(type, candidate, assumeTrue, checkDerived) {
|
|
72092
|
+
var _a;
|
|
72093
|
+
var key = type.flags & 1048576 /* Union */ ? "N" + getTypeId(type) + "," + getTypeId(candidate) + "," + ((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined;
|
|
72094
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived));
|
|
72045
72095
|
}
|
|
72046
|
-
function
|
|
72096
|
+
function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
|
|
72097
|
+
var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
|
|
72047
72098
|
if (!assumeTrue) {
|
|
72048
72099
|
return filterType(type, function (t) { return !isRelated(t, candidate); });
|
|
72049
72100
|
}
|
|
@@ -72091,7 +72142,7 @@ var ts;
|
|
|
72091
72142
|
var predicateArgument = getTypePredicateArgument(predicate, callExpression);
|
|
72092
72143
|
if (predicateArgument) {
|
|
72093
72144
|
if (isMatchingReference(reference, predicateArgument)) {
|
|
72094
|
-
return getNarrowedType(type, predicate.type, assumeTrue,
|
|
72145
|
+
return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false);
|
|
72095
72146
|
}
|
|
72096
72147
|
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
|
|
72097
72148
|
!(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
|
|
@@ -72099,7 +72150,7 @@ var ts;
|
|
|
72099
72150
|
}
|
|
72100
72151
|
var access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
72101
72152
|
if (access) {
|
|
72102
|
-
return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue,
|
|
72153
|
+
return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); });
|
|
72103
72154
|
}
|
|
72104
72155
|
}
|
|
72105
72156
|
}
|
|
@@ -72276,7 +72327,7 @@ var ts;
|
|
|
72276
72327
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
72277
72328
|
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
72278
72329
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
72279
|
-
: getContextualType(node));
|
|
72330
|
+
: getContextualType(node, /*contextFlags*/ undefined));
|
|
72280
72331
|
return contextualType && !isGenericType(contextualType);
|
|
72281
72332
|
}
|
|
72282
72333
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -72438,9 +72489,7 @@ var ts;
|
|
|
72438
72489
|
getNodeLinks(container).flags |= 8192 /* CaptureArguments */;
|
|
72439
72490
|
return getTypeOfSymbol(symbol);
|
|
72440
72491
|
}
|
|
72441
|
-
|
|
72442
|
-
// for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that
|
|
72443
|
-
if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
|
|
72492
|
+
if (shouldMarkIdentifierAliasReferenced(node)) {
|
|
72444
72493
|
markAliasReferenced(symbol, node);
|
|
72445
72494
|
}
|
|
72446
72495
|
var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
@@ -72574,6 +72623,25 @@ var ts;
|
|
|
72574
72623
|
}
|
|
72575
72624
|
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
|
|
72576
72625
|
}
|
|
72626
|
+
function shouldMarkIdentifierAliasReferenced(node) {
|
|
72627
|
+
var _a;
|
|
72628
|
+
var parent = node.parent;
|
|
72629
|
+
if (parent) {
|
|
72630
|
+
// A property access expression LHS? checkPropertyAccessExpression will handle that.
|
|
72631
|
+
if (ts.isPropertyAccessExpression(parent) && parent.expression === node) {
|
|
72632
|
+
return false;
|
|
72633
|
+
}
|
|
72634
|
+
// Next two check for an identifier inside a type only export.
|
|
72635
|
+
if (ts.isExportSpecifier(parent) && parent.isTypeOnly) {
|
|
72636
|
+
return false;
|
|
72637
|
+
}
|
|
72638
|
+
var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent;
|
|
72639
|
+
if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) {
|
|
72640
|
+
return false;
|
|
72641
|
+
}
|
|
72642
|
+
}
|
|
72643
|
+
return true;
|
|
72644
|
+
}
|
|
72577
72645
|
function isInsideFunctionOrInstancePropertyInitializer(node, threshold) {
|
|
72578
72646
|
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); });
|
|
72579
72647
|
}
|
|
@@ -73123,7 +73191,7 @@ var ts;
|
|
|
73123
73191
|
// We have an object literal method. Check if the containing object literal has a contextual type
|
|
73124
73192
|
// that includes a ThisType<T>. If so, T is the contextual type for 'this'. We continue looking in
|
|
73125
73193
|
// any directly enclosing object literals.
|
|
73126
|
-
var contextualType = getApparentTypeOfContextualType(containingLiteral);
|
|
73194
|
+
var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined);
|
|
73127
73195
|
var literal = containingLiteral;
|
|
73128
73196
|
var type = contextualType;
|
|
73129
73197
|
while (type) {
|
|
@@ -73135,7 +73203,7 @@ var ts;
|
|
|
73135
73203
|
break;
|
|
73136
73204
|
}
|
|
73137
73205
|
literal = literal.parent.parent;
|
|
73138
|
-
type = getApparentTypeOfContextualType(literal);
|
|
73206
|
+
type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined);
|
|
73139
73207
|
}
|
|
73140
73208
|
// There was no contextual ThisType<T> for the containing object literal, so the contextual type
|
|
73141
73209
|
// for 'this' is the non-null form of the contextual type for the containing object literal or
|
|
@@ -73192,7 +73260,7 @@ var ts;
|
|
|
73192
73260
|
tryGetTypeAtPosition(contextualSignature, index);
|
|
73193
73261
|
}
|
|
73194
73262
|
}
|
|
73195
|
-
function getContextualTypeForVariableLikeDeclaration(declaration) {
|
|
73263
|
+
function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) {
|
|
73196
73264
|
var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
|
|
73197
73265
|
if (typeNode) {
|
|
73198
73266
|
return getTypeFromTypeNode(typeNode);
|
|
@@ -73201,18 +73269,18 @@ var ts;
|
|
|
73201
73269
|
case 164 /* Parameter */:
|
|
73202
73270
|
return getContextuallyTypedParameterType(declaration);
|
|
73203
73271
|
case 203 /* BindingElement */:
|
|
73204
|
-
return getContextualTypeForBindingElement(declaration);
|
|
73272
|
+
return getContextualTypeForBindingElement(declaration, contextFlags);
|
|
73205
73273
|
case 167 /* PropertyDeclaration */:
|
|
73206
73274
|
if (ts.isStatic(declaration)) {
|
|
73207
|
-
return getContextualTypeForStaticPropertyDeclaration(declaration);
|
|
73275
|
+
return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags);
|
|
73208
73276
|
}
|
|
73209
73277
|
// By default, do nothing and return undefined - only the above cases have context implied by a parent
|
|
73210
73278
|
}
|
|
73211
73279
|
}
|
|
73212
|
-
function getContextualTypeForBindingElement(declaration) {
|
|
73280
|
+
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
73213
73281
|
var parent = declaration.parent.parent;
|
|
73214
73282
|
var name = declaration.propertyName || declaration.name;
|
|
73215
|
-
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
73283
|
+
var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) ||
|
|
73216
73284
|
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
73217
73285
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
73218
73286
|
return undefined;
|
|
@@ -73228,8 +73296,8 @@ var ts;
|
|
|
73228
73296
|
return getTypeOfPropertyOfType(parentType, text);
|
|
73229
73297
|
}
|
|
73230
73298
|
}
|
|
73231
|
-
function getContextualTypeForStaticPropertyDeclaration(declaration) {
|
|
73232
|
-
var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent);
|
|
73299
|
+
function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) {
|
|
73300
|
+
var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags);
|
|
73233
73301
|
if (!parentType)
|
|
73234
73302
|
return undefined;
|
|
73235
73303
|
return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
|
|
@@ -73245,7 +73313,7 @@ var ts;
|
|
|
73245
73313
|
function getContextualTypeForInitializerExpression(node, contextFlags) {
|
|
73246
73314
|
var declaration = node.parent;
|
|
73247
73315
|
if (ts.hasInitializer(declaration) && node === declaration.initializer) {
|
|
73248
|
-
var result = getContextualTypeForVariableLikeDeclaration(declaration);
|
|
73316
|
+
var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags);
|
|
73249
73317
|
if (result) {
|
|
73250
73318
|
return result;
|
|
73251
73319
|
}
|
|
@@ -73255,10 +73323,10 @@ var ts;
|
|
|
73255
73323
|
}
|
|
73256
73324
|
return undefined;
|
|
73257
73325
|
}
|
|
73258
|
-
function getContextualTypeForReturnExpression(node) {
|
|
73326
|
+
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
73259
73327
|
var func = ts.getContainingFunction(node);
|
|
73260
73328
|
if (func) {
|
|
73261
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73329
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73262
73330
|
if (contextualReturnType) {
|
|
73263
73331
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73264
73332
|
if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
|
|
@@ -73288,11 +73356,11 @@ var ts;
|
|
|
73288
73356
|
}
|
|
73289
73357
|
return undefined;
|
|
73290
73358
|
}
|
|
73291
|
-
function getContextualTypeForYieldOperand(node) {
|
|
73359
|
+
function getContextualTypeForYieldOperand(node, contextFlags) {
|
|
73292
73360
|
var func = ts.getContainingFunction(node);
|
|
73293
73361
|
if (func) {
|
|
73294
73362
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73295
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73363
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73296
73364
|
if (contextualReturnType) {
|
|
73297
73365
|
return node.asteriskToken
|
|
73298
73366
|
? contextualReturnType
|
|
@@ -73316,14 +73384,14 @@ var ts;
|
|
|
73316
73384
|
}
|
|
73317
73385
|
function getContextualIterationType(kind, functionDecl) {
|
|
73318
73386
|
var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */);
|
|
73319
|
-
var contextualReturnType = getContextualReturnType(functionDecl);
|
|
73387
|
+
var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined);
|
|
73320
73388
|
if (contextualReturnType) {
|
|
73321
73389
|
return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
|
|
73322
73390
|
|| undefined;
|
|
73323
73391
|
}
|
|
73324
73392
|
return undefined;
|
|
73325
73393
|
}
|
|
73326
|
-
function getContextualReturnType(functionDecl) {
|
|
73394
|
+
function getContextualReturnType(functionDecl, contextFlags) {
|
|
73327
73395
|
// If the containing function has a return type annotation, is a constructor, or is a get accessor whose
|
|
73328
73396
|
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
|
|
73329
73397
|
var returnType = getReturnTypeFromAnnotation(functionDecl);
|
|
@@ -73338,7 +73406,7 @@ var ts;
|
|
|
73338
73406
|
}
|
|
73339
73407
|
var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl);
|
|
73340
73408
|
if (iife) {
|
|
73341
|
-
return getContextualType(iife);
|
|
73409
|
+
return getContextualType(iife, contextFlags);
|
|
73342
73410
|
}
|
|
73343
73411
|
return undefined;
|
|
73344
73412
|
}
|
|
@@ -73591,7 +73659,7 @@ var ts;
|
|
|
73591
73659
|
}
|
|
73592
73660
|
function getContextualTypeForObjectLiteralElement(element, contextFlags) {
|
|
73593
73661
|
var objectLiteral = element.parent;
|
|
73594
|
-
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element);
|
|
73662
|
+
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags);
|
|
73595
73663
|
if (propertyAssignmentType) {
|
|
73596
73664
|
return propertyAssignmentType;
|
|
73597
73665
|
}
|
|
@@ -73786,9 +73854,9 @@ var ts;
|
|
|
73786
73854
|
return getContextualTypeForInitializerExpression(node, contextFlags);
|
|
73787
73855
|
case 214 /* ArrowFunction */:
|
|
73788
73856
|
case 247 /* ReturnStatement */:
|
|
73789
|
-
return getContextualTypeForReturnExpression(node);
|
|
73857
|
+
return getContextualTypeForReturnExpression(node, contextFlags);
|
|
73790
73858
|
case 224 /* YieldExpression */:
|
|
73791
|
-
return getContextualTypeForYieldOperand(parent);
|
|
73859
|
+
return getContextualTypeForYieldOperand(parent, contextFlags);
|
|
73792
73860
|
case 218 /* AwaitExpression */:
|
|
73793
73861
|
return getContextualTypeForAwaitOperand(parent, contextFlags);
|
|
73794
73862
|
case 208 /* CallExpression */:
|
|
@@ -73836,7 +73904,7 @@ var ts;
|
|
|
73836
73904
|
}
|
|
73837
73905
|
return undefined;
|
|
73838
73906
|
function tryFindWhenConstTypeReference(node) {
|
|
73839
|
-
return getContextualType(node);
|
|
73907
|
+
return getContextualType(node, contextFlags);
|
|
73840
73908
|
}
|
|
73841
73909
|
}
|
|
73842
73910
|
function getInferenceContext(node) {
|
|
@@ -74138,7 +74206,7 @@ var ts;
|
|
|
74138
74206
|
var elementCount = elements.length;
|
|
74139
74207
|
var elementTypes = [];
|
|
74140
74208
|
var elementFlags = [];
|
|
74141
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74209
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
74142
74210
|
var inDestructuringPattern = ts.isAssignmentTarget(node);
|
|
74143
74211
|
var inConstContext = isConstContext(node);
|
|
74144
74212
|
var hasOmittedExpression = false;
|
|
@@ -74309,7 +74377,7 @@ var ts;
|
|
|
74309
74377
|
var propertiesTable = ts.createSymbolTable();
|
|
74310
74378
|
var propertiesArray = [];
|
|
74311
74379
|
var spread = emptyObjectType;
|
|
74312
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74380
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
74313
74381
|
var contextualTypeHasPattern = contextualType && contextualType.pattern &&
|
|
74314
74382
|
(contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */);
|
|
74315
74383
|
var inConstContext = isConstContext(node);
|
|
@@ -74648,7 +74716,7 @@ var ts;
|
|
|
74648
74716
|
if (explicitlySpecifyChildrenAttribute) {
|
|
74649
74717
|
error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
|
|
74650
74718
|
}
|
|
74651
|
-
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
|
|
74719
|
+
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined);
|
|
74652
74720
|
var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
|
|
74653
74721
|
// 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
|
|
74654
74722
|
var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName);
|
|
@@ -77111,7 +77179,7 @@ var ts;
|
|
|
77111
77179
|
argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
77112
77180
|
if (inferenceContext) {
|
|
77113
77181
|
var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
77114
|
-
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext
|
|
77182
|
+
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
77115
77183
|
// If the original signature has a generic rest type, instantiation may produce a
|
|
77116
77184
|
// signature with different arity and we need to perform another arity check.
|
|
77117
77185
|
if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
|
|
@@ -78488,17 +78556,6 @@ var ts;
|
|
|
78488
78556
|
}
|
|
78489
78557
|
}
|
|
78490
78558
|
}
|
|
78491
|
-
var restType = getEffectiveRestType(context);
|
|
78492
|
-
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
78493
|
-
// The contextual signature has a generic rest parameter. We first instantiate the contextual
|
|
78494
|
-
// signature (without fixing type parameters) and assign types to contextually typed parameters.
|
|
78495
|
-
var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
|
|
78496
|
-
assignContextualParameterTypes(signature, instantiatedContext);
|
|
78497
|
-
// We then infer from a tuple type representing the parameters that correspond to the contextual
|
|
78498
|
-
// rest parameter.
|
|
78499
|
-
var restPos = getParameterCount(context) - 1;
|
|
78500
|
-
inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
|
|
78501
|
-
}
|
|
78502
78559
|
}
|
|
78503
78560
|
function assignContextualParameterTypes(signature, context) {
|
|
78504
78561
|
if (context.typeParameters) {
|
|
@@ -78691,7 +78748,7 @@ var ts;
|
|
|
78691
78748
|
var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
|
|
78692
78749
|
var contextualType = !contextualSignature ? undefined :
|
|
78693
78750
|
contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
|
|
78694
|
-
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
|
|
78751
|
+
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined);
|
|
78695
78752
|
if (isGenerator) {
|
|
78696
78753
|
yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync);
|
|
78697
78754
|
returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync);
|
|
@@ -78762,7 +78819,7 @@ var ts;
|
|
|
78762
78819
|
nextType = iterationTypes && iterationTypes.nextType;
|
|
78763
78820
|
}
|
|
78764
78821
|
else {
|
|
78765
|
-
nextType = getContextualType(yieldExpression);
|
|
78822
|
+
nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined);
|
|
78766
78823
|
}
|
|
78767
78824
|
if (nextType)
|
|
78768
78825
|
ts.pushIfUnique(nextTypes, nextType);
|
|
@@ -78971,11 +79028,16 @@ var ts;
|
|
|
78971
79028
|
if (isContextSensitive(node)) {
|
|
78972
79029
|
if (contextualSignature) {
|
|
78973
79030
|
var inferenceContext = getInferenceContext(node);
|
|
79031
|
+
var instantiatedContextualSignature = void 0;
|
|
78974
79032
|
if (checkMode && checkMode & 2 /* Inferential */) {
|
|
78975
79033
|
inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
|
|
79034
|
+
var restType = getEffectiveRestType(contextualSignature);
|
|
79035
|
+
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
79036
|
+
instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper);
|
|
79037
|
+
}
|
|
78976
79038
|
}
|
|
78977
|
-
|
|
78978
|
-
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
|
|
79039
|
+
instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ?
|
|
79040
|
+
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature);
|
|
78979
79041
|
assignContextualParameterTypes(signature, instantiatedContextualSignature);
|
|
78980
79042
|
}
|
|
78981
79043
|
else {
|
|
@@ -80217,7 +80279,7 @@ var ts;
|
|
|
80217
80279
|
type = anyType;
|
|
80218
80280
|
addLazyDiagnostic(function () {
|
|
80219
80281
|
if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
|
|
80220
|
-
var contextualType = getContextualType(node);
|
|
80282
|
+
var contextualType = getContextualType(node, /*contextFlags*/ undefined);
|
|
80221
80283
|
if (!contextualType || isTypeAny(contextualType)) {
|
|
80222
80284
|
error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
|
|
80223
80285
|
}
|
|
@@ -80258,7 +80320,7 @@ var ts;
|
|
|
80258
80320
|
texts.push(span.literal.text);
|
|
80259
80321
|
types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
|
|
80260
80322
|
}
|
|
80261
|
-
return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
|
|
80323
|
+
return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
|
|
80262
80324
|
}
|
|
80263
80325
|
function isTemplateLiteralContextualType(type) {
|
|
80264
80326
|
return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) ||
|
|
@@ -80286,7 +80348,7 @@ var ts;
|
|
|
80286
80348
|
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
|
|
80287
80349
|
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
|
|
80288
80350
|
// here would be to not mark contextually typed literals as fresh in the first place.
|
|
80289
|
-
var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
|
|
80351
|
+
var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ?
|
|
80290
80352
|
getRegularTypeOfLiteralType(type) : type;
|
|
80291
80353
|
return result;
|
|
80292
80354
|
}
|
|
@@ -80401,7 +80463,7 @@ var ts;
|
|
|
80401
80463
|
var type = checkExpression(node, checkMode, forceTuple);
|
|
80402
80464
|
return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
|
|
80403
80465
|
isTypeAssertion(node) ? type :
|
|
80404
|
-
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
|
|
80466
|
+
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined));
|
|
80405
80467
|
}
|
|
80406
80468
|
function checkPropertyAssignment(node, checkMode) {
|
|
80407
80469
|
// Do not use hasDynamicName here, because that returns false for well known symbols.
|
|
@@ -86383,7 +86445,9 @@ var ts;
|
|
|
86383
86445
|
error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
|
|
86384
86446
|
}
|
|
86385
86447
|
else {
|
|
86386
|
-
|
|
86448
|
+
if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) {
|
|
86449
|
+
markExportAsReferenced(node);
|
|
86450
|
+
}
|
|
86387
86451
|
var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
|
|
86388
86452
|
if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) {
|
|
86389
86453
|
checkExpressionCached(node.propertyName || node.name);
|
|
@@ -89744,9 +89808,6 @@ var ts;
|
|
|
89744
89808
|
else {
|
|
89745
89809
|
return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
|
89746
89810
|
}
|
|
89747
|
-
if (!isConstOrReadonly || isInvalidInitializer) {
|
|
89748
|
-
return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
|
89749
|
-
}
|
|
89750
89811
|
}
|
|
89751
89812
|
}
|
|
89752
89813
|
function checkGrammarVariableDeclaration(node) {
|
|
@@ -111531,7 +111592,7 @@ var ts;
|
|
|
111531
111592
|
return;
|
|
111532
111593
|
}
|
|
111533
111594
|
// Make sure not to write js file and source map file if any of them cannot be written
|
|
111534
|
-
if (
|
|
111595
|
+
if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) {
|
|
111535
111596
|
emitSkipped = true;
|
|
111536
111597
|
return;
|
|
111537
111598
|
}
|
|
@@ -124793,7 +124854,6 @@ var ts;
|
|
|
124793
124854
|
var parsedConfigs; // Parsed commandline and watching cached for referenced projects
|
|
124794
124855
|
var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
|
|
124795
124856
|
var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
|
|
124796
|
-
var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
|
|
124797
124857
|
var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
|
|
124798
124858
|
var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
|
|
124799
124859
|
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
|
|
@@ -124946,12 +125006,12 @@ var ts;
|
|
|
124946
125006
|
var program = getCurrentBuilderProgram();
|
|
124947
125007
|
if (hasChangedCompilerOptions) {
|
|
124948
125008
|
newLine = updateNewLine();
|
|
124949
|
-
if (program &&
|
|
125009
|
+
if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
|
|
124950
125010
|
resolutionCache.clear();
|
|
124951
125011
|
}
|
|
124952
125012
|
}
|
|
124953
125013
|
// All resolutions are invalid if user provided resolutions
|
|
124954
|
-
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution
|
|
125014
|
+
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
|
|
124955
125015
|
if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
|
124956
125016
|
if (hasChangedConfigFileParsingErrors) {
|
|
124957
125017
|
if (reportFileChangeDetectedOnCreateProgram) {
|
|
@@ -124967,7 +125027,6 @@ var ts;
|
|
|
124967
125027
|
}
|
|
124968
125028
|
createNewProgram(hasInvalidatedResolution);
|
|
124969
125029
|
}
|
|
124970
|
-
changesAffectResolution = false; // reset for next sync
|
|
124971
125030
|
reportFileChangeDetectedOnCreateProgram = false;
|
|
124972
125031
|
if (host.afterProgramCreate && program !== builderProgram) {
|
|
124973
125032
|
host.afterProgramCreate(builderProgram);
|
|
@@ -126348,7 +126407,7 @@ var ts;
|
|
|
126348
126407
|
}
|
|
126349
126408
|
function afterProgramDone(state, program, config) {
|
|
126350
126409
|
if (program) {
|
|
126351
|
-
if (
|
|
126410
|
+
if (state.write)
|
|
126352
126411
|
ts.listFiles(program, state.write);
|
|
126353
126412
|
if (state.host.afterProgramEmitAndDiagnostics) {
|
|
126354
126413
|
state.host.afterProgramEmitAndDiagnostics(program);
|
|
@@ -134536,7 +134595,7 @@ var ts;
|
|
|
134536
134595
|
var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
|
|
134537
134596
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
134538
134597
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
134539
|
-
var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ :
|
|
134598
|
+
var builderFlags = 33554432 /* OmitThisParameter */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */);
|
|
134540
134599
|
switch (declaration.kind) {
|
|
134541
134600
|
case 166 /* PropertySignature */:
|
|
134542
134601
|
case 167 /* PropertyDeclaration */:
|
|
@@ -166081,20 +166140,25 @@ var ts;
|
|
|
166081
166140
|
return this.documentationComment;
|
|
166082
166141
|
};
|
|
166083
166142
|
SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) {
|
|
166084
|
-
|
|
166085
|
-
|
|
166143
|
+
if (context) {
|
|
166144
|
+
if (ts.isGetAccessor(context)) {
|
|
166086
166145
|
if (!this.contextualGetAccessorDocumentationComment) {
|
|
166087
166146
|
this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
166088
166147
|
}
|
|
166089
|
-
|
|
166090
|
-
|
|
166148
|
+
if (ts.length(this.contextualGetAccessorDocumentationComment)) {
|
|
166149
|
+
return this.contextualGetAccessorDocumentationComment;
|
|
166150
|
+
}
|
|
166151
|
+
}
|
|
166152
|
+
if (ts.isSetAccessor(context)) {
|
|
166091
166153
|
if (!this.contextualSetAccessorDocumentationComment) {
|
|
166092
166154
|
this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
166093
166155
|
}
|
|
166094
|
-
|
|
166095
|
-
|
|
166096
|
-
|
|
166156
|
+
if (ts.length(this.contextualSetAccessorDocumentationComment)) {
|
|
166157
|
+
return this.contextualSetAccessorDocumentationComment;
|
|
166158
|
+
}
|
|
166159
|
+
}
|
|
166097
166160
|
}
|
|
166161
|
+
return this.getDocumentationComment(checker);
|
|
166098
166162
|
};
|
|
166099
166163
|
SymbolObject.prototype.getJsDocTags = function (checker) {
|
|
166100
166164
|
if (this.tags === undefined) {
|
|
@@ -166103,20 +166167,25 @@ var ts;
|
|
|
166103
166167
|
return this.tags;
|
|
166104
166168
|
};
|
|
166105
166169
|
SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
|
|
166106
|
-
|
|
166107
|
-
|
|
166170
|
+
if (context) {
|
|
166171
|
+
if (ts.isGetAccessor(context)) {
|
|
166108
166172
|
if (!this.contextualGetAccessorTags) {
|
|
166109
166173
|
this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
166110
166174
|
}
|
|
166111
|
-
|
|
166112
|
-
|
|
166175
|
+
if (ts.length(this.contextualGetAccessorTags)) {
|
|
166176
|
+
return this.contextualGetAccessorTags;
|
|
166177
|
+
}
|
|
166178
|
+
}
|
|
166179
|
+
if (ts.isSetAccessor(context)) {
|
|
166113
166180
|
if (!this.contextualSetAccessorTags) {
|
|
166114
166181
|
this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
166115
166182
|
}
|
|
166116
|
-
|
|
166117
|
-
|
|
166118
|
-
|
|
166183
|
+
if (ts.length(this.contextualSetAccessorTags)) {
|
|
166184
|
+
return this.contextualSetAccessorTags;
|
|
166185
|
+
}
|
|
166186
|
+
}
|
|
166119
166187
|
}
|
|
166188
|
+
return this.getJsDocTags(checker);
|
|
166120
166189
|
};
|
|
166121
166190
|
return SymbolObject;
|
|
166122
166191
|
}());
|
|
@@ -166867,7 +166936,10 @@ var ts;
|
|
|
166867
166936
|
program = undefined; // TODO: GH#18217
|
|
166868
166937
|
lastTypesRootVersion = typeRootsVersion;
|
|
166869
166938
|
}
|
|
166870
|
-
|
|
166939
|
+
// This array is retained by the program and will be used to determine if the program is up to date,
|
|
166940
|
+
// so we need to make a copy in case the host mutates the underlying array - otherwise it would look
|
|
166941
|
+
// like every program always has the host's current list of root files.
|
|
166942
|
+
var rootFileNames = host.getScriptFileNames().slice();
|
|
166871
166943
|
// Get a fresh cache of the host information
|
|
166872
166944
|
var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
|
|
166873
166945
|
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
|