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/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220707";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -2774,6 +2774,22 @@ var ts;
|
|
|
2774
2774
|
return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true);
|
|
2775
2775
|
}
|
|
2776
2776
|
Debug.formatFlowFlags = formatFlowFlags;
|
|
2777
|
+
function formatRelationComparisonResult(result) {
|
|
2778
|
+
return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true);
|
|
2779
|
+
}
|
|
2780
|
+
Debug.formatRelationComparisonResult = formatRelationComparisonResult;
|
|
2781
|
+
function formatCheckMode(mode) {
|
|
2782
|
+
return formatEnum(mode, ts.CheckMode, /*isFlags*/ true);
|
|
2783
|
+
}
|
|
2784
|
+
Debug.formatCheckMode = formatCheckMode;
|
|
2785
|
+
function formatSignatureCheckMode(mode) {
|
|
2786
|
+
return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true);
|
|
2787
|
+
}
|
|
2788
|
+
Debug.formatSignatureCheckMode = formatSignatureCheckMode;
|
|
2789
|
+
function formatTypeFacts(facts) {
|
|
2790
|
+
return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true);
|
|
2791
|
+
}
|
|
2792
|
+
Debug.formatTypeFacts = formatTypeFacts;
|
|
2777
2793
|
var isDebugInfoEnabled = false;
|
|
2778
2794
|
var extendedDebugModule;
|
|
2779
2795
|
function extendedDebug() {
|
|
@@ -4726,6 +4742,7 @@ var ts;
|
|
|
4726
4742
|
NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4727
4743
|
NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4728
4744
|
NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4745
|
+
NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
|
|
4729
4746
|
// Error handling
|
|
4730
4747
|
NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral";
|
|
4731
4748
|
NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier";
|
|
@@ -4766,6 +4783,7 @@ var ts;
|
|
|
4766
4783
|
TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope";
|
|
4767
4784
|
TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType";
|
|
4768
4785
|
TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction";
|
|
4786
|
+
TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter";
|
|
4769
4787
|
// Error Handling
|
|
4770
4788
|
TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType";
|
|
4771
4789
|
// TypeFormatFlags exclusive
|
|
@@ -4777,7 +4795,7 @@ var ts;
|
|
|
4777
4795
|
TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument";
|
|
4778
4796
|
TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias";
|
|
4779
4797
|
/** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike";
|
|
4780
|
-
TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] =
|
|
4798
|
+
TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask";
|
|
4781
4799
|
})(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {}));
|
|
4782
4800
|
var SymbolFormatFlags;
|
|
4783
4801
|
(function (SymbolFormatFlags) {
|
|
@@ -19509,7 +19527,8 @@ var ts;
|
|
|
19509
19527
|
function getDeclarationModifierFlagsFromSymbol(s, isWrite) {
|
|
19510
19528
|
if (isWrite === void 0) { isWrite = false; }
|
|
19511
19529
|
if (s.valueDeclaration) {
|
|
19512
|
-
var declaration = (isWrite && s.declarations && ts.find(s.declarations,
|
|
19530
|
+
var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration))
|
|
19531
|
+
|| (s.flags & 32768 /* GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration;
|
|
19513
19532
|
var flags = ts.getCombinedModifierFlags(declaration);
|
|
19514
19533
|
return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */;
|
|
19515
19534
|
}
|
|
@@ -20184,7 +20203,7 @@ var ts;
|
|
|
20184
20203
|
// Excludes declaration files - they still require an explicit `export {}` or the like
|
|
20185
20204
|
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
|
20186
20205
|
// that aren't esm-mode (meaning not in a `type: module` scope).
|
|
20187
|
-
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20206
|
+
return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */, ".mjs" /* Mjs */, ".mts" /* Mts */]))) && !file.isDeclarationFile ? true : undefined;
|
|
20188
20207
|
}
|
|
20189
20208
|
function getSetExternalModuleIndicator(options) {
|
|
20190
20209
|
// TODO: Should this callback be cached?
|
|
@@ -20207,10 +20226,7 @@ var ts;
|
|
|
20207
20226
|
if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
|
|
20208
20227
|
checks.push(isFileModuleFromUsingJSXTag);
|
|
20209
20228
|
}
|
|
20210
|
-
|
|
20211
|
-
if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
20212
|
-
checks.push(isFileForcedToBeModuleByFormat);
|
|
20213
|
-
}
|
|
20229
|
+
checks.push(isFileForcedToBeModuleByFormat);
|
|
20214
20230
|
var combined_1 = ts.or.apply(void 0, checks);
|
|
20215
20231
|
var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
|
|
20216
20232
|
return callback;
|
|
@@ -33930,10 +33946,10 @@ var ts;
|
|
|
33930
33946
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
33931
33947
|
var modifiers = parseModifiers();
|
|
33932
33948
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
33933
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */);
|
|
33949
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */, 4 /* Type */);
|
|
33934
33950
|
}
|
|
33935
33951
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
33936
|
-
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */);
|
|
33952
|
+
return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */, 4 /* Type */);
|
|
33937
33953
|
}
|
|
33938
33954
|
if (isIndexSignature()) {
|
|
33939
33955
|
return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers);
|
|
@@ -35979,10 +35995,10 @@ var ts;
|
|
|
35979
35995
|
var decorators = parseDecorators();
|
|
35980
35996
|
var modifiers = parseModifiers();
|
|
35981
35997
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
35982
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
35998
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
35983
35999
|
}
|
|
35984
36000
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
35985
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
36001
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
35986
36002
|
}
|
|
35987
36003
|
var asteriskToken = parseOptionalToken(41 /* AsteriskToken */);
|
|
35988
36004
|
var tokenIsIdentifier = isIdentifier();
|
|
@@ -36674,9 +36690,15 @@ var ts;
|
|
|
36674
36690
|
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */);
|
|
36675
36691
|
}
|
|
36676
36692
|
function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
|
|
36677
|
-
if (token() !== 18 /* OpenBraceToken */
|
|
36678
|
-
|
|
36679
|
-
|
|
36693
|
+
if (token() !== 18 /* OpenBraceToken */) {
|
|
36694
|
+
if (flags & 4 /* Type */) {
|
|
36695
|
+
parseTypeMemberSemicolon();
|
|
36696
|
+
return;
|
|
36697
|
+
}
|
|
36698
|
+
if (canParseSemicolon()) {
|
|
36699
|
+
parseSemicolon();
|
|
36700
|
+
return;
|
|
36701
|
+
}
|
|
36680
36702
|
}
|
|
36681
36703
|
return parseFunctionBlock(flags, diagnosticMessage);
|
|
36682
36704
|
}
|
|
@@ -36880,12 +36902,12 @@ var ts;
|
|
|
36880
36902
|
}
|
|
36881
36903
|
return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
|
|
36882
36904
|
}
|
|
36883
|
-
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
|
|
36905
|
+
function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) {
|
|
36884
36906
|
var name = parsePropertyName();
|
|
36885
36907
|
var typeParameters = parseTypeParameters();
|
|
36886
36908
|
var parameters = parseParameters(0 /* None */);
|
|
36887
36909
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
36888
|
-
var body = parseFunctionBlockOrSemicolon(
|
|
36910
|
+
var body = parseFunctionBlockOrSemicolon(flags);
|
|
36889
36911
|
var node = kind === 172 /* GetAccessor */
|
|
36890
36912
|
? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
|
|
36891
36913
|
: factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
|
|
@@ -37072,10 +37094,10 @@ var ts;
|
|
|
37072
37094
|
return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
37073
37095
|
}
|
|
37074
37096
|
if (parseContextualModifier(136 /* GetKeyword */)) {
|
|
37075
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */);
|
|
37097
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */, 0 /* None */);
|
|
37076
37098
|
}
|
|
37077
37099
|
if (parseContextualModifier(149 /* SetKeyword */)) {
|
|
37078
|
-
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */);
|
|
37100
|
+
return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */, 0 /* None */);
|
|
37079
37101
|
}
|
|
37080
37102
|
if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) {
|
|
37081
37103
|
var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
@@ -48479,7 +48501,7 @@ var ts;
|
|
|
48479
48501
|
// Masks
|
|
48480
48502
|
TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
|
|
48481
48503
|
TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask";
|
|
48482
|
-
})(TypeFacts || (TypeFacts = {}));
|
|
48504
|
+
})(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {}));
|
|
48483
48505
|
var typeofNEFacts = new ts.Map(ts.getEntries({
|
|
48484
48506
|
string: 256 /* TypeofNEString */,
|
|
48485
48507
|
number: 512 /* TypeofNENumber */,
|
|
@@ -48514,7 +48536,7 @@ var ts;
|
|
|
48514
48536
|
CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement";
|
|
48515
48537
|
// e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`,
|
|
48516
48538
|
// we need to preserve generic types instead of substituting them for constraints
|
|
48517
|
-
})(CheckMode || (CheckMode = {}));
|
|
48539
|
+
})(CheckMode = ts.CheckMode || (ts.CheckMode = {}));
|
|
48518
48540
|
var SignatureCheckMode;
|
|
48519
48541
|
(function (SignatureCheckMode) {
|
|
48520
48542
|
SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback";
|
|
@@ -48522,7 +48544,7 @@ var ts;
|
|
|
48522
48544
|
SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes";
|
|
48523
48545
|
SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity";
|
|
48524
48546
|
SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback";
|
|
48525
|
-
})(SignatureCheckMode || (SignatureCheckMode = {}));
|
|
48547
|
+
})(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {}));
|
|
48526
48548
|
var IntersectionState;
|
|
48527
48549
|
(function (IntersectionState) {
|
|
48528
48550
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
@@ -48874,7 +48896,7 @@ var ts;
|
|
|
48874
48896
|
},
|
|
48875
48897
|
getContextualTypeForObjectLiteralElement: function (nodeIn) {
|
|
48876
48898
|
var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
|
|
48877
|
-
return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
|
|
48899
|
+
return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined;
|
|
48878
48900
|
},
|
|
48879
48901
|
getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
|
|
48880
48902
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -48882,7 +48904,7 @@ var ts;
|
|
|
48882
48904
|
},
|
|
48883
48905
|
getContextualTypeForJsxAttribute: function (nodeIn) {
|
|
48884
48906
|
var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
|
|
48885
|
-
return node && getContextualTypeForJsxAttribute(node);
|
|
48907
|
+
return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined);
|
|
48886
48908
|
},
|
|
48887
48909
|
isContextSensitive: isContextSensitive,
|
|
48888
48910
|
getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType,
|
|
@@ -49088,6 +49110,7 @@ var ts;
|
|
|
49088
49110
|
var stringMappingTypes = new ts.Map();
|
|
49089
49111
|
var substitutionTypes = new ts.Map();
|
|
49090
49112
|
var subtypeReductionCache = new ts.Map();
|
|
49113
|
+
var cachedTypes = new ts.Map();
|
|
49091
49114
|
var evolvingArrayTypes = [];
|
|
49092
49115
|
var undefinedProperties = new ts.Map();
|
|
49093
49116
|
var markerTypes = new ts.Set();
|
|
@@ -49341,6 +49364,14 @@ var ts;
|
|
|
49341
49364
|
];
|
|
49342
49365
|
initializeTypeChecker();
|
|
49343
49366
|
return checker;
|
|
49367
|
+
function getCachedType(key) {
|
|
49368
|
+
return key ? cachedTypes.get(key) : undefined;
|
|
49369
|
+
}
|
|
49370
|
+
function setCachedType(key, type) {
|
|
49371
|
+
if (key)
|
|
49372
|
+
cachedTypes.set(key, type);
|
|
49373
|
+
return type;
|
|
49374
|
+
}
|
|
49344
49375
|
function getJsxNamespace(location) {
|
|
49345
49376
|
if (location) {
|
|
49346
49377
|
var file = ts.getSourceFileOfNode(location);
|
|
@@ -52596,13 +52627,25 @@ var ts;
|
|
|
52596
52627
|
&& isDeclarationVisible(declaration.parent)) {
|
|
52597
52628
|
return addVisibleAlias(declaration, declaration);
|
|
52598
52629
|
}
|
|
52599
|
-
else if (
|
|
52600
|
-
&& ts.
|
|
52601
|
-
|
|
52602
|
-
|
|
52603
|
-
|
|
52604
|
-
|
|
52605
|
-
|
|
52630
|
+
else if (ts.isBindingElement(declaration)) {
|
|
52631
|
+
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
|
|
52632
|
+
&& ts.isVariableDeclaration(declaration.parent.parent)
|
|
52633
|
+
&& ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
|
|
52634
|
+
&& !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */)
|
|
52635
|
+
&& declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file)
|
|
52636
|
+
&& isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
|
|
52637
|
+
return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
|
|
52638
|
+
}
|
|
52639
|
+
else if (symbol.flags & 2 /* BlockScopedVariable */) {
|
|
52640
|
+
var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement);
|
|
52641
|
+
if (ts.hasSyntacticModifier(variableStatement, 1 /* Export */)) {
|
|
52642
|
+
return true;
|
|
52643
|
+
}
|
|
52644
|
+
if (!isDeclarationVisible(variableStatement.parent)) {
|
|
52645
|
+
return false;
|
|
52646
|
+
}
|
|
52647
|
+
return addVisibleAlias(declaration, variableStatement);
|
|
52648
|
+
}
|
|
52606
52649
|
}
|
|
52607
52650
|
// Declaration is not visible
|
|
52608
52651
|
return false;
|
|
@@ -52735,7 +52778,7 @@ var ts;
|
|
|
52735
52778
|
}
|
|
52736
52779
|
function toNodeBuilderFlags(flags) {
|
|
52737
52780
|
if (flags === void 0) { flags = 0 /* None */; }
|
|
52738
|
-
return flags &
|
|
52781
|
+
return flags & 848330091 /* NodeBuilderFlagsMask */;
|
|
52739
52782
|
}
|
|
52740
52783
|
function isClassInstanceSide(type) {
|
|
52741
52784
|
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */)));
|
|
@@ -53123,6 +53166,10 @@ var ts;
|
|
|
53123
53166
|
}
|
|
53124
53167
|
return typeToTypeNodeHelper(type, context);
|
|
53125
53168
|
}
|
|
53169
|
+
function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) {
|
|
53170
|
+
return isMappedTypeWithKeyofConstraintDeclaration(type)
|
|
53171
|
+
&& !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */);
|
|
53172
|
+
}
|
|
53126
53173
|
function createMappedTypeNodeFromType(type) {
|
|
53127
53174
|
ts.Debug.assert(!!(type.flags & 524288 /* Object */));
|
|
53128
53175
|
var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
|
|
@@ -53132,7 +53179,7 @@ var ts;
|
|
|
53132
53179
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
53133
53180
|
// We have a { [P in keyof T]: X }
|
|
53134
53181
|
// We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType`
|
|
53135
|
-
if (
|
|
53182
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53136
53183
|
var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
53137
53184
|
var name = typeParameterToName(newParam, context);
|
|
53138
53185
|
newTypeVariable = ts.factory.createTypeReferenceNode(name);
|
|
@@ -53148,11 +53195,12 @@ var ts;
|
|
|
53148
53195
|
var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
|
|
53149
53196
|
context.approximateLength += 10;
|
|
53150
53197
|
var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */);
|
|
53151
|
-
if (
|
|
53198
|
+
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
53152
53199
|
// homomorphic mapped type with a non-homomorphic naive inlining
|
|
53153
53200
|
// wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting
|
|
53154
53201
|
// type stays homomorphic
|
|
53155
|
-
|
|
53202
|
+
var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper);
|
|
53203
|
+
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 */));
|
|
53156
53204
|
}
|
|
53157
53205
|
return result;
|
|
53158
53206
|
}
|
|
@@ -53714,7 +53762,7 @@ var ts;
|
|
|
53714
53762
|
var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0];
|
|
53715
53763
|
// If the expanded parameter list had a variadic in a non-trailing position, don't expand it
|
|
53716
53764
|
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); });
|
|
53717
|
-
var thisParameter = tryGetThisParameterDeclaration(signature, context);
|
|
53765
|
+
var thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context);
|
|
53718
53766
|
if (thisParameter) {
|
|
53719
53767
|
parameters.unshift(thisParameter);
|
|
53720
53768
|
}
|
|
@@ -54773,12 +54821,11 @@ var ts;
|
|
|
54773
54821
|
if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
|
|
54774
54822
|
var oldContext = context;
|
|
54775
54823
|
context = cloneNodeBuilderContext(context);
|
|
54776
|
-
|
|
54824
|
+
serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
|
|
54777
54825
|
if (context.reportedDiagnostic) {
|
|
54778
54826
|
oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context
|
|
54779
54827
|
}
|
|
54780
54828
|
context = oldContext;
|
|
54781
|
-
return result;
|
|
54782
54829
|
}
|
|
54783
54830
|
}
|
|
54784
54831
|
// Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias
|
|
@@ -57835,7 +57882,7 @@ var ts;
|
|
|
57835
57882
|
error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
57836
57883
|
}
|
|
57837
57884
|
else {
|
|
57838
|
-
error(ts.isNamedDeclaration(declaration) ? declaration.name
|
|
57885
|
+
error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
|
|
57839
57886
|
}
|
|
57840
57887
|
}
|
|
57841
57888
|
links.declaredType = type;
|
|
@@ -66103,13 +66150,20 @@ var ts;
|
|
|
66103
66150
|
return result;
|
|
66104
66151
|
}
|
|
66105
66152
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66153
|
+
var saveErrorInfo = captureErrorCalculationState();
|
|
66154
|
+
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66155
|
+
if (result) {
|
|
66156
|
+
resetErrorInfo(saveErrorInfo);
|
|
66157
|
+
}
|
|
66158
|
+
return result;
|
|
66159
|
+
}
|
|
66160
|
+
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
|
|
66106
66161
|
if (intersectionState & 4 /* PropertyCheck */) {
|
|
66107
66162
|
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
|
|
66108
66163
|
}
|
|
66109
66164
|
var result;
|
|
66110
66165
|
var originalErrorInfo;
|
|
66111
66166
|
var varianceCheckFailed = false;
|
|
66112
|
-
var saveErrorInfo = captureErrorCalculationState();
|
|
66113
66167
|
var sourceFlags = source.flags;
|
|
66114
66168
|
var targetFlags = target.flags;
|
|
66115
66169
|
if (relation === identityRelation) {
|
|
@@ -66173,7 +66227,6 @@ var ts;
|
|
|
66173
66227
|
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
66174
66228
|
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
66175
66229
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66176
|
-
resetErrorInfo(saveErrorInfo);
|
|
66177
66230
|
return result;
|
|
66178
66231
|
}
|
|
66179
66232
|
}
|
|
@@ -66298,7 +66351,6 @@ var ts;
|
|
|
66298
66351
|
result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
|
|
66299
66352
|
}
|
|
66300
66353
|
if (result) {
|
|
66301
|
-
resetErrorInfo(saveErrorInfo);
|
|
66302
66354
|
return result;
|
|
66303
66355
|
}
|
|
66304
66356
|
if (reportErrors) {
|
|
@@ -66401,7 +66453,6 @@ var ts;
|
|
|
66401
66453
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66402
66454
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66403
66455
|
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
|
|
66404
|
-
resetErrorInfo(saveErrorInfo);
|
|
66405
66456
|
return 3 /* Maybe */;
|
|
66406
66457
|
}
|
|
66407
66458
|
var c = target;
|
|
@@ -66416,7 +66467,6 @@ var ts;
|
|
|
66416
66467
|
if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) {
|
|
66417
66468
|
result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
66418
66469
|
if (result) {
|
|
66419
|
-
resetErrorInfo(saveErrorInfo);
|
|
66420
66470
|
return result;
|
|
66421
66471
|
}
|
|
66422
66472
|
}
|
|
@@ -66448,12 +66498,10 @@ var ts;
|
|
|
66448
66498
|
var constraint = getConstraintOfType(source) || unknownType;
|
|
66449
66499
|
// 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
|
|
66450
66500
|
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
66451
|
-
resetErrorInfo(saveErrorInfo);
|
|
66452
66501
|
return result;
|
|
66453
66502
|
}
|
|
66454
66503
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
66455
66504
|
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
66456
|
-
resetErrorInfo(saveErrorInfo);
|
|
66457
66505
|
return result;
|
|
66458
66506
|
}
|
|
66459
66507
|
if (isMappedTypeGenericIndexedAccess(source)) {
|
|
@@ -66462,7 +66510,6 @@ var ts;
|
|
|
66462
66510
|
var indexConstraint = getConstraintOfType(source.indexType);
|
|
66463
66511
|
if (indexConstraint) {
|
|
66464
66512
|
if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
|
|
66465
|
-
resetErrorInfo(saveErrorInfo);
|
|
66466
66513
|
return result;
|
|
66467
66514
|
}
|
|
66468
66515
|
}
|
|
@@ -66471,7 +66518,6 @@ var ts;
|
|
|
66471
66518
|
}
|
|
66472
66519
|
else if (sourceFlags & 4194304 /* Index */) {
|
|
66473
66520
|
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
66474
|
-
resetErrorInfo(saveErrorInfo);
|
|
66475
66521
|
return result;
|
|
66476
66522
|
}
|
|
66477
66523
|
}
|
|
@@ -66479,7 +66525,6 @@ var ts;
|
|
|
66479
66525
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
66480
66526
|
var constraint = getBaseConstraintOfType(source);
|
|
66481
66527
|
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66482
|
-
resetErrorInfo(saveErrorInfo);
|
|
66483
66528
|
return result;
|
|
66484
66529
|
}
|
|
66485
66530
|
}
|
|
@@ -66490,14 +66535,12 @@ var ts;
|
|
|
66490
66535
|
return 0 /* False */;
|
|
66491
66536
|
}
|
|
66492
66537
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66493
|
-
resetErrorInfo(saveErrorInfo);
|
|
66494
66538
|
return result;
|
|
66495
66539
|
}
|
|
66496
66540
|
}
|
|
66497
66541
|
else {
|
|
66498
66542
|
var constraint = getBaseConstraintOfType(source);
|
|
66499
66543
|
if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
66500
|
-
resetErrorInfo(saveErrorInfo);
|
|
66501
66544
|
return result;
|
|
66502
66545
|
}
|
|
66503
66546
|
}
|
|
@@ -66506,7 +66549,6 @@ var ts;
|
|
|
66506
66549
|
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
|
|
66507
66550
|
// conditional type and bail out with a Ternary.Maybe result.
|
|
66508
66551
|
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
|
|
66509
|
-
resetErrorInfo(saveErrorInfo);
|
|
66510
66552
|
return 3 /* Maybe */;
|
|
66511
66553
|
}
|
|
66512
66554
|
if (targetFlags & 16777216 /* Conditional */) {
|
|
@@ -66529,7 +66571,6 @@ var ts;
|
|
|
66529
66571
|
result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
|
|
66530
66572
|
}
|
|
66531
66573
|
if (result) {
|
|
66532
|
-
resetErrorInfo(saveErrorInfo);
|
|
66533
66574
|
return result;
|
|
66534
66575
|
}
|
|
66535
66576
|
}
|
|
@@ -66540,7 +66581,6 @@ var ts;
|
|
|
66540
66581
|
var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
|
|
66541
66582
|
if (distributiveConstraint) {
|
|
66542
66583
|
if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66543
|
-
resetErrorInfo(saveErrorInfo);
|
|
66544
66584
|
return result;
|
|
66545
66585
|
}
|
|
66546
66586
|
}
|
|
@@ -66550,7 +66590,6 @@ var ts;
|
|
|
66550
66590
|
var defaultConstraint = getDefaultConstraintOfConditionalType(source);
|
|
66551
66591
|
if (defaultConstraint) {
|
|
66552
66592
|
if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
|
|
66553
|
-
resetErrorInfo(saveErrorInfo);
|
|
66554
66593
|
return result;
|
|
66555
66594
|
}
|
|
66556
66595
|
}
|
|
@@ -66563,7 +66602,6 @@ var ts;
|
|
|
66563
66602
|
if (isGenericMappedType(target)) {
|
|
66564
66603
|
if (isGenericMappedType(source)) {
|
|
66565
66604
|
if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
|
|
66566
|
-
resetErrorInfo(saveErrorInfo);
|
|
66567
66605
|
return result;
|
|
66568
66606
|
}
|
|
66569
66607
|
}
|
|
@@ -68018,9 +68056,14 @@ var ts;
|
|
|
68018
68056
|
type.flags & 256 /* NumberLiteral */ ? numberType :
|
|
68019
68057
|
type.flags & 2048 /* BigIntLiteral */ ? bigintType :
|
|
68020
68058
|
type.flags & 512 /* BooleanLiteral */ ? booleanType :
|
|
68021
|
-
type.flags & 1048576 /* Union */ ?
|
|
68059
|
+
type.flags & 1048576 /* Union */ ? getBaseTypeOfLiteralTypeUnion(type) :
|
|
68022
68060
|
type;
|
|
68023
68061
|
}
|
|
68062
|
+
function getBaseTypeOfLiteralTypeUnion(type) {
|
|
68063
|
+
var _a;
|
|
68064
|
+
var key = "B" + getTypeId(type);
|
|
68065
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType));
|
|
68066
|
+
}
|
|
68024
68067
|
function getWidenedLiteralType(type) {
|
|
68025
68068
|
return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
|
|
68026
68069
|
type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType :
|
|
@@ -70163,23 +70206,25 @@ var ts;
|
|
|
70163
70206
|
// For example, when a variable of type number | string | boolean is assigned a value of type number | boolean,
|
|
70164
70207
|
// we remove type string.
|
|
70165
70208
|
function getAssignmentReducedType(declaredType, assignedType) {
|
|
70166
|
-
|
|
70167
|
-
|
|
70168
|
-
|
|
70169
|
-
}
|
|
70170
|
-
var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
|
|
70171
|
-
if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) {
|
|
70172
|
-
reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types
|
|
70173
|
-
}
|
|
70174
|
-
// Our crude heuristic produces an invalid result in some cases: see GH#26130.
|
|
70175
|
-
// For now, when that happens, we give up and don't narrow at all. (This also
|
|
70176
|
-
// means we'll never narrow for erroneous assignments where the assigned type
|
|
70177
|
-
// is not assignable to the declared type.)
|
|
70178
|
-
if (isTypeAssignableTo(assignedType, reducedType)) {
|
|
70179
|
-
return reducedType;
|
|
70180
|
-
}
|
|
70209
|
+
var _a;
|
|
70210
|
+
if (declaredType === assignedType) {
|
|
70211
|
+
return declaredType;
|
|
70181
70212
|
}
|
|
70182
|
-
|
|
70213
|
+
if (assignedType.flags & 131072 /* Never */) {
|
|
70214
|
+
return assignedType;
|
|
70215
|
+
}
|
|
70216
|
+
var key = "A" + getTypeId(declaredType) + "," + getTypeId(assignedType);
|
|
70217
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType));
|
|
70218
|
+
}
|
|
70219
|
+
function getAssignmentReducedTypeWorker(declaredType, assignedType) {
|
|
70220
|
+
var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
|
|
70221
|
+
// Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type.
|
|
70222
|
+
var reducedType = assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType;
|
|
70223
|
+
// Our crude heuristic produces an invalid result in some cases: see GH#26130.
|
|
70224
|
+
// For now, when that happens, we give up and don't narrow at all. (This also
|
|
70225
|
+
// means we'll never narrow for erroneous assignments where the assigned type
|
|
70226
|
+
// is not assignable to the declared type.)
|
|
70227
|
+
return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType;
|
|
70183
70228
|
}
|
|
70184
70229
|
function isFunctionObjectType(type) {
|
|
70185
70230
|
// We do a quick check for a "bind" property before performing the more expensive subtype
|
|
@@ -71585,7 +71630,7 @@ var ts;
|
|
|
71585
71630
|
var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
|
|
71586
71631
|
? getTypeOfSymbol(classSymbol)
|
|
71587
71632
|
: getDeclaredTypeOfSymbol(classSymbol);
|
|
71588
|
-
return getNarrowedType(type, targetType, assumeTrue,
|
|
71633
|
+
return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
|
|
71589
71634
|
}
|
|
71590
71635
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
71591
71636
|
// We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows:
|
|
@@ -71836,9 +71881,15 @@ var ts;
|
|
|
71836
71881
|
if (!nonConstructorTypeInUnion)
|
|
71837
71882
|
return type;
|
|
71838
71883
|
}
|
|
71839
|
-
return getNarrowedType(type, targetType, assumeTrue,
|
|
71884
|
+
return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true);
|
|
71885
|
+
}
|
|
71886
|
+
function getNarrowedType(type, candidate, assumeTrue, checkDerived) {
|
|
71887
|
+
var _a;
|
|
71888
|
+
var key = type.flags & 1048576 /* Union */ ? "N" + getTypeId(type) + "," + getTypeId(candidate) + "," + ((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined;
|
|
71889
|
+
return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived));
|
|
71840
71890
|
}
|
|
71841
|
-
function
|
|
71891
|
+
function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) {
|
|
71892
|
+
var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;
|
|
71842
71893
|
if (!assumeTrue) {
|
|
71843
71894
|
return filterType(type, function (t) { return !isRelated(t, candidate); });
|
|
71844
71895
|
}
|
|
@@ -71886,7 +71937,7 @@ var ts;
|
|
|
71886
71937
|
var predicateArgument = getTypePredicateArgument(predicate, callExpression);
|
|
71887
71938
|
if (predicateArgument) {
|
|
71888
71939
|
if (isMatchingReference(reference, predicateArgument)) {
|
|
71889
|
-
return getNarrowedType(type, predicate.type, assumeTrue,
|
|
71940
|
+
return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false);
|
|
71890
71941
|
}
|
|
71891
71942
|
if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
|
|
71892
71943
|
!(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) {
|
|
@@ -71894,7 +71945,7 @@ var ts;
|
|
|
71894
71945
|
}
|
|
71895
71946
|
var access = getDiscriminantPropertyAccess(predicateArgument, type);
|
|
71896
71947
|
if (access) {
|
|
71897
|
-
return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue,
|
|
71948
|
+
return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); });
|
|
71898
71949
|
}
|
|
71899
71950
|
}
|
|
71900
71951
|
}
|
|
@@ -72071,7 +72122,7 @@ var ts;
|
|
|
72071
72122
|
!((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) &&
|
|
72072
72123
|
(checkMode && checkMode & 64 /* RestBindingElement */ ?
|
|
72073
72124
|
getContextualType(node, 8 /* SkipBindingPatterns */)
|
|
72074
|
-
: getContextualType(node));
|
|
72125
|
+
: getContextualType(node, /*contextFlags*/ undefined));
|
|
72075
72126
|
return contextualType && !isGenericType(contextualType);
|
|
72076
72127
|
}
|
|
72077
72128
|
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
@@ -72233,9 +72284,7 @@ var ts;
|
|
|
72233
72284
|
getNodeLinks(container).flags |= 8192 /* CaptureArguments */;
|
|
72234
72285
|
return getTypeOfSymbol(symbol);
|
|
72235
72286
|
}
|
|
72236
|
-
|
|
72237
|
-
// for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that
|
|
72238
|
-
if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
|
|
72287
|
+
if (shouldMarkIdentifierAliasReferenced(node)) {
|
|
72239
72288
|
markAliasReferenced(symbol, node);
|
|
72240
72289
|
}
|
|
72241
72290
|
var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
@@ -72369,6 +72418,25 @@ var ts;
|
|
|
72369
72418
|
}
|
|
72370
72419
|
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
|
|
72371
72420
|
}
|
|
72421
|
+
function shouldMarkIdentifierAliasReferenced(node) {
|
|
72422
|
+
var _a;
|
|
72423
|
+
var parent = node.parent;
|
|
72424
|
+
if (parent) {
|
|
72425
|
+
// A property access expression LHS? checkPropertyAccessExpression will handle that.
|
|
72426
|
+
if (ts.isPropertyAccessExpression(parent) && parent.expression === node) {
|
|
72427
|
+
return false;
|
|
72428
|
+
}
|
|
72429
|
+
// Next two check for an identifier inside a type only export.
|
|
72430
|
+
if (ts.isExportSpecifier(parent) && parent.isTypeOnly) {
|
|
72431
|
+
return false;
|
|
72432
|
+
}
|
|
72433
|
+
var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent;
|
|
72434
|
+
if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) {
|
|
72435
|
+
return false;
|
|
72436
|
+
}
|
|
72437
|
+
}
|
|
72438
|
+
return true;
|
|
72439
|
+
}
|
|
72372
72440
|
function isInsideFunctionOrInstancePropertyInitializer(node, threshold) {
|
|
72373
72441
|
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); });
|
|
72374
72442
|
}
|
|
@@ -72918,7 +72986,7 @@ var ts;
|
|
|
72918
72986
|
// We have an object literal method. Check if the containing object literal has a contextual type
|
|
72919
72987
|
// that includes a ThisType<T>. If so, T is the contextual type for 'this'. We continue looking in
|
|
72920
72988
|
// any directly enclosing object literals.
|
|
72921
|
-
var contextualType = getApparentTypeOfContextualType(containingLiteral);
|
|
72989
|
+
var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined);
|
|
72922
72990
|
var literal = containingLiteral;
|
|
72923
72991
|
var type = contextualType;
|
|
72924
72992
|
while (type) {
|
|
@@ -72930,7 +72998,7 @@ var ts;
|
|
|
72930
72998
|
break;
|
|
72931
72999
|
}
|
|
72932
73000
|
literal = literal.parent.parent;
|
|
72933
|
-
type = getApparentTypeOfContextualType(literal);
|
|
73001
|
+
type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined);
|
|
72934
73002
|
}
|
|
72935
73003
|
// There was no contextual ThisType<T> for the containing object literal, so the contextual type
|
|
72936
73004
|
// for 'this' is the non-null form of the contextual type for the containing object literal or
|
|
@@ -72987,7 +73055,7 @@ var ts;
|
|
|
72987
73055
|
tryGetTypeAtPosition(contextualSignature, index);
|
|
72988
73056
|
}
|
|
72989
73057
|
}
|
|
72990
|
-
function getContextualTypeForVariableLikeDeclaration(declaration) {
|
|
73058
|
+
function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) {
|
|
72991
73059
|
var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
|
|
72992
73060
|
if (typeNode) {
|
|
72993
73061
|
return getTypeFromTypeNode(typeNode);
|
|
@@ -72996,18 +73064,18 @@ var ts;
|
|
|
72996
73064
|
case 164 /* Parameter */:
|
|
72997
73065
|
return getContextuallyTypedParameterType(declaration);
|
|
72998
73066
|
case 203 /* BindingElement */:
|
|
72999
|
-
return getContextualTypeForBindingElement(declaration);
|
|
73067
|
+
return getContextualTypeForBindingElement(declaration, contextFlags);
|
|
73000
73068
|
case 167 /* PropertyDeclaration */:
|
|
73001
73069
|
if (ts.isStatic(declaration)) {
|
|
73002
|
-
return getContextualTypeForStaticPropertyDeclaration(declaration);
|
|
73070
|
+
return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags);
|
|
73003
73071
|
}
|
|
73004
73072
|
// By default, do nothing and return undefined - only the above cases have context implied by a parent
|
|
73005
73073
|
}
|
|
73006
73074
|
}
|
|
73007
|
-
function getContextualTypeForBindingElement(declaration) {
|
|
73075
|
+
function getContextualTypeForBindingElement(declaration, contextFlags) {
|
|
73008
73076
|
var parent = declaration.parent.parent;
|
|
73009
73077
|
var name = declaration.propertyName || declaration.name;
|
|
73010
|
-
var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
|
|
73078
|
+
var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) ||
|
|
73011
73079
|
parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */);
|
|
73012
73080
|
if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
|
|
73013
73081
|
return undefined;
|
|
@@ -73023,8 +73091,8 @@ var ts;
|
|
|
73023
73091
|
return getTypeOfPropertyOfType(parentType, text);
|
|
73024
73092
|
}
|
|
73025
73093
|
}
|
|
73026
|
-
function getContextualTypeForStaticPropertyDeclaration(declaration) {
|
|
73027
|
-
var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent);
|
|
73094
|
+
function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) {
|
|
73095
|
+
var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags);
|
|
73028
73096
|
if (!parentType)
|
|
73029
73097
|
return undefined;
|
|
73030
73098
|
return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
|
|
@@ -73040,7 +73108,7 @@ var ts;
|
|
|
73040
73108
|
function getContextualTypeForInitializerExpression(node, contextFlags) {
|
|
73041
73109
|
var declaration = node.parent;
|
|
73042
73110
|
if (ts.hasInitializer(declaration) && node === declaration.initializer) {
|
|
73043
|
-
var result = getContextualTypeForVariableLikeDeclaration(declaration);
|
|
73111
|
+
var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags);
|
|
73044
73112
|
if (result) {
|
|
73045
73113
|
return result;
|
|
73046
73114
|
}
|
|
@@ -73050,10 +73118,10 @@ var ts;
|
|
|
73050
73118
|
}
|
|
73051
73119
|
return undefined;
|
|
73052
73120
|
}
|
|
73053
|
-
function getContextualTypeForReturnExpression(node) {
|
|
73121
|
+
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
73054
73122
|
var func = ts.getContainingFunction(node);
|
|
73055
73123
|
if (func) {
|
|
73056
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73124
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73057
73125
|
if (contextualReturnType) {
|
|
73058
73126
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73059
73127
|
if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function
|
|
@@ -73083,11 +73151,11 @@ var ts;
|
|
|
73083
73151
|
}
|
|
73084
73152
|
return undefined;
|
|
73085
73153
|
}
|
|
73086
|
-
function getContextualTypeForYieldOperand(node) {
|
|
73154
|
+
function getContextualTypeForYieldOperand(node, contextFlags) {
|
|
73087
73155
|
var func = ts.getContainingFunction(node);
|
|
73088
73156
|
if (func) {
|
|
73089
73157
|
var functionFlags = ts.getFunctionFlags(func);
|
|
73090
|
-
var contextualReturnType = getContextualReturnType(func);
|
|
73158
|
+
var contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
73091
73159
|
if (contextualReturnType) {
|
|
73092
73160
|
return node.asteriskToken
|
|
73093
73161
|
? contextualReturnType
|
|
@@ -73111,14 +73179,14 @@ var ts;
|
|
|
73111
73179
|
}
|
|
73112
73180
|
function getContextualIterationType(kind, functionDecl) {
|
|
73113
73181
|
var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */);
|
|
73114
|
-
var contextualReturnType = getContextualReturnType(functionDecl);
|
|
73182
|
+
var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined);
|
|
73115
73183
|
if (contextualReturnType) {
|
|
73116
73184
|
return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
|
|
73117
73185
|
|| undefined;
|
|
73118
73186
|
}
|
|
73119
73187
|
return undefined;
|
|
73120
73188
|
}
|
|
73121
|
-
function getContextualReturnType(functionDecl) {
|
|
73189
|
+
function getContextualReturnType(functionDecl, contextFlags) {
|
|
73122
73190
|
// If the containing function has a return type annotation, is a constructor, or is a get accessor whose
|
|
73123
73191
|
// corresponding set accessor has a type annotation, return statements in the function are contextually typed
|
|
73124
73192
|
var returnType = getReturnTypeFromAnnotation(functionDecl);
|
|
@@ -73133,7 +73201,7 @@ var ts;
|
|
|
73133
73201
|
}
|
|
73134
73202
|
var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl);
|
|
73135
73203
|
if (iife) {
|
|
73136
|
-
return getContextualType(iife);
|
|
73204
|
+
return getContextualType(iife, contextFlags);
|
|
73137
73205
|
}
|
|
73138
73206
|
return undefined;
|
|
73139
73207
|
}
|
|
@@ -73386,7 +73454,7 @@ var ts;
|
|
|
73386
73454
|
}
|
|
73387
73455
|
function getContextualTypeForObjectLiteralElement(element, contextFlags) {
|
|
73388
73456
|
var objectLiteral = element.parent;
|
|
73389
|
-
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element);
|
|
73457
|
+
var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags);
|
|
73390
73458
|
if (propertyAssignmentType) {
|
|
73391
73459
|
return propertyAssignmentType;
|
|
73392
73460
|
}
|
|
@@ -73581,9 +73649,9 @@ var ts;
|
|
|
73581
73649
|
return getContextualTypeForInitializerExpression(node, contextFlags);
|
|
73582
73650
|
case 214 /* ArrowFunction */:
|
|
73583
73651
|
case 247 /* ReturnStatement */:
|
|
73584
|
-
return getContextualTypeForReturnExpression(node);
|
|
73652
|
+
return getContextualTypeForReturnExpression(node, contextFlags);
|
|
73585
73653
|
case 224 /* YieldExpression */:
|
|
73586
|
-
return getContextualTypeForYieldOperand(parent);
|
|
73654
|
+
return getContextualTypeForYieldOperand(parent, contextFlags);
|
|
73587
73655
|
case 218 /* AwaitExpression */:
|
|
73588
73656
|
return getContextualTypeForAwaitOperand(parent, contextFlags);
|
|
73589
73657
|
case 208 /* CallExpression */:
|
|
@@ -73631,7 +73699,7 @@ var ts;
|
|
|
73631
73699
|
}
|
|
73632
73700
|
return undefined;
|
|
73633
73701
|
function tryFindWhenConstTypeReference(node) {
|
|
73634
|
-
return getContextualType(node);
|
|
73702
|
+
return getContextualType(node, contextFlags);
|
|
73635
73703
|
}
|
|
73636
73704
|
}
|
|
73637
73705
|
function getInferenceContext(node) {
|
|
@@ -73933,7 +74001,7 @@ var ts;
|
|
|
73933
74001
|
var elementCount = elements.length;
|
|
73934
74002
|
var elementTypes = [];
|
|
73935
74003
|
var elementFlags = [];
|
|
73936
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74004
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
73937
74005
|
var inDestructuringPattern = ts.isAssignmentTarget(node);
|
|
73938
74006
|
var inConstContext = isConstContext(node);
|
|
73939
74007
|
var hasOmittedExpression = false;
|
|
@@ -74104,7 +74172,7 @@ var ts;
|
|
|
74104
74172
|
var propertiesTable = ts.createSymbolTable();
|
|
74105
74173
|
var propertiesArray = [];
|
|
74106
74174
|
var spread = emptyObjectType;
|
|
74107
|
-
var contextualType = getApparentTypeOfContextualType(node);
|
|
74175
|
+
var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined);
|
|
74108
74176
|
var contextualTypeHasPattern = contextualType && contextualType.pattern &&
|
|
74109
74177
|
(contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */);
|
|
74110
74178
|
var inConstContext = isConstContext(node);
|
|
@@ -74443,7 +74511,7 @@ var ts;
|
|
|
74443
74511
|
if (explicitlySpecifyChildrenAttribute) {
|
|
74444
74512
|
error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
|
|
74445
74513
|
}
|
|
74446
|
-
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
|
|
74514
|
+
var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined);
|
|
74447
74515
|
var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
|
|
74448
74516
|
// 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
|
|
74449
74517
|
var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName);
|
|
@@ -76906,7 +76974,7 @@ var ts;
|
|
|
76906
76974
|
argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
|
|
76907
76975
|
if (inferenceContext) {
|
|
76908
76976
|
var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
76909
|
-
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext
|
|
76977
|
+
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
76910
76978
|
// If the original signature has a generic rest type, instantiation may produce a
|
|
76911
76979
|
// signature with different arity and we need to perform another arity check.
|
|
76912
76980
|
if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
|
|
@@ -78283,17 +78351,6 @@ var ts;
|
|
|
78283
78351
|
}
|
|
78284
78352
|
}
|
|
78285
78353
|
}
|
|
78286
|
-
var restType = getEffectiveRestType(context);
|
|
78287
|
-
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
78288
|
-
// The contextual signature has a generic rest parameter. We first instantiate the contextual
|
|
78289
|
-
// signature (without fixing type parameters) and assign types to contextually typed parameters.
|
|
78290
|
-
var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
|
|
78291
|
-
assignContextualParameterTypes(signature, instantiatedContext);
|
|
78292
|
-
// We then infer from a tuple type representing the parameters that correspond to the contextual
|
|
78293
|
-
// rest parameter.
|
|
78294
|
-
var restPos = getParameterCount(context) - 1;
|
|
78295
|
-
inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
|
|
78296
|
-
}
|
|
78297
78354
|
}
|
|
78298
78355
|
function assignContextualParameterTypes(signature, context) {
|
|
78299
78356
|
if (context.typeParameters) {
|
|
@@ -78486,7 +78543,7 @@ var ts;
|
|
|
78486
78543
|
var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
|
|
78487
78544
|
var contextualType = !contextualSignature ? undefined :
|
|
78488
78545
|
contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
|
|
78489
|
-
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
|
|
78546
|
+
instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined);
|
|
78490
78547
|
if (isGenerator) {
|
|
78491
78548
|
yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync);
|
|
78492
78549
|
returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync);
|
|
@@ -78557,7 +78614,7 @@ var ts;
|
|
|
78557
78614
|
nextType = iterationTypes && iterationTypes.nextType;
|
|
78558
78615
|
}
|
|
78559
78616
|
else {
|
|
78560
|
-
nextType = getContextualType(yieldExpression);
|
|
78617
|
+
nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined);
|
|
78561
78618
|
}
|
|
78562
78619
|
if (nextType)
|
|
78563
78620
|
ts.pushIfUnique(nextTypes, nextType);
|
|
@@ -78766,11 +78823,16 @@ var ts;
|
|
|
78766
78823
|
if (isContextSensitive(node)) {
|
|
78767
78824
|
if (contextualSignature) {
|
|
78768
78825
|
var inferenceContext = getInferenceContext(node);
|
|
78826
|
+
var instantiatedContextualSignature = void 0;
|
|
78769
78827
|
if (checkMode && checkMode & 2 /* Inferential */) {
|
|
78770
78828
|
inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
|
|
78829
|
+
var restType = getEffectiveRestType(contextualSignature);
|
|
78830
|
+
if (restType && restType.flags & 262144 /* TypeParameter */) {
|
|
78831
|
+
instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper);
|
|
78832
|
+
}
|
|
78771
78833
|
}
|
|
78772
|
-
|
|
78773
|
-
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
|
|
78834
|
+
instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ?
|
|
78835
|
+
instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature);
|
|
78774
78836
|
assignContextualParameterTypes(signature, instantiatedContextualSignature);
|
|
78775
78837
|
}
|
|
78776
78838
|
else {
|
|
@@ -80012,7 +80074,7 @@ var ts;
|
|
|
80012
80074
|
type = anyType;
|
|
80013
80075
|
addLazyDiagnostic(function () {
|
|
80014
80076
|
if (noImplicitAny && !ts.expressionResultIsUnused(node)) {
|
|
80015
|
-
var contextualType = getContextualType(node);
|
|
80077
|
+
var contextualType = getContextualType(node, /*contextFlags*/ undefined);
|
|
80016
80078
|
if (!contextualType || isTypeAny(contextualType)) {
|
|
80017
80079
|
error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
|
|
80018
80080
|
}
|
|
@@ -80053,7 +80115,7 @@ var ts;
|
|
|
80053
80115
|
texts.push(span.literal.text);
|
|
80054
80116
|
types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
|
|
80055
80117
|
}
|
|
80056
|
-
return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
|
|
80118
|
+
return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
|
|
80057
80119
|
}
|
|
80058
80120
|
function isTemplateLiteralContextualType(type) {
|
|
80059
80121
|
return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) ||
|
|
@@ -80081,7 +80143,7 @@ var ts;
|
|
|
80081
80143
|
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
|
|
80082
80144
|
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
|
|
80083
80145
|
// here would be to not mark contextually typed literals as fresh in the first place.
|
|
80084
|
-
var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
|
|
80146
|
+
var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ?
|
|
80085
80147
|
getRegularTypeOfLiteralType(type) : type;
|
|
80086
80148
|
return result;
|
|
80087
80149
|
}
|
|
@@ -80196,7 +80258,7 @@ var ts;
|
|
|
80196
80258
|
var type = checkExpression(node, checkMode, forceTuple);
|
|
80197
80259
|
return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) :
|
|
80198
80260
|
isTypeAssertion(node) ? type :
|
|
80199
|
-
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
|
|
80261
|
+
getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined));
|
|
80200
80262
|
}
|
|
80201
80263
|
function checkPropertyAssignment(node, checkMode) {
|
|
80202
80264
|
// Do not use hasDynamicName here, because that returns false for well known symbols.
|
|
@@ -86178,7 +86240,9 @@ var ts;
|
|
|
86178
86240
|
error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
|
|
86179
86241
|
}
|
|
86180
86242
|
else {
|
|
86181
|
-
|
|
86243
|
+
if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) {
|
|
86244
|
+
markExportAsReferenced(node);
|
|
86245
|
+
}
|
|
86182
86246
|
var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol);
|
|
86183
86247
|
if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) {
|
|
86184
86248
|
checkExpressionCached(node.propertyName || node.name);
|
|
@@ -89539,9 +89603,6 @@ var ts;
|
|
|
89539
89603
|
else {
|
|
89540
89604
|
return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
|
89541
89605
|
}
|
|
89542
|
-
if (!isConstOrReadonly || isInvalidInitializer) {
|
|
89543
|
-
return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
|
|
89544
|
-
}
|
|
89545
89606
|
}
|
|
89546
89607
|
}
|
|
89547
89608
|
function checkGrammarVariableDeclaration(node) {
|
|
@@ -111326,7 +111387,7 @@ var ts;
|
|
|
111326
111387
|
return;
|
|
111327
111388
|
}
|
|
111328
111389
|
// Make sure not to write js file and source map file if any of them cannot be written
|
|
111329
|
-
if (
|
|
111390
|
+
if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) {
|
|
111330
111391
|
emitSkipped = true;
|
|
111331
111392
|
return;
|
|
111332
111393
|
}
|
|
@@ -124588,7 +124649,6 @@ var ts;
|
|
|
124588
124649
|
var parsedConfigs; // Parsed commandline and watching cached for referenced projects
|
|
124589
124650
|
var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
|
|
124590
124651
|
var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
|
|
124591
|
-
var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
|
|
124592
124652
|
var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
|
|
124593
124653
|
var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
|
|
124594
124654
|
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
|
|
@@ -124741,12 +124801,12 @@ var ts;
|
|
|
124741
124801
|
var program = getCurrentBuilderProgram();
|
|
124742
124802
|
if (hasChangedCompilerOptions) {
|
|
124743
124803
|
newLine = updateNewLine();
|
|
124744
|
-
if (program &&
|
|
124804
|
+
if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
|
|
124745
124805
|
resolutionCache.clear();
|
|
124746
124806
|
}
|
|
124747
124807
|
}
|
|
124748
124808
|
// All resolutions are invalid if user provided resolutions
|
|
124749
|
-
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution
|
|
124809
|
+
var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
|
|
124750
124810
|
if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
|
124751
124811
|
if (hasChangedConfigFileParsingErrors) {
|
|
124752
124812
|
if (reportFileChangeDetectedOnCreateProgram) {
|
|
@@ -124762,7 +124822,6 @@ var ts;
|
|
|
124762
124822
|
}
|
|
124763
124823
|
createNewProgram(hasInvalidatedResolution);
|
|
124764
124824
|
}
|
|
124765
|
-
changesAffectResolution = false; // reset for next sync
|
|
124766
124825
|
reportFileChangeDetectedOnCreateProgram = false;
|
|
124767
124826
|
if (host.afterProgramCreate && program !== builderProgram) {
|
|
124768
124827
|
host.afterProgramCreate(builderProgram);
|
|
@@ -126143,7 +126202,7 @@ var ts;
|
|
|
126143
126202
|
}
|
|
126144
126203
|
function afterProgramDone(state, program, config) {
|
|
126145
126204
|
if (program) {
|
|
126146
|
-
if (
|
|
126205
|
+
if (state.write)
|
|
126147
126206
|
ts.listFiles(program, state.write);
|
|
126148
126207
|
if (state.host.afterProgramEmitAndDiagnostics) {
|
|
126149
126208
|
state.host.afterProgramEmitAndDiagnostics(program);
|