@typescript-deploys/pr-build 5.1.0-pr-53739-12 → 5.1.0-pr-53729-10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +49 -105
- package/lib/tsserver.js +53 -107
- package/lib/tsserverlibrary.js +54 -108
- package/lib/typescript.js +54 -108
- package/lib/typingsInstaller.js +1 -1
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.1";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20230412`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -42568,7 +42568,6 @@ function isInstantiatedModule(node, preserveConstEnums) {
|
|
|
42568
42568
|
const moduleState = getModuleInstanceState(node);
|
|
42569
42569
|
return moduleState === 1 /* Instantiated */ || preserveConstEnums && moduleState === 2 /* ConstEnumOnly */;
|
|
42570
42570
|
}
|
|
42571
|
-
var UNION_CROSS_PRODUCT_SIZE_LIMIT = 1e5;
|
|
42572
42571
|
function createTypeChecker(host) {
|
|
42573
42572
|
var getPackagesMap = memoize(() => {
|
|
42574
42573
|
var map2 = /* @__PURE__ */ new Map();
|
|
@@ -43408,6 +43407,8 @@ function createTypeChecker(host) {
|
|
|
43408
43407
|
var resolutionTargets = [];
|
|
43409
43408
|
var resolutionResults = [];
|
|
43410
43409
|
var resolutionPropertyNames = [];
|
|
43410
|
+
var resolutionStart = 0;
|
|
43411
|
+
var inVarianceComputation = false;
|
|
43411
43412
|
var suggestionCount = 0;
|
|
43412
43413
|
var maximumSuggestionCount = 10;
|
|
43413
43414
|
var mergedSymbols = [];
|
|
@@ -50608,7 +50609,7 @@ function createTypeChecker(host) {
|
|
|
50608
50609
|
return true;
|
|
50609
50610
|
}
|
|
50610
50611
|
function findResolutionCycleStartIndex(target, propertyName) {
|
|
50611
|
-
for (let i = resolutionTargets.length - 1; i >=
|
|
50612
|
+
for (let i = resolutionTargets.length - 1; i >= resolutionStart; i--) {
|
|
50612
50613
|
if (resolutionTargetHasProperty(resolutionTargets[i], resolutionPropertyNames[i])) {
|
|
50613
50614
|
return -1;
|
|
50614
50615
|
}
|
|
@@ -51741,12 +51742,7 @@ function createTypeChecker(host) {
|
|
|
51741
51742
|
if (!links.type) {
|
|
51742
51743
|
Debug.assertIsDefined(links.deferralParent);
|
|
51743
51744
|
Debug.assertIsDefined(links.deferralConstituents);
|
|
51744
|
-
|
|
51745
|
-
let result = operation(links.deferralConstituents);
|
|
51746
|
-
for (const part of links.deferredMismatchedParts || emptyArray) {
|
|
51747
|
-
result = operation([result, getTypeOfSymbol(part)]);
|
|
51748
|
-
}
|
|
51749
|
-
links.type = result;
|
|
51745
|
+
links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents);
|
|
51750
51746
|
}
|
|
51751
51747
|
return links.type;
|
|
51752
51748
|
}
|
|
@@ -51754,12 +51750,8 @@ function createTypeChecker(host) {
|
|
|
51754
51750
|
const links = getSymbolLinks(symbol);
|
|
51755
51751
|
if (!links.writeType && links.deferralWriteConstituents) {
|
|
51756
51752
|
Debug.assertIsDefined(links.deferralParent);
|
|
51757
|
-
|
|
51758
|
-
|
|
51759
|
-
for (const part of links.deferredMismatchedParts || emptyArray) {
|
|
51760
|
-
result = operation([result, getTypeOfSymbol(part)]);
|
|
51761
|
-
}
|
|
51762
|
-
links.writeType = result;
|
|
51753
|
+
Debug.assertIsDefined(links.deferralConstituents);
|
|
51754
|
+
links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
|
|
51763
51755
|
}
|
|
51764
51756
|
return links.writeType;
|
|
51765
51757
|
}
|
|
@@ -53796,7 +53788,7 @@ function createTypeChecker(host) {
|
|
|
53796
53788
|
return getReducedType(getApparentType(getReducedType(type)));
|
|
53797
53789
|
}
|
|
53798
53790
|
function createUnionOrIntersectionProperty(containingType, name, skipObjectFunctionPropertyAugment) {
|
|
53799
|
-
var _a2, _b, _c
|
|
53791
|
+
var _a2, _b, _c;
|
|
53800
53792
|
let singleProp;
|
|
53801
53793
|
let propSet;
|
|
53802
53794
|
let indexTypes;
|
|
@@ -53878,9 +53870,8 @@ function createTypeChecker(host) {
|
|
|
53878
53870
|
let declarations;
|
|
53879
53871
|
let firstType;
|
|
53880
53872
|
let nameType;
|
|
53881
|
-
|
|
53873
|
+
const propTypes = [];
|
|
53882
53874
|
let writeTypes;
|
|
53883
|
-
let deferredMismatchedParts;
|
|
53884
53875
|
let firstValueDeclaration;
|
|
53885
53876
|
let hasNonUniformValueDeclaration = false;
|
|
53886
53877
|
for (const prop of props) {
|
|
@@ -53890,24 +53881,6 @@ function createTypeChecker(host) {
|
|
|
53890
53881
|
hasNonUniformValueDeclaration = true;
|
|
53891
53882
|
}
|
|
53892
53883
|
declarations = addRange(declarations, prop.declarations);
|
|
53893
|
-
if (getCheckFlags(prop) & 65536 /* DeferredType */) {
|
|
53894
|
-
checkFlags |= getCheckFlags(prop) & (131072 /* HasNeverType */ | 64 /* HasNonUniformType */ | 128 /* HasLiteralType */);
|
|
53895
|
-
if (!nameType) {
|
|
53896
|
-
nameType = getSymbolLinks(prop).nameType;
|
|
53897
|
-
}
|
|
53898
|
-
if ((((_d = getSymbolLinks(prop).deferralParent) == null ? void 0 : _d.flags) & 3145728 /* UnionOrIntersection */) === (containingType.flags & 3145728 /* UnionOrIntersection */)) {
|
|
53899
|
-
const deferredWriteTypes = getSymbolLinks(prop).deferralWriteConstituents;
|
|
53900
|
-
if (deferredWriteTypes) {
|
|
53901
|
-
writeTypes = concatenate(!writeTypes ? propTypes.slice() : writeTypes, deferredWriteTypes);
|
|
53902
|
-
}
|
|
53903
|
-
propTypes = concatenate(propTypes, getSymbolLinks(prop).deferralConstituents);
|
|
53904
|
-
deferredMismatchedParts = concatenate(deferredMismatchedParts, getSymbolLinks(prop).deferredMismatchedParts);
|
|
53905
|
-
break;
|
|
53906
|
-
} else {
|
|
53907
|
-
deferredMismatchedParts = append(deferredMismatchedParts, prop);
|
|
53908
|
-
break;
|
|
53909
|
-
}
|
|
53910
|
-
}
|
|
53911
53884
|
const type = getTypeOfSymbol(prop);
|
|
53912
53885
|
if (!firstType) {
|
|
53913
53886
|
firstType = type;
|
|
@@ -53938,12 +53911,11 @@ function createTypeChecker(host) {
|
|
|
53938
53911
|
}
|
|
53939
53912
|
result.declarations = declarations;
|
|
53940
53913
|
result.links.nameType = nameType;
|
|
53941
|
-
if (propTypes.length > 2
|
|
53914
|
+
if (propTypes.length > 2) {
|
|
53942
53915
|
result.links.checkFlags |= 65536 /* DeferredType */;
|
|
53943
53916
|
result.links.deferralParent = containingType;
|
|
53944
53917
|
result.links.deferralConstituents = propTypes;
|
|
53945
53918
|
result.links.deferralWriteConstituents = writeTypes;
|
|
53946
|
-
result.links.deferredMismatchedParts = deferredMismatchedParts;
|
|
53947
53919
|
} else {
|
|
53948
53920
|
result.links.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
|
|
53949
53921
|
if (writeTypes) {
|
|
@@ -56300,7 +56272,7 @@ function createTypeChecker(host) {
|
|
|
56300
56272
|
function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
|
|
56301
56273
|
const typeMembershipMap = /* @__PURE__ */ new Map();
|
|
56302
56274
|
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
56303
|
-
|
|
56275
|
+
const typeSet = arrayFrom(typeMembershipMap.values());
|
|
56304
56276
|
if (includes & 131072 /* Never */) {
|
|
56305
56277
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
56306
56278
|
}
|
|
@@ -56332,8 +56304,6 @@ function createTypeChecker(host) {
|
|
|
56332
56304
|
const id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
56333
56305
|
let result = intersectionTypes.get(id);
|
|
56334
56306
|
if (!result) {
|
|
56335
|
-
const originalSet = typeSet;
|
|
56336
|
-
let runningResult;
|
|
56337
56307
|
if (includes & 1048576 /* Union */) {
|
|
56338
56308
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
56339
56309
|
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
@@ -56345,32 +56315,12 @@ function createTypeChecker(host) {
|
|
|
56345
56315
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
56346
56316
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
56347
56317
|
} else {
|
|
56348
|
-
if (getCrossProductUnionSize(typeSet) >= UNION_CROSS_PRODUCT_SIZE_LIMIT && every(typeSet, (t) => !!(t.flags & 1048576 /* Union */) || !!(t.flags & 402784252 /* Primitive */))) {
|
|
56349
|
-
if (typeSet.length > 2 || some(typeSet, (t) => getReducedType(t) !== t)) {
|
|
56350
|
-
runningResult = getReducedType(typeSet[0]);
|
|
56351
|
-
for (let i = 1; i < typeSet.length; i++) {
|
|
56352
|
-
const reducedElem = getReducedType(typeSet[i]);
|
|
56353
|
-
runningResult = reducedElem.flags & 402784252 /* Primitive */ && everyType(runningResult, (t) => !!(t.flags & 524288 /* Object */)) ? neverType : getReducedType(intersectTypes(runningResult, reducedElem));
|
|
56354
|
-
if (i === typeSet.length - 1 || isTypeAny(runningResult) || runningResult.flags & 131072 /* Never */) {
|
|
56355
|
-
return runningResult;
|
|
56356
|
-
}
|
|
56357
|
-
if (!(runningResult.flags & 1048576 /* Union */) || runningResult.types.length > typeSet.length) {
|
|
56358
|
-
typeSet = typeSet.slice(i + 1);
|
|
56359
|
-
break;
|
|
56360
|
-
}
|
|
56361
|
-
}
|
|
56362
|
-
}
|
|
56363
|
-
}
|
|
56364
56318
|
if (!checkCrossProductUnion(typeSet)) {
|
|
56365
56319
|
return errorType;
|
|
56366
56320
|
}
|
|
56367
56321
|
const constituents = getCrossProductIntersections(typeSet);
|
|
56368
|
-
|
|
56369
|
-
|
|
56370
|
-
} else {
|
|
56371
|
-
const origin = some(constituents, (t) => !!(t.flags & 2097152 /* Intersection */)) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, originalSet) : void 0;
|
|
56372
|
-
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
56373
|
-
}
|
|
56322
|
+
const origin = some(constituents, (t) => !!(t.flags & 2097152 /* Intersection */)) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : void 0;
|
|
56323
|
+
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
56374
56324
|
}
|
|
56375
56325
|
} else {
|
|
56376
56326
|
result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
@@ -56385,7 +56335,7 @@ function createTypeChecker(host) {
|
|
|
56385
56335
|
function checkCrossProductUnion(types) {
|
|
56386
56336
|
var _a2;
|
|
56387
56337
|
const size = getCrossProductUnionSize(types);
|
|
56388
|
-
if (size >=
|
|
56338
|
+
if (size >= 1e5) {
|
|
56389
56339
|
(_a2 = tracing) == null ? void 0 : _a2.instant(tracing.Phase.CheckTypes, "checkCrossProductUnion_DepthLimit", { typeIds: types.map((t) => t.id), size });
|
|
56390
56340
|
error(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
|
|
56391
56341
|
return false;
|
|
@@ -61631,40 +61581,31 @@ function createTypeChecker(host) {
|
|
|
61631
61581
|
return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
|
|
61632
61582
|
}
|
|
61633
61583
|
function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
|
|
61634
|
-
return findMatchingDiscriminantType(
|
|
61635
|
-
source,
|
|
61636
|
-
target,
|
|
61637
|
-
isRelatedTo,
|
|
61638
|
-
/*skipPartial*/
|
|
61639
|
-
true
|
|
61640
|
-
) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
|
|
61584
|
+
return findMatchingDiscriminantType(source, target, isRelatedTo) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
|
|
61641
61585
|
}
|
|
61642
|
-
function discriminateTypeByDiscriminableItems(target, discriminators, related
|
|
61643
|
-
const
|
|
61586
|
+
function discriminateTypeByDiscriminableItems(target, discriminators, related) {
|
|
61587
|
+
const types = target.types;
|
|
61588
|
+
const include = types.map((t) => t.flags & 402784252 /* Primitive */ ? 0 /* False */ : -1 /* True */);
|
|
61644
61589
|
for (const [getDiscriminatingType, propertyName] of discriminators) {
|
|
61645
|
-
|
|
61646
|
-
|
|
61647
|
-
|
|
61590
|
+
let matched = false;
|
|
61591
|
+
for (let i = 0; i < types.length; i++) {
|
|
61592
|
+
if (include[i]) {
|
|
61593
|
+
const targetType = getTypeOfPropertyOfType(types[i], propertyName);
|
|
61594
|
+
if (targetType && related(getDiscriminatingType(), targetType)) {
|
|
61595
|
+
matched = true;
|
|
61596
|
+
} else {
|
|
61597
|
+
include[i] = 3 /* Maybe */;
|
|
61598
|
+
}
|
|
61599
|
+
}
|
|
61648
61600
|
}
|
|
61649
|
-
let i = 0;
|
|
61650
|
-
|
|
61651
|
-
|
|
61652
|
-
if (targetType && related(getDiscriminatingType(), targetType)) {
|
|
61653
|
-
discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
|
|
61654
|
-
} else {
|
|
61655
|
-
discriminable[i] = false;
|
|
61601
|
+
for (let i = 0; i < types.length; i++) {
|
|
61602
|
+
if (include[i] === 3 /* Maybe */) {
|
|
61603
|
+
include[i] = matched ? 0 /* False */ : -1 /* True */;
|
|
61656
61604
|
}
|
|
61657
|
-
i++;
|
|
61658
61605
|
}
|
|
61659
61606
|
}
|
|
61660
|
-
const
|
|
61661
|
-
|
|
61662
|
-
true
|
|
61663
|
-
);
|
|
61664
|
-
if (match === -1) {
|
|
61665
|
-
return defaultValue;
|
|
61666
|
-
}
|
|
61667
|
-
return getUnionType(target.types.filter((_, index) => discriminable[index]));
|
|
61607
|
+
const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i])) : target;
|
|
61608
|
+
return filtered.flags & 131072 /* Never */ ? target : filtered;
|
|
61668
61609
|
}
|
|
61669
61610
|
function isWeakType(type) {
|
|
61670
61611
|
if (type.flags & 524288 /* Object */) {
|
|
@@ -61695,6 +61636,11 @@ function createTypeChecker(host) {
|
|
|
61695
61636
|
const links = getSymbolLinks(symbol);
|
|
61696
61637
|
if (!links.variances) {
|
|
61697
61638
|
(_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
|
|
61639
|
+
const oldVarianceComputation = inVarianceComputation;
|
|
61640
|
+
if (!inVarianceComputation) {
|
|
61641
|
+
inVarianceComputation = true;
|
|
61642
|
+
resolutionStart = resolutionTargets.length;
|
|
61643
|
+
}
|
|
61698
61644
|
links.variances = emptyArray;
|
|
61699
61645
|
const variances = [];
|
|
61700
61646
|
for (const tp of typeParameters) {
|
|
@@ -61723,6 +61669,10 @@ function createTypeChecker(host) {
|
|
|
61723
61669
|
}
|
|
61724
61670
|
variances.push(variance);
|
|
61725
61671
|
}
|
|
61672
|
+
if (!oldVarianceComputation) {
|
|
61673
|
+
inVarianceComputation = false;
|
|
61674
|
+
resolutionStart = 0;
|
|
61675
|
+
}
|
|
61726
61676
|
links.variances = variances;
|
|
61727
61677
|
(_b = tracing) == null ? void 0 : _b.pop({ variances: variances.map(Debug.formatVariance) });
|
|
61728
61678
|
}
|
|
@@ -66959,8 +66909,7 @@ function createTypeChecker(host) {
|
|
|
66959
66909
|
(s) => [() => undefinedType, s.escapedName]
|
|
66960
66910
|
)
|
|
66961
66911
|
),
|
|
66962
|
-
isTypeAssignableTo
|
|
66963
|
-
contextualType
|
|
66912
|
+
isTypeAssignableTo
|
|
66964
66913
|
);
|
|
66965
66914
|
}
|
|
66966
66915
|
function discriminateContextualTypeByJSXAttributes(node, contextualType) {
|
|
@@ -66979,8 +66928,7 @@ function createTypeChecker(host) {
|
|
|
66979
66928
|
(s) => [() => undefinedType, s.escapedName]
|
|
66980
66929
|
)
|
|
66981
66930
|
),
|
|
66982
|
-
isTypeAssignableTo
|
|
66983
|
-
contextualType
|
|
66931
|
+
isTypeAssignableTo
|
|
66984
66932
|
);
|
|
66985
66933
|
}
|
|
66986
66934
|
function getApparentTypeOfContextualType(node, contextFlags) {
|
|
@@ -82994,7 +82942,7 @@ function createTypeChecker(host) {
|
|
|
82994
82942
|
}
|
|
82995
82943
|
return type;
|
|
82996
82944
|
}
|
|
82997
|
-
function findMatchingDiscriminantType(source, target, isRelatedTo
|
|
82945
|
+
function findMatchingDiscriminantType(source, target, isRelatedTo) {
|
|
82998
82946
|
if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
|
|
82999
82947
|
const match = getMatchingUnionConstituentForType(target, source);
|
|
83000
82948
|
if (match) {
|
|
@@ -83004,14 +82952,10 @@ function createTypeChecker(host) {
|
|
|
83004
82952
|
if (sourceProperties) {
|
|
83005
82953
|
const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
|
|
83006
82954
|
if (sourcePropertiesFiltered) {
|
|
83007
|
-
|
|
83008
|
-
|
|
83009
|
-
|
|
83010
|
-
|
|
83011
|
-
/*defaultValue*/
|
|
83012
|
-
void 0,
|
|
83013
|
-
skipPartial
|
|
83014
|
-
);
|
|
82955
|
+
const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
|
|
82956
|
+
if (discriminated !== target) {
|
|
82957
|
+
return discriminated;
|
|
82958
|
+
}
|
|
83015
82959
|
}
|
|
83016
82960
|
}
|
|
83017
82961
|
}
|
package/lib/tsserver.js
CHANGED
|
@@ -2293,7 +2293,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2293
2293
|
|
|
2294
2294
|
// src/compiler/corePublic.ts
|
|
2295
2295
|
var versionMajorMinor = "5.1";
|
|
2296
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2296
|
+
var version = `${versionMajorMinor}.0-insiders.20230412`;
|
|
2297
2297
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2298
2298
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2299
2299
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -47218,7 +47218,6 @@ function isInstantiatedModule(node, preserveConstEnums) {
|
|
|
47218
47218
|
const moduleState = getModuleInstanceState(node);
|
|
47219
47219
|
return moduleState === 1 /* Instantiated */ || preserveConstEnums && moduleState === 2 /* ConstEnumOnly */;
|
|
47220
47220
|
}
|
|
47221
|
-
var UNION_CROSS_PRODUCT_SIZE_LIMIT = 1e5;
|
|
47222
47221
|
function createTypeChecker(host) {
|
|
47223
47222
|
var getPackagesMap = memoize(() => {
|
|
47224
47223
|
var map2 = /* @__PURE__ */ new Map();
|
|
@@ -48058,6 +48057,8 @@ function createTypeChecker(host) {
|
|
|
48058
48057
|
var resolutionTargets = [];
|
|
48059
48058
|
var resolutionResults = [];
|
|
48060
48059
|
var resolutionPropertyNames = [];
|
|
48060
|
+
var resolutionStart = 0;
|
|
48061
|
+
var inVarianceComputation = false;
|
|
48061
48062
|
var suggestionCount = 0;
|
|
48062
48063
|
var maximumSuggestionCount = 10;
|
|
48063
48064
|
var mergedSymbols = [];
|
|
@@ -55258,7 +55259,7 @@ function createTypeChecker(host) {
|
|
|
55258
55259
|
return true;
|
|
55259
55260
|
}
|
|
55260
55261
|
function findResolutionCycleStartIndex(target, propertyName) {
|
|
55261
|
-
for (let i = resolutionTargets.length - 1; i >=
|
|
55262
|
+
for (let i = resolutionTargets.length - 1; i >= resolutionStart; i--) {
|
|
55262
55263
|
if (resolutionTargetHasProperty(resolutionTargets[i], resolutionPropertyNames[i])) {
|
|
55263
55264
|
return -1;
|
|
55264
55265
|
}
|
|
@@ -56391,12 +56392,7 @@ function createTypeChecker(host) {
|
|
|
56391
56392
|
if (!links.type) {
|
|
56392
56393
|
Debug.assertIsDefined(links.deferralParent);
|
|
56393
56394
|
Debug.assertIsDefined(links.deferralConstituents);
|
|
56394
|
-
|
|
56395
|
-
let result = operation(links.deferralConstituents);
|
|
56396
|
-
for (const part of links.deferredMismatchedParts || emptyArray) {
|
|
56397
|
-
result = operation([result, getTypeOfSymbol(part)]);
|
|
56398
|
-
}
|
|
56399
|
-
links.type = result;
|
|
56395
|
+
links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents);
|
|
56400
56396
|
}
|
|
56401
56397
|
return links.type;
|
|
56402
56398
|
}
|
|
@@ -56404,12 +56400,8 @@ function createTypeChecker(host) {
|
|
|
56404
56400
|
const links = getSymbolLinks(symbol);
|
|
56405
56401
|
if (!links.writeType && links.deferralWriteConstituents) {
|
|
56406
56402
|
Debug.assertIsDefined(links.deferralParent);
|
|
56407
|
-
|
|
56408
|
-
|
|
56409
|
-
for (const part of links.deferredMismatchedParts || emptyArray) {
|
|
56410
|
-
result = operation([result, getTypeOfSymbol(part)]);
|
|
56411
|
-
}
|
|
56412
|
-
links.writeType = result;
|
|
56403
|
+
Debug.assertIsDefined(links.deferralConstituents);
|
|
56404
|
+
links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
|
|
56413
56405
|
}
|
|
56414
56406
|
return links.writeType;
|
|
56415
56407
|
}
|
|
@@ -58446,7 +58438,7 @@ function createTypeChecker(host) {
|
|
|
58446
58438
|
return getReducedType(getApparentType(getReducedType(type)));
|
|
58447
58439
|
}
|
|
58448
58440
|
function createUnionOrIntersectionProperty(containingType, name, skipObjectFunctionPropertyAugment) {
|
|
58449
|
-
var _a2, _b, _c
|
|
58441
|
+
var _a2, _b, _c;
|
|
58450
58442
|
let singleProp;
|
|
58451
58443
|
let propSet;
|
|
58452
58444
|
let indexTypes;
|
|
@@ -58528,9 +58520,8 @@ function createTypeChecker(host) {
|
|
|
58528
58520
|
let declarations;
|
|
58529
58521
|
let firstType;
|
|
58530
58522
|
let nameType;
|
|
58531
|
-
|
|
58523
|
+
const propTypes = [];
|
|
58532
58524
|
let writeTypes;
|
|
58533
|
-
let deferredMismatchedParts;
|
|
58534
58525
|
let firstValueDeclaration;
|
|
58535
58526
|
let hasNonUniformValueDeclaration = false;
|
|
58536
58527
|
for (const prop of props) {
|
|
@@ -58540,24 +58531,6 @@ function createTypeChecker(host) {
|
|
|
58540
58531
|
hasNonUniformValueDeclaration = true;
|
|
58541
58532
|
}
|
|
58542
58533
|
declarations = addRange(declarations, prop.declarations);
|
|
58543
|
-
if (getCheckFlags(prop) & 65536 /* DeferredType */) {
|
|
58544
|
-
checkFlags |= getCheckFlags(prop) & (131072 /* HasNeverType */ | 64 /* HasNonUniformType */ | 128 /* HasLiteralType */);
|
|
58545
|
-
if (!nameType) {
|
|
58546
|
-
nameType = getSymbolLinks(prop).nameType;
|
|
58547
|
-
}
|
|
58548
|
-
if ((((_d = getSymbolLinks(prop).deferralParent) == null ? void 0 : _d.flags) & 3145728 /* UnionOrIntersection */) === (containingType.flags & 3145728 /* UnionOrIntersection */)) {
|
|
58549
|
-
const deferredWriteTypes = getSymbolLinks(prop).deferralWriteConstituents;
|
|
58550
|
-
if (deferredWriteTypes) {
|
|
58551
|
-
writeTypes = concatenate(!writeTypes ? propTypes.slice() : writeTypes, deferredWriteTypes);
|
|
58552
|
-
}
|
|
58553
|
-
propTypes = concatenate(propTypes, getSymbolLinks(prop).deferralConstituents);
|
|
58554
|
-
deferredMismatchedParts = concatenate(deferredMismatchedParts, getSymbolLinks(prop).deferredMismatchedParts);
|
|
58555
|
-
break;
|
|
58556
|
-
} else {
|
|
58557
|
-
deferredMismatchedParts = append(deferredMismatchedParts, prop);
|
|
58558
|
-
break;
|
|
58559
|
-
}
|
|
58560
|
-
}
|
|
58561
58534
|
const type = getTypeOfSymbol(prop);
|
|
58562
58535
|
if (!firstType) {
|
|
58563
58536
|
firstType = type;
|
|
@@ -58588,12 +58561,11 @@ function createTypeChecker(host) {
|
|
|
58588
58561
|
}
|
|
58589
58562
|
result.declarations = declarations;
|
|
58590
58563
|
result.links.nameType = nameType;
|
|
58591
|
-
if (propTypes.length > 2
|
|
58564
|
+
if (propTypes.length > 2) {
|
|
58592
58565
|
result.links.checkFlags |= 65536 /* DeferredType */;
|
|
58593
58566
|
result.links.deferralParent = containingType;
|
|
58594
58567
|
result.links.deferralConstituents = propTypes;
|
|
58595
58568
|
result.links.deferralWriteConstituents = writeTypes;
|
|
58596
|
-
result.links.deferredMismatchedParts = deferredMismatchedParts;
|
|
58597
58569
|
} else {
|
|
58598
58570
|
result.links.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
|
|
58599
58571
|
if (writeTypes) {
|
|
@@ -60950,7 +60922,7 @@ function createTypeChecker(host) {
|
|
|
60950
60922
|
function getIntersectionType(types, aliasSymbol, aliasTypeArguments, noSupertypeReduction) {
|
|
60951
60923
|
const typeMembershipMap = /* @__PURE__ */ new Map();
|
|
60952
60924
|
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
|
60953
|
-
|
|
60925
|
+
const typeSet = arrayFrom(typeMembershipMap.values());
|
|
60954
60926
|
if (includes & 131072 /* Never */) {
|
|
60955
60927
|
return contains(typeSet, silentNeverType) ? silentNeverType : neverType;
|
|
60956
60928
|
}
|
|
@@ -60982,8 +60954,6 @@ function createTypeChecker(host) {
|
|
|
60982
60954
|
const id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
60983
60955
|
let result = intersectionTypes.get(id);
|
|
60984
60956
|
if (!result) {
|
|
60985
|
-
const originalSet = typeSet;
|
|
60986
|
-
let runningResult;
|
|
60987
60957
|
if (includes & 1048576 /* Union */) {
|
|
60988
60958
|
if (intersectUnionsOfPrimitiveTypes(typeSet)) {
|
|
60989
60959
|
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
@@ -60995,32 +60965,12 @@ function createTypeChecker(host) {
|
|
|
60995
60965
|
removeFromEach(typeSet, 65536 /* Null */);
|
|
60996
60966
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
60997
60967
|
} else {
|
|
60998
|
-
if (getCrossProductUnionSize(typeSet) >= UNION_CROSS_PRODUCT_SIZE_LIMIT && every(typeSet, (t) => !!(t.flags & 1048576 /* Union */) || !!(t.flags & 402784252 /* Primitive */))) {
|
|
60999
|
-
if (typeSet.length > 2 || some(typeSet, (t) => getReducedType(t) !== t)) {
|
|
61000
|
-
runningResult = getReducedType(typeSet[0]);
|
|
61001
|
-
for (let i = 1; i < typeSet.length; i++) {
|
|
61002
|
-
const reducedElem = getReducedType(typeSet[i]);
|
|
61003
|
-
runningResult = reducedElem.flags & 402784252 /* Primitive */ && everyType(runningResult, (t) => !!(t.flags & 524288 /* Object */)) ? neverType : getReducedType(intersectTypes(runningResult, reducedElem));
|
|
61004
|
-
if (i === typeSet.length - 1 || isTypeAny(runningResult) || runningResult.flags & 131072 /* Never */) {
|
|
61005
|
-
return runningResult;
|
|
61006
|
-
}
|
|
61007
|
-
if (!(runningResult.flags & 1048576 /* Union */) || runningResult.types.length > typeSet.length) {
|
|
61008
|
-
typeSet = typeSet.slice(i + 1);
|
|
61009
|
-
break;
|
|
61010
|
-
}
|
|
61011
|
-
}
|
|
61012
|
-
}
|
|
61013
|
-
}
|
|
61014
60968
|
if (!checkCrossProductUnion(typeSet)) {
|
|
61015
60969
|
return errorType;
|
|
61016
60970
|
}
|
|
61017
60971
|
const constituents = getCrossProductIntersections(typeSet);
|
|
61018
|
-
|
|
61019
|
-
|
|
61020
|
-
} else {
|
|
61021
|
-
const origin = some(constituents, (t) => !!(t.flags & 2097152 /* Intersection */)) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, originalSet) : void 0;
|
|
61022
|
-
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
61023
|
-
}
|
|
60972
|
+
const origin = some(constituents, (t) => !!(t.flags & 2097152 /* Intersection */)) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : void 0;
|
|
60973
|
+
result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin);
|
|
61024
60974
|
}
|
|
61025
60975
|
} else {
|
|
61026
60976
|
result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
@@ -61035,7 +60985,7 @@ function createTypeChecker(host) {
|
|
|
61035
60985
|
function checkCrossProductUnion(types) {
|
|
61036
60986
|
var _a2;
|
|
61037
60987
|
const size = getCrossProductUnionSize(types);
|
|
61038
|
-
if (size >=
|
|
60988
|
+
if (size >= 1e5) {
|
|
61039
60989
|
(_a2 = tracing) == null ? void 0 : _a2.instant(tracing.Phase.CheckTypes, "checkCrossProductUnion_DepthLimit", { typeIds: types.map((t) => t.id), size });
|
|
61040
60990
|
error(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
|
|
61041
60991
|
return false;
|
|
@@ -66281,40 +66231,31 @@ function createTypeChecker(host) {
|
|
|
66281
66231
|
return getPropertiesOfType(type).filter((targetProp) => containsMissingType(getTypeOfSymbol(targetProp)));
|
|
66282
66232
|
}
|
|
66283
66233
|
function getBestMatchingType(source, target, isRelatedTo = compareTypesAssignable) {
|
|
66284
|
-
return findMatchingDiscriminantType(
|
|
66285
|
-
source,
|
|
66286
|
-
target,
|
|
66287
|
-
isRelatedTo,
|
|
66288
|
-
/*skipPartial*/
|
|
66289
|
-
true
|
|
66290
|
-
) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
|
|
66234
|
+
return findMatchingDiscriminantType(source, target, isRelatedTo) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target);
|
|
66291
66235
|
}
|
|
66292
|
-
function discriminateTypeByDiscriminableItems(target, discriminators, related
|
|
66293
|
-
const
|
|
66236
|
+
function discriminateTypeByDiscriminableItems(target, discriminators, related) {
|
|
66237
|
+
const types = target.types;
|
|
66238
|
+
const include = types.map((t) => t.flags & 402784252 /* Primitive */ ? 0 /* False */ : -1 /* True */);
|
|
66294
66239
|
for (const [getDiscriminatingType, propertyName] of discriminators) {
|
|
66295
|
-
|
|
66296
|
-
|
|
66297
|
-
|
|
66240
|
+
let matched = false;
|
|
66241
|
+
for (let i = 0; i < types.length; i++) {
|
|
66242
|
+
if (include[i]) {
|
|
66243
|
+
const targetType = getTypeOfPropertyOfType(types[i], propertyName);
|
|
66244
|
+
if (targetType && related(getDiscriminatingType(), targetType)) {
|
|
66245
|
+
matched = true;
|
|
66246
|
+
} else {
|
|
66247
|
+
include[i] = 3 /* Maybe */;
|
|
66248
|
+
}
|
|
66249
|
+
}
|
|
66298
66250
|
}
|
|
66299
|
-
let i = 0;
|
|
66300
|
-
|
|
66301
|
-
|
|
66302
|
-
if (targetType && related(getDiscriminatingType(), targetType)) {
|
|
66303
|
-
discriminable[i] = discriminable[i] === void 0 ? true : discriminable[i];
|
|
66304
|
-
} else {
|
|
66305
|
-
discriminable[i] = false;
|
|
66251
|
+
for (let i = 0; i < types.length; i++) {
|
|
66252
|
+
if (include[i] === 3 /* Maybe */) {
|
|
66253
|
+
include[i] = matched ? 0 /* False */ : -1 /* True */;
|
|
66306
66254
|
}
|
|
66307
|
-
i++;
|
|
66308
66255
|
}
|
|
66309
66256
|
}
|
|
66310
|
-
const
|
|
66311
|
-
|
|
66312
|
-
true
|
|
66313
|
-
);
|
|
66314
|
-
if (match === -1) {
|
|
66315
|
-
return defaultValue;
|
|
66316
|
-
}
|
|
66317
|
-
return getUnionType(target.types.filter((_, index) => discriminable[index]));
|
|
66257
|
+
const filtered = contains(include, 0 /* False */) ? getUnionType(types.filter((_, i) => include[i])) : target;
|
|
66258
|
+
return filtered.flags & 131072 /* Never */ ? target : filtered;
|
|
66318
66259
|
}
|
|
66319
66260
|
function isWeakType(type) {
|
|
66320
66261
|
if (type.flags & 524288 /* Object */) {
|
|
@@ -66345,6 +66286,11 @@ function createTypeChecker(host) {
|
|
|
66345
66286
|
const links = getSymbolLinks(symbol);
|
|
66346
66287
|
if (!links.variances) {
|
|
66347
66288
|
(_a2 = tracing) == null ? void 0 : _a2.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
|
|
66289
|
+
const oldVarianceComputation = inVarianceComputation;
|
|
66290
|
+
if (!inVarianceComputation) {
|
|
66291
|
+
inVarianceComputation = true;
|
|
66292
|
+
resolutionStart = resolutionTargets.length;
|
|
66293
|
+
}
|
|
66348
66294
|
links.variances = emptyArray;
|
|
66349
66295
|
const variances = [];
|
|
66350
66296
|
for (const tp of typeParameters) {
|
|
@@ -66373,6 +66319,10 @@ function createTypeChecker(host) {
|
|
|
66373
66319
|
}
|
|
66374
66320
|
variances.push(variance);
|
|
66375
66321
|
}
|
|
66322
|
+
if (!oldVarianceComputation) {
|
|
66323
|
+
inVarianceComputation = false;
|
|
66324
|
+
resolutionStart = 0;
|
|
66325
|
+
}
|
|
66376
66326
|
links.variances = variances;
|
|
66377
66327
|
(_b = tracing) == null ? void 0 : _b.pop({ variances: variances.map(Debug.formatVariance) });
|
|
66378
66328
|
}
|
|
@@ -71609,8 +71559,7 @@ function createTypeChecker(host) {
|
|
|
71609
71559
|
(s) => [() => undefinedType, s.escapedName]
|
|
71610
71560
|
)
|
|
71611
71561
|
),
|
|
71612
|
-
isTypeAssignableTo
|
|
71613
|
-
contextualType
|
|
71562
|
+
isTypeAssignableTo
|
|
71614
71563
|
);
|
|
71615
71564
|
}
|
|
71616
71565
|
function discriminateContextualTypeByJSXAttributes(node, contextualType) {
|
|
@@ -71629,8 +71578,7 @@ function createTypeChecker(host) {
|
|
|
71629
71578
|
(s) => [() => undefinedType, s.escapedName]
|
|
71630
71579
|
)
|
|
71631
71580
|
),
|
|
71632
|
-
isTypeAssignableTo
|
|
71633
|
-
contextualType
|
|
71581
|
+
isTypeAssignableTo
|
|
71634
71582
|
);
|
|
71635
71583
|
}
|
|
71636
71584
|
function getApparentTypeOfContextualType(node, contextFlags) {
|
|
@@ -87644,7 +87592,7 @@ function createTypeChecker(host) {
|
|
|
87644
87592
|
}
|
|
87645
87593
|
return type;
|
|
87646
87594
|
}
|
|
87647
|
-
function findMatchingDiscriminantType(source, target, isRelatedTo
|
|
87595
|
+
function findMatchingDiscriminantType(source, target, isRelatedTo) {
|
|
87648
87596
|
if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) {
|
|
87649
87597
|
const match = getMatchingUnionConstituentForType(target, source);
|
|
87650
87598
|
if (match) {
|
|
@@ -87654,14 +87602,10 @@ function createTypeChecker(host) {
|
|
|
87654
87602
|
if (sourceProperties) {
|
|
87655
87603
|
const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
|
|
87656
87604
|
if (sourcePropertiesFiltered) {
|
|
87657
|
-
|
|
87658
|
-
|
|
87659
|
-
|
|
87660
|
-
|
|
87661
|
-
/*defaultValue*/
|
|
87662
|
-
void 0,
|
|
87663
|
-
skipPartial
|
|
87664
|
-
);
|
|
87605
|
+
const discriminated = discriminateTypeByDiscriminableItems(target, map(sourcePropertiesFiltered, (p) => [() => getTypeOfSymbol(p), p.escapedName]), isRelatedTo);
|
|
87606
|
+
if (discriminated !== target) {
|
|
87607
|
+
return discriminated;
|
|
87608
|
+
}
|
|
87665
87609
|
}
|
|
87666
87610
|
}
|
|
87667
87611
|
}
|
|
@@ -156326,6 +156270,7 @@ function getReferenceAtPosition(sourceFile, position, program) {
|
|
|
156326
156270
|
return void 0;
|
|
156327
156271
|
}
|
|
156328
156272
|
function getTypeDefinitionAtPosition(typeChecker, sourceFile, position) {
|
|
156273
|
+
var _a2;
|
|
156329
156274
|
const node = getTouchingPropertyName(sourceFile, position);
|
|
156330
156275
|
if (node === sourceFile) {
|
|
156331
156276
|
return void 0;
|
|
@@ -156350,8 +156295,9 @@ function getTypeDefinitionAtPosition(typeChecker, sourceFile, position) {
|
|
|
156350
156295
|
const typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);
|
|
156351
156296
|
const returnType = tryGetReturnTypeOfFunction(symbol, typeAtLocation, typeChecker);
|
|
156352
156297
|
const fromReturnType = returnType && definitionFromType(returnType, typeChecker, node, failedAliasResolution);
|
|
156353
|
-
const typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution);
|
|
156354
|
-
|
|
156298
|
+
const [resolvedType, typeDefinitions] = fromReturnType && fromReturnType.length !== 0 ? [returnType, fromReturnType] : [typeAtLocation, definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution)];
|
|
156299
|
+
const singleTypeArgumentDefinition = !!(getObjectFlags(resolvedType) & 4 /* Reference */) && ((_a2 = resolvedType.resolvedTypeArguments) == null ? void 0 : _a2.length) === 1 ? definitionFromType(resolvedType.resolvedTypeArguments[0], typeChecker, node, failedAliasResolution) : [];
|
|
156300
|
+
return typeDefinitions.length ? [...singleTypeArgumentDefinition, ...typeDefinitions] : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, skipAlias(symbol, typeChecker), node, failedAliasResolution) : void 0;
|
|
156355
156301
|
}
|
|
156356
156302
|
function definitionFromType(type, checker, node, failedAliasResolution) {
|
|
156357
156303
|
return flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], (t) => t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution));
|