@typescript-deploys/pr-build 5.1.0-pr-54072-11 → 5.1.0-pr-54112-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 +67 -39
- package/lib/tsserver.js +78 -49
- package/lib/tsserverlibrary.js +78 -49
- package/lib/typescript.js +77 -48
- 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.20230503`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -44003,7 +44003,7 @@ function createTypeChecker(host) {
|
|
|
44003
44003
|
return true;
|
|
44004
44004
|
}
|
|
44005
44005
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
44006
|
-
if (getEmitScriptTarget(compilerOptions)
|
|
44006
|
+
if (getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ && useDefineForClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
44007
44007
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
44008
44008
|
declaration,
|
|
44009
44009
|
usage,
|
|
@@ -49693,7 +49693,7 @@ function createTypeChecker(host) {
|
|
|
49693
49693
|
context.enclosingDeclaration = originalDecl || oldEnclosing;
|
|
49694
49694
|
const localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
|
|
49695
49695
|
const typeParamDecls = map(localParams, (p) => typeParameterToDeclaration(p, context));
|
|
49696
|
-
const classType = getDeclaredTypeOfClassOrInterface(symbol);
|
|
49696
|
+
const classType = getTypeWithThisArgument(getDeclaredTypeOfClassOrInterface(symbol));
|
|
49697
49697
|
const baseTypes = getBaseTypes(classType);
|
|
49698
49698
|
const originalImplements = originalDecl && getEffectiveImplementsTypeNodes(originalDecl);
|
|
49699
49699
|
const implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements) || mapDefined(getImplementsTypes(classType), serializeImplementedType);
|
|
@@ -50885,18 +50885,18 @@ function createTypeChecker(host) {
|
|
|
50885
50885
|
} else {
|
|
50886
50886
|
const name = declaration.propertyName || declaration.name;
|
|
50887
50887
|
const indexType = getLiteralTypeFromPropertyName(name);
|
|
50888
|
-
const declaredType = getIndexedAccessType(parentType, indexType,
|
|
50888
|
+
const declaredType = getIndexedAccessType(parentType, indexType, 64 /* ExpressionPosition */, name);
|
|
50889
50889
|
type = getFlowTypeOfDestructuring(declaration, declaredType);
|
|
50890
50890
|
}
|
|
50891
50891
|
} else {
|
|
50892
50892
|
const elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern);
|
|
50893
50893
|
const index = pattern.elements.indexOf(declaration);
|
|
50894
50894
|
if (declaration.dotDotDotToken) {
|
|
50895
|
-
const baseConstraint =
|
|
50895
|
+
const baseConstraint = mapType(parentType, (t) => t.flags & 58982400 /* InstantiableNonPrimitive */ ? getBaseConstraintOrType(t) : t);
|
|
50896
50896
|
type = everyType(baseConstraint, isTupleType) ? mapType(baseConstraint, (t) => sliceTupleType(t, index)) : createArrayType(elementType);
|
|
50897
50897
|
} else if (isArrayLikeType(parentType)) {
|
|
50898
50898
|
const indexType = getNumberLiteralType(index);
|
|
50899
|
-
const accessFlags =
|
|
50899
|
+
const accessFlags = 64 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 32 /* NoTupleBoundsCheck */ : 0);
|
|
50900
50900
|
const declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType;
|
|
50901
50901
|
type = getFlowTypeOfDestructuring(declaration, declaredType);
|
|
50902
50902
|
} else {
|
|
@@ -52620,6 +52620,9 @@ function createTypeChecker(host) {
|
|
|
52620
52620
|
}
|
|
52621
52621
|
return needApparentType ? getApparentType(type) : type;
|
|
52622
52622
|
}
|
|
52623
|
+
function getThisArgument(type) {
|
|
52624
|
+
return getObjectFlags(type) & 4 /* Reference */ && length(getTypeArguments(type)) > getTypeReferenceArity(type) ? last(getTypeArguments(type)) : type;
|
|
52625
|
+
}
|
|
52623
52626
|
function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
|
|
52624
52627
|
let mapper;
|
|
52625
52628
|
let members;
|
|
@@ -52750,7 +52753,7 @@ function createTypeChecker(host) {
|
|
|
52750
52753
|
}
|
|
52751
52754
|
return [sig.parameters];
|
|
52752
52755
|
function expandSignatureParametersWithTupleMembers(restType, restIndex) {
|
|
52753
|
-
const elementTypes =
|
|
52756
|
+
const elementTypes = getElementTypes(restType);
|
|
52754
52757
|
const associatedNames = getUniqAssociatedNamesFromTupleType(restType);
|
|
52755
52758
|
const restParams = map(elementTypes, (t, i) => {
|
|
52756
52759
|
const name = associatedNames && associatedNames[i] ? associatedNames[i] : getParameterNameAtPosition(sig, restIndex + i, restType);
|
|
@@ -53566,7 +53569,7 @@ function createTypeChecker(host) {
|
|
|
53566
53569
|
}
|
|
53567
53570
|
function isConstTypeVariable(type) {
|
|
53568
53571
|
var _a;
|
|
53569
|
-
return !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, isConstTypeVariable) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type)) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType) || isGenericTupleType(type) && findIndex(
|
|
53572
|
+
return !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a = type.symbol) == null ? void 0 : _a.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, isConstTypeVariable) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type)) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType) || isGenericTupleType(type) && findIndex(getElementTypes(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0));
|
|
53570
53573
|
}
|
|
53571
53574
|
function getConstraintOfIndexedAccess(type) {
|
|
53572
53575
|
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
|
|
@@ -53668,7 +53671,7 @@ function createTypeChecker(host) {
|
|
|
53668
53671
|
return void 0;
|
|
53669
53672
|
}
|
|
53670
53673
|
function getBaseConstraintOfType(type) {
|
|
53671
|
-
if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) {
|
|
53674
|
+
if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || isGenericTupleType(type)) {
|
|
53672
53675
|
const constraint = getResolvedBaseConstraint(type);
|
|
53673
53676
|
return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : void 0;
|
|
53674
53677
|
}
|
|
@@ -53685,7 +53688,7 @@ function createTypeChecker(host) {
|
|
|
53685
53688
|
return type.resolvedBaseConstraint;
|
|
53686
53689
|
}
|
|
53687
53690
|
const stack = [];
|
|
53688
|
-
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type);
|
|
53691
|
+
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), getThisArgument(type));
|
|
53689
53692
|
function getImmediateBaseConstraint(t) {
|
|
53690
53693
|
if (!t.immediateBaseConstraint) {
|
|
53691
53694
|
if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) {
|
|
@@ -53775,6 +53778,13 @@ function createTypeChecker(host) {
|
|
|
53775
53778
|
if (t.flags & 33554432 /* Substitution */) {
|
|
53776
53779
|
return getBaseConstraint(getSubstitutionIntersection(t));
|
|
53777
53780
|
}
|
|
53781
|
+
if (isGenericTupleType(t)) {
|
|
53782
|
+
const newElements = map(getElementTypes(t), (v, i) => {
|
|
53783
|
+
const constraint = t.target.elementFlags[i] & 8 /* Variadic */ && getBaseConstraint(v) || v;
|
|
53784
|
+
return constraint && everyType(constraint, (c) => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
|
|
53785
|
+
});
|
|
53786
|
+
return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
|
|
53787
|
+
}
|
|
53778
53788
|
return t;
|
|
53779
53789
|
}
|
|
53780
53790
|
}
|
|
@@ -55829,7 +55839,7 @@ function createTypeChecker(host) {
|
|
|
55829
55839
|
if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) {
|
|
55830
55840
|
addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) == null ? void 0 : _a[i]);
|
|
55831
55841
|
} else if (isTupleType(type)) {
|
|
55832
|
-
const elements =
|
|
55842
|
+
const elements = getElementTypes(type);
|
|
55833
55843
|
if (elements.length + expandedTypes.length >= 1e4) {
|
|
55834
55844
|
error(currentNode, isPartOfTypeNode(currentNode) ? Diagnostics.Type_produces_a_tuple_type_that_is_too_large_to_represent : Diagnostics.Expression_produces_a_tuple_type_that_is_too_large_to_represent);
|
|
55835
55845
|
return errorType;
|
|
@@ -55907,6 +55917,11 @@ function createTypeChecker(host) {
|
|
|
55907
55917
|
function getEndElementCount(type, flags) {
|
|
55908
55918
|
return type.elementFlags.length - findLastIndex(type.elementFlags, (f) => !(f & flags)) - 1;
|
|
55909
55919
|
}
|
|
55920
|
+
function getElementTypes(type) {
|
|
55921
|
+
const typeArguments = getTypeArguments(type);
|
|
55922
|
+
const arity = getTypeReferenceArity(type);
|
|
55923
|
+
return typeArguments.length === arity ? typeArguments : typeArguments.slice(0, arity);
|
|
55924
|
+
}
|
|
55910
55925
|
function getTypeFromOptionalTypeNode(node) {
|
|
55911
55926
|
return addOptionality(
|
|
55912
55927
|
getTypeFromTypeNode(node.type),
|
|
@@ -56750,12 +56765,12 @@ function createTypeChecker(host) {
|
|
|
56750
56765
|
const accessExpression = accessNode && accessNode.kind === 211 /* ElementAccessExpression */ ? accessNode : void 0;
|
|
56751
56766
|
const propName = accessNode && isPrivateIdentifier(accessNode) ? void 0 : getPropertyNameFromIndex(indexType, accessNode);
|
|
56752
56767
|
if (propName !== void 0) {
|
|
56753
|
-
if (accessFlags &
|
|
56768
|
+
if (accessFlags & 512 /* Contextual */) {
|
|
56754
56769
|
return getTypeOfPropertyOfContextualType(objectType, propName) || anyType;
|
|
56755
56770
|
}
|
|
56756
56771
|
const prop = getPropertyOfType(objectType, propName);
|
|
56757
56772
|
if (prop) {
|
|
56758
|
-
if (accessFlags &
|
|
56773
|
+
if (accessFlags & 128 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) {
|
|
56759
56774
|
const deprecatedNode = (accessExpression == null ? void 0 : accessExpression.argumentExpression) ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
|
|
56760
56775
|
addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName);
|
|
56761
56776
|
}
|
|
@@ -56765,7 +56780,7 @@ function createTypeChecker(host) {
|
|
|
56765
56780
|
error(accessExpression.argumentExpression, Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop));
|
|
56766
56781
|
return void 0;
|
|
56767
56782
|
}
|
|
56768
|
-
if (accessFlags &
|
|
56783
|
+
if (accessFlags & 16 /* CacheSymbol */) {
|
|
56769
56784
|
getNodeLinks(accessNode).resolvedSymbol = prop;
|
|
56770
56785
|
}
|
|
56771
56786
|
if (isThisPropertyAccessInConstructor(accessExpression, prop)) {
|
|
@@ -56777,7 +56792,7 @@ function createTypeChecker(host) {
|
|
|
56777
56792
|
}
|
|
56778
56793
|
if (everyType(objectType, isTupleType) && isNumericLiteralName(propName)) {
|
|
56779
56794
|
const index = +propName;
|
|
56780
|
-
if (accessNode && everyType(objectType, (t) => !t.target.hasRestElement) && !(accessFlags &
|
|
56795
|
+
if (accessNode && everyType(objectType, (t) => !t.target.hasRestElement) && !(accessFlags & 32 /* NoTupleBoundsCheck */)) {
|
|
56781
56796
|
const indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
56782
56797
|
if (isTupleType(objectType)) {
|
|
56783
56798
|
if (index < 0) {
|
|
@@ -56810,7 +56825,7 @@ function createTypeChecker(host) {
|
|
|
56810
56825
|
}
|
|
56811
56826
|
const indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType);
|
|
56812
56827
|
if (indexInfo) {
|
|
56813
|
-
if (accessFlags &
|
|
56828
|
+
if (accessFlags & 4 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) {
|
|
56814
56829
|
if (accessExpression) {
|
|
56815
56830
|
error(accessExpression, Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType));
|
|
56816
56831
|
}
|
|
@@ -56847,7 +56862,7 @@ function createTypeChecker(host) {
|
|
|
56847
56862
|
}
|
|
56848
56863
|
if (objectType.symbol === globalThisSymbol && propName !== void 0 && globalThisSymbol.exports.has(propName) && globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */) {
|
|
56849
56864
|
error(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1, unescapeLeadingUnderscores(propName), typeToString(objectType));
|
|
56850
|
-
} else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags &
|
|
56865
|
+
} else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 256 /* SuppressNoImplicitAnyError */)) {
|
|
56851
56866
|
if (propName !== void 0 && typeHasStaticProperty(propName, objectType)) {
|
|
56852
56867
|
const typeName = typeToString(objectType);
|
|
56853
56868
|
error(accessExpression, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + getTextOfNode(accessExpression.argumentExpression) + "]");
|
|
@@ -57083,13 +57098,13 @@ function createTypeChecker(host) {
|
|
|
57083
57098
|
if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) {
|
|
57084
57099
|
indexType = stringType;
|
|
57085
57100
|
}
|
|
57086
|
-
if (compilerOptions.noUncheckedIndexedAccess && accessFlags &
|
|
57101
|
+
if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 64 /* ExpressionPosition */)
|
|
57087
57102
|
accessFlags |= 1 /* IncludeUndefined */;
|
|
57088
|
-
if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 198 /* IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)) || isGenericReducibleType(objectType))) {
|
|
57103
|
+
if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 198 /* IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)) || !(accessFlags & 2 /* ResolveReducibleTypes */) && isGenericReducibleType(objectType))) {
|
|
57089
57104
|
if (objectType.flags & 3 /* AnyOrUnknown */) {
|
|
57090
57105
|
return objectType;
|
|
57091
57106
|
}
|
|
57092
|
-
const persistentAccessFlags = accessFlags &
|
|
57107
|
+
const persistentAccessFlags = accessFlags & 3 /* Persistent */;
|
|
57093
57108
|
const id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments);
|
|
57094
57109
|
let type = indexedAccessTypes.get(id);
|
|
57095
57110
|
if (!type) {
|
|
@@ -57102,7 +57117,7 @@ function createTypeChecker(host) {
|
|
|
57102
57117
|
const propTypes = [];
|
|
57103
57118
|
let wasMissingProp = false;
|
|
57104
57119
|
for (const t of indexType.types) {
|
|
57105
|
-
const propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ?
|
|
57120
|
+
const propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 256 /* SuppressNoImplicitAnyError */ : 0));
|
|
57106
57121
|
if (propType) {
|
|
57107
57122
|
propTypes.push(propType);
|
|
57108
57123
|
} else if (!accessNode) {
|
|
@@ -57114,9 +57129,9 @@ function createTypeChecker(host) {
|
|
|
57114
57129
|
if (wasMissingProp) {
|
|
57115
57130
|
return void 0;
|
|
57116
57131
|
}
|
|
57117
|
-
return accessFlags &
|
|
57132
|
+
return accessFlags & 8 /* Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
57118
57133
|
}
|
|
57119
|
-
return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags |
|
|
57134
|
+
return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 16 /* CacheSymbol */ | 128 /* ReportDeprecated */);
|
|
57120
57135
|
}
|
|
57121
57136
|
function getTypeFromIndexedAccessTypeNode(node) {
|
|
57122
57137
|
const links = getNodeLinks(node);
|
|
@@ -57157,7 +57172,7 @@ function createTypeChecker(host) {
|
|
|
57157
57172
|
return isTupleTypeNode(node) && length(node.elements) > 0 && !some(node.elements, (e) => isOptionalTypeNode(e) || isRestTypeNode(e) || isNamedTupleMember(e) && !!(e.questionToken || e.dotDotDotToken));
|
|
57158
57173
|
}
|
|
57159
57174
|
function isDeferredType(type, checkTuples) {
|
|
57160
|
-
return isGenericType(type) || checkTuples && isTupleType(type) && some(
|
|
57175
|
+
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
|
57161
57176
|
}
|
|
57162
57177
|
function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
|
|
57163
57178
|
let result;
|
|
@@ -58092,7 +58107,7 @@ function createTypeChecker(host) {
|
|
|
58092
58107
|
}
|
|
58093
58108
|
function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) {
|
|
58094
58109
|
const elementFlags = tupleType.target.elementFlags;
|
|
58095
|
-
const elementTypes = map(
|
|
58110
|
+
const elementTypes = map(getElementTypes(tupleType), (t, i) => {
|
|
58096
58111
|
const singleton = elementFlags[i] & 8 /* Variadic */ ? t : elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]);
|
|
58097
58112
|
return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
|
|
58098
58113
|
});
|
|
@@ -58111,7 +58126,7 @@ function createTypeChecker(host) {
|
|
|
58111
58126
|
}
|
|
58112
58127
|
function instantiateMappedTupleType(tupleType, mappedType, mapper) {
|
|
58113
58128
|
const elementFlags = tupleType.target.elementFlags;
|
|
58114
|
-
const elementTypes = map(
|
|
58129
|
+
const elementTypes = map(getElementTypes(tupleType), (_, i) => instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper));
|
|
58115
58130
|
const modifiers = getMappedTypeModifiers(mappedType);
|
|
58116
58131
|
const newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? map(elementFlags, (f) => f & 1 /* Required */ ? 2 /* Optional */ : f) : modifiers & 8 /* ExcludeOptional */ ? map(elementFlags, (f) => f & 2 /* Optional */ ? 1 /* Required */ : f) : elementFlags;
|
|
58117
58132
|
const newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
|
|
@@ -59297,7 +59312,7 @@ function createTypeChecker(host) {
|
|
|
59297
59312
|
return type;
|
|
59298
59313
|
}
|
|
59299
59314
|
function getNormalizedTupleType(type, writing) {
|
|
59300
|
-
const elements =
|
|
59315
|
+
const elements = getElementTypes(type);
|
|
59301
59316
|
const normalizedElements = sameMap(elements, (t) => t.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(t, writing) : t);
|
|
59302
59317
|
return elements !== normalizedElements ? createNormalizedTupleType(type.target, normalizedElements) : type;
|
|
59303
59318
|
}
|
|
@@ -59586,6 +59601,8 @@ function createTypeChecker(host) {
|
|
|
59586
59601
|
return isRelatedTo(source2, target2, 3 /* Both */, reportErrors2);
|
|
59587
59602
|
}
|
|
59588
59603
|
function isRelatedTo(originalSource, originalTarget, recursionFlags = 3 /* Both */, reportErrors2 = false, headMessage2, intersectionState = 0 /* None */) {
|
|
59604
|
+
if (originalSource === originalTarget)
|
|
59605
|
+
return -1 /* True */;
|
|
59589
59606
|
if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 402784252 /* Primitive */) {
|
|
59590
59607
|
if (relation === comparableRelation && !(originalTarget.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(originalTarget, originalSource, relation) || isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors2 ? reportError : void 0)) {
|
|
59591
59608
|
return -1 /* True */;
|
|
@@ -60537,7 +60554,7 @@ function createTypeChecker(host) {
|
|
|
60537
60554
|
const baseObjectType = getBaseConstraintOfType(objectType) || objectType;
|
|
60538
60555
|
const baseIndexType = getBaseConstraintOfType(indexType) || indexType;
|
|
60539
60556
|
if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) {
|
|
60540
|
-
const accessFlags =
|
|
60557
|
+
const accessFlags = 8 /* Writing */ | (baseObjectType !== objectType ? 4 /* NoIndexSignatures */ : 0);
|
|
60541
60558
|
const constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags);
|
|
60542
60559
|
if (constraint) {
|
|
60543
60560
|
if (reportErrors2 && originalErrorInfo) {
|
|
@@ -60804,6 +60821,11 @@ function createTypeChecker(host) {
|
|
|
60804
60821
|
} else {
|
|
60805
60822
|
return 0 /* False */;
|
|
60806
60823
|
}
|
|
60824
|
+
} else if (isGenericTupleType(source2) && isTupleType(target2) && !isGenericTupleType(target2)) {
|
|
60825
|
+
const constraint = getBaseConstraintOrType(source2);
|
|
60826
|
+
if (constraint !== source2) {
|
|
60827
|
+
return isRelatedTo(constraint, target2, 1 /* Source */, reportErrors2);
|
|
60828
|
+
}
|
|
60807
60829
|
} else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target2) && getObjectFlags(target2) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source2)) {
|
|
60808
60830
|
return 0 /* False */;
|
|
60809
60831
|
}
|
|
@@ -62719,7 +62741,7 @@ function createTypeChecker(host) {
|
|
|
62719
62741
|
return type;
|
|
62720
62742
|
}
|
|
62721
62743
|
function isPartiallyInferableType(type) {
|
|
62722
|
-
return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(
|
|
62744
|
+
return !(getObjectFlags(type) & 262144 /* NonInferrableType */) || isObjectLiteralType(type) && some(getPropertiesOfType(type), (prop) => isPartiallyInferableType(getTypeOfSymbol(prop))) || isTupleType(type) && some(getElementTypes(type), isPartiallyInferableType);
|
|
62723
62745
|
}
|
|
62724
62746
|
function createReverseMappedType(source, target, constraint) {
|
|
62725
62747
|
if (!(getIndexInfoOfType(source, stringType) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
|
|
@@ -62729,7 +62751,7 @@ function createTypeChecker(host) {
|
|
|
62729
62751
|
return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
|
|
62730
62752
|
}
|
|
62731
62753
|
if (isTupleType(source)) {
|
|
62732
|
-
const elementTypes = map(
|
|
62754
|
+
const elementTypes = map(getElementTypes(source), (t) => inferReverseMappedType(t, target, constraint));
|
|
62733
62755
|
const elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? sameMap(source.target.elementFlags, (f) => f & 2 /* Optional */ ? 1 /* Required */ : f) : source.target.elementFlags;
|
|
62734
62756
|
return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations);
|
|
62735
62757
|
}
|
|
@@ -63058,6 +63080,12 @@ function createTypeChecker(host) {
|
|
|
63058
63080
|
}
|
|
63059
63081
|
}
|
|
63060
63082
|
}
|
|
63083
|
+
if (target.flags & 8388608 /* IndexedAccess */ && isGenericReducibleType(target.objectType)) {
|
|
63084
|
+
const instantiated = getIndexedAccessType(target.objectType, target.indexType, 2 /* ResolveReducibleTypes */);
|
|
63085
|
+
if (instantiated && instantiated !== target) {
|
|
63086
|
+
inferFromTypes(source, instantiated);
|
|
63087
|
+
}
|
|
63088
|
+
}
|
|
63061
63089
|
}
|
|
63062
63090
|
if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && !(source.node && target.node)) {
|
|
63063
63091
|
inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
|
|
@@ -63570,7 +63598,7 @@ function createTypeChecker(host) {
|
|
|
63570
63598
|
const inferredCovariantType = inference.candidates ? getCovariantInference(inference, context.signature) : void 0;
|
|
63571
63599
|
const inferredContravariantType = inference.contraCandidates ? getContravariantInference(inference) : void 0;
|
|
63572
63600
|
if (inferredCovariantType || inferredContravariantType) {
|
|
63573
|
-
const preferCovariantType = inferredCovariantType && (!inferredContravariantType || !(inferredCovariantType.flags & 131072 /* Never */) &&
|
|
63601
|
+
const preferCovariantType = inferredCovariantType && (!inferredContravariantType || !(inferredCovariantType.flags & 131072 /* Never */) && some(inference.contraCandidates, (t) => isTypeSubtypeOf(inferredCovariantType, t)) && every(context.inferences, (other) => other !== inference && getConstraintOfTypeParameter(other.typeParameter) !== inference.typeParameter || every(other.candidates, (t) => isTypeSubtypeOf(t, inferredCovariantType))));
|
|
63574
63602
|
inferredType = preferCovariantType ? inferredCovariantType : inferredContravariantType;
|
|
63575
63603
|
fallbackType = preferCovariantType ? inferredContravariantType : inferredCovariantType;
|
|
63576
63604
|
} else if (context.flags & 1 /* NoDefault */) {
|
|
@@ -66583,7 +66611,7 @@ function createTypeChecker(host) {
|
|
|
66583
66611
|
return getEffectiveFirstArgumentForJsxSignature(signature, callTarget);
|
|
66584
66612
|
}
|
|
66585
66613
|
const restIndex = signature.parameters.length - 1;
|
|
66586
|
-
return signatureHasRestParameter(signature) && argIndex >= restIndex ? getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex),
|
|
66614
|
+
return signatureHasRestParameter(signature) && argIndex >= restIndex ? getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 512 /* Contextual */) : getTypeAtPosition(signature, argIndex);
|
|
66587
66615
|
}
|
|
66588
66616
|
function getContextualTypeForDecorator(decorator) {
|
|
66589
66617
|
const signature = getDecoratorCallSignature(decorator);
|
|
@@ -69264,7 +69292,7 @@ function createTypeChecker(host) {
|
|
|
69264
69292
|
return errorType;
|
|
69265
69293
|
}
|
|
69266
69294
|
const effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
|
|
69267
|
-
const accessFlags = isAssignmentTarget(node) ?
|
|
69295
|
+
const accessFlags = isAssignmentTarget(node) ? 8 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 4 /* NoIndexSignatures */ : 0) : 64 /* ExpressionPosition */;
|
|
69268
69296
|
const indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType;
|
|
69269
69297
|
return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node);
|
|
69270
69298
|
}
|
|
@@ -69510,7 +69538,7 @@ function createTypeChecker(host) {
|
|
|
69510
69538
|
}
|
|
69511
69539
|
function getMutableArrayOrTupleType(type) {
|
|
69512
69540
|
return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(
|
|
69513
|
-
|
|
69541
|
+
getElementTypes(type),
|
|
69514
69542
|
type.target.elementFlags,
|
|
69515
69543
|
/*readonly*/
|
|
69516
69544
|
false,
|
|
@@ -69544,7 +69572,7 @@ function createTypeChecker(host) {
|
|
|
69544
69572
|
flags.push(4 /* Rest */);
|
|
69545
69573
|
}
|
|
69546
69574
|
} else {
|
|
69547
|
-
const contextualType = isTupleType(restType) ? getContextualTypeForElementExpression(restType, i - index, argCount - index) || unknownType : getIndexedAccessType(restType, getNumberLiteralType(i - index),
|
|
69575
|
+
const contextualType = isTupleType(restType) ? getContextualTypeForElementExpression(restType, i - index, argCount - index) || unknownType : getIndexedAccessType(restType, getNumberLiteralType(i - index), 512 /* Contextual */);
|
|
69548
69576
|
const argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode);
|
|
69549
69577
|
const hasPrimitiveContextualType = inConstContext || maybeTypeOfKind(contextualType, 402784252 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */);
|
|
69550
69578
|
types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
|
|
@@ -69824,7 +69852,7 @@ function createTypeChecker(host) {
|
|
|
69824
69852
|
const arg = args[i];
|
|
69825
69853
|
const spreadType = arg.kind === 229 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
69826
69854
|
if (spreadType && isTupleType(spreadType)) {
|
|
69827
|
-
forEach(
|
|
69855
|
+
forEach(getElementTypes(spreadType), (t, i2) => {
|
|
69828
69856
|
var _a;
|
|
69829
69857
|
const flags = spreadType.target.elementFlags[i2];
|
|
69830
69858
|
const syntheticArg = createSyntheticExpression(
|
|
@@ -72929,7 +72957,7 @@ function createTypeChecker(host) {
|
|
|
72929
72957
|
);
|
|
72930
72958
|
}
|
|
72931
72959
|
}
|
|
72932
|
-
const elementType = getIndexedAccessType(objectLiteralType, exprType,
|
|
72960
|
+
const elementType = getIndexedAccessType(objectLiteralType, exprType, 64 /* ExpressionPosition */, name);
|
|
72933
72961
|
const type = getFlowTypeOfDestructuring(property, elementType);
|
|
72934
72962
|
return checkDestructuringAssignment(property.kind === 303 /* ShorthandPropertyAssignment */ ? property : property.initializer, type);
|
|
72935
72963
|
} else if (property.kind === 304 /* SpreadAssignment */) {
|
|
@@ -72978,7 +73006,7 @@ function createTypeChecker(host) {
|
|
|
72978
73006
|
if (element.kind !== 229 /* SpreadElement */) {
|
|
72979
73007
|
const indexType = getNumberLiteralType(elementIndex);
|
|
72980
73008
|
if (isArrayLikeType(sourceType)) {
|
|
72981
|
-
const accessFlags =
|
|
73009
|
+
const accessFlags = 64 /* ExpressionPosition */ | (hasDefaultValue(element) ? 32 /* NoTupleBoundsCheck */ : 0);
|
|
72982
73010
|
const elementType2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType;
|
|
72983
73011
|
const assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType2, 524288 /* NEUndefined */) : elementType2;
|
|
72984
73012
|
const type = getFlowTypeOfDestructuring(element, assignedType);
|
|
@@ -73818,7 +73846,7 @@ function createTypeChecker(host) {
|
|
|
73818
73846
|
}
|
|
73819
73847
|
function padTupleType(type, pattern) {
|
|
73820
73848
|
const patternElements = pattern.elements;
|
|
73821
|
-
const elementTypes =
|
|
73849
|
+
const elementTypes = getElementTypes(type).slice();
|
|
73822
73850
|
const elementFlags = type.target.elementFlags.slice();
|
|
73823
73851
|
for (let i = getTypeReferenceArity(type); i < patternElements.length; i++) {
|
|
73824
73852
|
const e = patternElements[i];
|