mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Update LKG
This commit is contained in:
1 parent
e15166af42
commit
409311f363
9 files changed
+445
-391
No files matched your search
+75
-67
@@ -3029,7 +3029,7 @@ var ts;
|
||||
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." },
|
||||
Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." },
|
||||
Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'" },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" },
|
||||
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
|
||||
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." },
|
||||
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." },
|
||||
@@ -23060,11 +23060,11 @@ var ts;
|
||||
setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
var typeParameter = getTypeParameterFromMappedType(type);
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
var isomorphicType = getIsomorphicTypeFromMappedType(type);
|
||||
var homomorphicType = getHomomorphicTypeFromMappedType(type);
|
||||
var templateType = getTemplateTypeFromMappedType(type);
|
||||
var templateReadonly = !!type.declaration.readonlyToken;
|
||||
var templateOptional = !!type.declaration.questionToken;
|
||||
var keyType = constraintType.flags & 16384 ? getApparentType(constraintType) : constraintType;
|
||||
var keyType = constraintType.flags & 540672 ? getApparentType(constraintType) : constraintType;
|
||||
var iterationType = keyType.flags & 262144 ? getIndexType(getApparentType(keyType.type)) : keyType;
|
||||
forEachType(iterationType, function (t) {
|
||||
var iterationMapper = createUnaryTypeMapper(typeParameter, t);
|
||||
@@ -23072,11 +23072,11 @@ var ts;
|
||||
var propType = instantiateType(templateType, templateMapper);
|
||||
if (t.flags & 32) {
|
||||
var propName = t.text;
|
||||
var isomorphicProp = isomorphicType && getPropertyOfType(isomorphicType, propName);
|
||||
var isOptional = templateOptional || !!(isomorphicProp && isomorphicProp.flags & 536870912);
|
||||
var homomorphicProp = homomorphicType && getPropertyOfType(homomorphicType, propName);
|
||||
var isOptional = templateOptional || !!(homomorphicProp && homomorphicProp.flags & 536870912);
|
||||
var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName);
|
||||
prop.type = propType;
|
||||
prop.isReadonly = templateReadonly || isomorphicProp && isReadonlySymbol(isomorphicProp);
|
||||
prop.isReadonly = templateReadonly || homomorphicProp && isReadonlySymbol(homomorphicProp);
|
||||
members[propName] = prop;
|
||||
}
|
||||
else if (t.flags & 2) {
|
||||
@@ -23099,7 +23099,7 @@ var ts;
|
||||
instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!type.declaration.questionToken), type.mapper || identityMapper) :
|
||||
unknownType);
|
||||
}
|
||||
function getIsomorphicTypeFromMappedType(type) {
|
||||
function getHomomorphicTypeFromMappedType(type) {
|
||||
var constraint = getConstraintDeclaration(getTypeParameterFromMappedType(type));
|
||||
return constraint.kind === 168 ? instantiateType(getTypeFromTypeNode(constraint.type), type.mapper || identityMapper) : undefined;
|
||||
}
|
||||
@@ -23109,7 +23109,7 @@ var ts;
|
||||
function isGenericMappedType(type) {
|
||||
if (getObjectFlags(type) & 32) {
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
return !!(constraintType.flags & (16384 | 262144));
|
||||
return maybeTypeOfKind(constraintType, 540672 | 262144);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -24201,7 +24201,7 @@ var ts;
|
||||
}
|
||||
return links.resolvedType;
|
||||
}
|
||||
function getIndexTypeForTypeParameter(type) {
|
||||
function getIndexTypeForGenericType(type) {
|
||||
if (!type.resolvedIndexType) {
|
||||
type.resolvedIndexType = createType(262144);
|
||||
type.resolvedIndexType.type = type;
|
||||
@@ -24217,7 +24217,7 @@ var ts;
|
||||
return getUnionType(ts.map(getPropertiesOfType(type), getLiteralTypeFromPropertyName));
|
||||
}
|
||||
function getIndexType(type) {
|
||||
return type.flags & 16384 ? getIndexTypeForTypeParameter(type) :
|
||||
return maybeTypeOfKind(type, 540672) ? getIndexTypeForGenericType(type) :
|
||||
getObjectFlags(type) & 32 ? getConstraintTypeFromMappedType(type) :
|
||||
type.flags & 1 || getIndexInfoOfType(type, 0) ? stringType :
|
||||
getLiteralTypeFromPropertyNames(type);
|
||||
@@ -24312,9 +24312,10 @@ var ts;
|
||||
return instantiateType(getTemplateTypeFromMappedType(type), templateMapper);
|
||||
}
|
||||
function getIndexedAccessType(objectType, indexType, accessNode) {
|
||||
if (indexType.flags & 16384 ||
|
||||
objectType.flags & 16384 && indexType.flags & 262144 ||
|
||||
isGenericMappedType(objectType)) {
|
||||
if (maybeTypeOfKind(indexType, 540672 | 262144) || isGenericMappedType(objectType)) {
|
||||
if (objectType.flags & 1) {
|
||||
return objectType;
|
||||
}
|
||||
if (accessNode) {
|
||||
if (!isTypeAssignableTo(indexType, getIndexType(objectType))) {
|
||||
error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
||||
@@ -24746,12 +24747,12 @@ var ts;
|
||||
function instantiateMappedType(type, mapper) {
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
if (constraintType.flags & 262144) {
|
||||
var typeParameter_1 = constraintType.type;
|
||||
var mappedTypeParameter = mapper(typeParameter_1);
|
||||
if (typeParameter_1 !== mappedTypeParameter) {
|
||||
return mapType(mappedTypeParameter, function (t) {
|
||||
var typeVariable_1 = constraintType.type;
|
||||
var mappedTypeVariable = instantiateType(typeVariable_1, mapper);
|
||||
if (typeVariable_1 !== mappedTypeVariable) {
|
||||
return mapType(mappedTypeVariable, function (t) {
|
||||
if (isMappableType(t)) {
|
||||
var replacementMapper = createUnaryTypeMapper(typeParameter_1, t);
|
||||
var replacementMapper = createUnaryTypeMapper(typeVariable_1, t);
|
||||
var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper);
|
||||
combinedMapper.mappedTypes = mapper.mappedTypes;
|
||||
return instantiateMappedObjectType(type, combinedMapper);
|
||||
@@ -25311,10 +25312,12 @@ var ts;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
var constraint = getConstraintOfTypeParameter(target.type);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
|
||||
return result;
|
||||
if (target.type.flags & 16384) {
|
||||
var constraint = getConstraintOfTypeParameter(target.type);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26300,62 +26303,61 @@ var ts;
|
||||
isFixed: false,
|
||||
};
|
||||
}
|
||||
function couldContainTypeParameters(type) {
|
||||
function couldContainTypeVariables(type) {
|
||||
var objectFlags = getObjectFlags(type);
|
||||
return !!(type.flags & (16384 | 524288) ||
|
||||
objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeParameters) ||
|
||||
return !!(type.flags & 540672 ||
|
||||
objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) ||
|
||||
objectFlags & 16 && type.symbol && type.symbol.flags & (8192 | 2048 | 32) ||
|
||||
objectFlags & 32 ||
|
||||
type.flags & 196608 && couldUnionOrIntersectionContainTypeParameters(type));
|
||||
type.flags & 196608 && couldUnionOrIntersectionContainTypeVariables(type));
|
||||
}
|
||||
function couldUnionOrIntersectionContainTypeParameters(type) {
|
||||
if (type.couldContainTypeParameters === undefined) {
|
||||
type.couldContainTypeParameters = ts.forEach(type.types, couldContainTypeParameters);
|
||||
function couldUnionOrIntersectionContainTypeVariables(type) {
|
||||
if (type.couldContainTypeVariables === undefined) {
|
||||
type.couldContainTypeVariables = ts.forEach(type.types, couldContainTypeVariables);
|
||||
}
|
||||
return type.couldContainTypeParameters;
|
||||
return type.couldContainTypeVariables;
|
||||
}
|
||||
function isTypeParameterAtTopLevel(type, typeParameter) {
|
||||
return type === typeParameter || type.flags & 196608 && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); });
|
||||
}
|
||||
function inferTypeForIsomorphicMappedType(source, target) {
|
||||
if (!isMappableType(source)) {
|
||||
return source;
|
||||
function inferTypeForHomomorphicMappedType(source, target) {
|
||||
var properties = getPropertiesOfType(source);
|
||||
var indexInfo = getIndexInfoOfType(source, 0);
|
||||
if (properties.length === 0 && !indexInfo) {
|
||||
return undefined;
|
||||
}
|
||||
var typeParameter = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target));
|
||||
var typeParameterArray = [typeParameter];
|
||||
var typeVariable = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target));
|
||||
var typeVariableArray = [typeVariable];
|
||||
var typeInferences = createTypeInferencesObject();
|
||||
var typeInferencesArray = [typeInferences];
|
||||
var templateType = getTemplateTypeFromMappedType(target);
|
||||
var readonlyMask = target.declaration.readonlyToken ? false : true;
|
||||
var optionalMask = target.declaration.questionToken ? 0 : 536870912;
|
||||
var properties = getPropertiesOfType(source);
|
||||
var members = createSymbolTable(properties);
|
||||
var hasInferredTypes = false;
|
||||
for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) {
|
||||
var prop = properties_4[_i];
|
||||
var inferredPropType = inferTargetType(getTypeOfSymbol(prop));
|
||||
if (inferredPropType) {
|
||||
var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name);
|
||||
inferredProp.declarations = prop.declarations;
|
||||
inferredProp.type = inferredPropType;
|
||||
inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop);
|
||||
members[prop.name] = inferredProp;
|
||||
hasInferredTypes = true;
|
||||
if (!inferredPropType) {
|
||||
return undefined;
|
||||
}
|
||||
var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name);
|
||||
inferredProp.declarations = prop.declarations;
|
||||
inferredProp.type = inferredPropType;
|
||||
inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop);
|
||||
members[prop.name] = inferredProp;
|
||||
}
|
||||
var indexInfo = getIndexInfoOfType(source, 0);
|
||||
if (indexInfo) {
|
||||
var inferredIndexType = inferTargetType(indexInfo.type);
|
||||
if (inferredIndexType) {
|
||||
indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly);
|
||||
hasInferredTypes = true;
|
||||
if (!inferredIndexType) {
|
||||
return undefined;
|
||||
}
|
||||
indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly);
|
||||
}
|
||||
return hasInferredTypes ? createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfo, undefined) : source;
|
||||
return createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfo, undefined);
|
||||
function inferTargetType(sourceType) {
|
||||
typeInferences.primary = undefined;
|
||||
typeInferences.secondary = undefined;
|
||||
inferTypes(typeParameterArray, typeInferencesArray, sourceType, templateType);
|
||||
inferTypes(typeVariableArray, typeInferencesArray, sourceType, templateType);
|
||||
var inferences = typeInferences.primary || typeInferences.secondary;
|
||||
return inferences && getUnionType(inferences, true);
|
||||
}
|
||||
@@ -26363,7 +26365,7 @@ var ts;
|
||||
function inferTypesWithContext(context, originalSource, originalTarget) {
|
||||
inferTypes(context.signature.typeParameters, context.inferences, originalSource, originalTarget);
|
||||
}
|
||||
function inferTypes(typeParameters, typeInferences, originalSource, originalTarget) {
|
||||
function inferTypes(typeVariables, typeInferences, originalSource, originalTarget) {
|
||||
var sourceStack;
|
||||
var targetStack;
|
||||
var depth = 0;
|
||||
@@ -26379,7 +26381,7 @@ var ts;
|
||||
return false;
|
||||
}
|
||||
function inferFromTypes(source, target) {
|
||||
if (!couldContainTypeParameters(target)) {
|
||||
if (!couldContainTypeVariables(target)) {
|
||||
return;
|
||||
}
|
||||
if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
|
||||
@@ -26418,12 +26420,12 @@ var ts;
|
||||
target = removeTypesFromUnionOrIntersection(target, matchingTypes);
|
||||
}
|
||||
}
|
||||
if (target.flags & (16384 | 524288)) {
|
||||
if (target.flags & 540672) {
|
||||
if (source.flags & 8388608) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < typeParameters.length; i++) {
|
||||
if (target === typeParameters[i]) {
|
||||
for (var i = 0; i < typeVariables.length; i++) {
|
||||
if (target === typeVariables[i]) {
|
||||
var inferences = typeInferences[i];
|
||||
if (!inferences.isFixed) {
|
||||
var candidates = inferiority ?
|
||||
@@ -26450,21 +26452,21 @@ var ts;
|
||||
}
|
||||
else if (target.flags & 196608) {
|
||||
var targetTypes = target.types;
|
||||
var typeParameterCount = 0;
|
||||
var typeParameter = void 0;
|
||||
var typeVariableCount = 0;
|
||||
var typeVariable = void 0;
|
||||
for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) {
|
||||
var t = targetTypes_2[_d];
|
||||
if (t.flags & 16384 && ts.contains(typeParameters, t)) {
|
||||
typeParameter = t;
|
||||
typeParameterCount++;
|
||||
if (t.flags & 540672 && ts.contains(typeVariables, t)) {
|
||||
typeVariable = t;
|
||||
typeVariableCount++;
|
||||
}
|
||||
else {
|
||||
inferFromTypes(source, t);
|
||||
}
|
||||
}
|
||||
if (typeParameterCount === 1) {
|
||||
if (typeVariableCount === 1) {
|
||||
inferiority++;
|
||||
inferFromTypes(source, typeParameter);
|
||||
inferFromTypes(source, typeVariable);
|
||||
inferiority--;
|
||||
}
|
||||
}
|
||||
@@ -26505,9 +26507,14 @@ var ts;
|
||||
if (getObjectFlags(target) & 32) {
|
||||
var constraintType = getConstraintTypeFromMappedType(target);
|
||||
if (constraintType.flags & 262144) {
|
||||
var index = ts.indexOf(typeParameters, constraintType.type);
|
||||
var index = ts.indexOf(typeVariables, constraintType.type);
|
||||
if (index >= 0 && !typeInferences[index].isFixed) {
|
||||
inferFromTypes(inferTypeForIsomorphicMappedType(source, target), typeParameters[index]);
|
||||
var inferredType = inferTypeForHomomorphicMappedType(source, target);
|
||||
if (inferredType) {
|
||||
inferiority++;
|
||||
inferFromTypes(inferredType, typeVariables[index]);
|
||||
inferiority--;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -30633,7 +30640,7 @@ var ts;
|
||||
if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) {
|
||||
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
|
||||
}
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384 | 524288)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) {
|
||||
error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
return booleanType;
|
||||
@@ -32824,7 +32831,7 @@ var ts;
|
||||
checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access);
|
||||
}
|
||||
}
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384 | 524288)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) {
|
||||
error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
checkSourceElement(node.statement);
|
||||
@@ -37622,6 +37629,7 @@ var ts;
|
||||
case 145:
|
||||
case 228:
|
||||
case 147:
|
||||
return undefined;
|
||||
case 150:
|
||||
return visitConstructor(node);
|
||||
case 227:
|
||||
@@ -50661,7 +50669,7 @@ var ts;
|
||||
"es2017": 4,
|
||||
"esnext": 5,
|
||||
}),
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT,
|
||||
paramType: ts.Diagnostics.VERSION,
|
||||
},
|
||||
{
|
||||
|
||||
+75
-67
@@ -3034,7 +3034,7 @@ var ts;
|
||||
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." },
|
||||
Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." },
|
||||
Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'" },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" },
|
||||
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
|
||||
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." },
|
||||
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." },
|
||||
@@ -5043,7 +5043,7 @@ var ts;
|
||||
"es2017": 4,
|
||||
"esnext": 5,
|
||||
}),
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT,
|
||||
paramType: ts.Diagnostics.VERSION,
|
||||
},
|
||||
{
|
||||
@@ -24574,11 +24574,11 @@ var ts;
|
||||
setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
var typeParameter = getTypeParameterFromMappedType(type);
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
var isomorphicType = getIsomorphicTypeFromMappedType(type);
|
||||
var homomorphicType = getHomomorphicTypeFromMappedType(type);
|
||||
var templateType = getTemplateTypeFromMappedType(type);
|
||||
var templateReadonly = !!type.declaration.readonlyToken;
|
||||
var templateOptional = !!type.declaration.questionToken;
|
||||
var keyType = constraintType.flags & 16384 ? getApparentType(constraintType) : constraintType;
|
||||
var keyType = constraintType.flags & 540672 ? getApparentType(constraintType) : constraintType;
|
||||
var iterationType = keyType.flags & 262144 ? getIndexType(getApparentType(keyType.type)) : keyType;
|
||||
forEachType(iterationType, function (t) {
|
||||
var iterationMapper = createUnaryTypeMapper(typeParameter, t);
|
||||
@@ -24586,11 +24586,11 @@ var ts;
|
||||
var propType = instantiateType(templateType, templateMapper);
|
||||
if (t.flags & 32) {
|
||||
var propName = t.text;
|
||||
var isomorphicProp = isomorphicType && getPropertyOfType(isomorphicType, propName);
|
||||
var isOptional = templateOptional || !!(isomorphicProp && isomorphicProp.flags & 536870912);
|
||||
var homomorphicProp = homomorphicType && getPropertyOfType(homomorphicType, propName);
|
||||
var isOptional = templateOptional || !!(homomorphicProp && homomorphicProp.flags & 536870912);
|
||||
var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName);
|
||||
prop.type = propType;
|
||||
prop.isReadonly = templateReadonly || isomorphicProp && isReadonlySymbol(isomorphicProp);
|
||||
prop.isReadonly = templateReadonly || homomorphicProp && isReadonlySymbol(homomorphicProp);
|
||||
members[propName] = prop;
|
||||
}
|
||||
else if (t.flags & 2) {
|
||||
@@ -24613,7 +24613,7 @@ var ts;
|
||||
instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!type.declaration.questionToken), type.mapper || identityMapper) :
|
||||
unknownType);
|
||||
}
|
||||
function getIsomorphicTypeFromMappedType(type) {
|
||||
function getHomomorphicTypeFromMappedType(type) {
|
||||
var constraint = getConstraintDeclaration(getTypeParameterFromMappedType(type));
|
||||
return constraint.kind === 168 ? instantiateType(getTypeFromTypeNode(constraint.type), type.mapper || identityMapper) : undefined;
|
||||
}
|
||||
@@ -24623,7 +24623,7 @@ var ts;
|
||||
function isGenericMappedType(type) {
|
||||
if (getObjectFlags(type) & 32) {
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
return !!(constraintType.flags & (16384 | 262144));
|
||||
return maybeTypeOfKind(constraintType, 540672 | 262144);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -25715,7 +25715,7 @@ var ts;
|
||||
}
|
||||
return links.resolvedType;
|
||||
}
|
||||
function getIndexTypeForTypeParameter(type) {
|
||||
function getIndexTypeForGenericType(type) {
|
||||
if (!type.resolvedIndexType) {
|
||||
type.resolvedIndexType = createType(262144);
|
||||
type.resolvedIndexType.type = type;
|
||||
@@ -25731,7 +25731,7 @@ var ts;
|
||||
return getUnionType(ts.map(getPropertiesOfType(type), getLiteralTypeFromPropertyName));
|
||||
}
|
||||
function getIndexType(type) {
|
||||
return type.flags & 16384 ? getIndexTypeForTypeParameter(type) :
|
||||
return maybeTypeOfKind(type, 540672) ? getIndexTypeForGenericType(type) :
|
||||
getObjectFlags(type) & 32 ? getConstraintTypeFromMappedType(type) :
|
||||
type.flags & 1 || getIndexInfoOfType(type, 0) ? stringType :
|
||||
getLiteralTypeFromPropertyNames(type);
|
||||
@@ -25826,9 +25826,10 @@ var ts;
|
||||
return instantiateType(getTemplateTypeFromMappedType(type), templateMapper);
|
||||
}
|
||||
function getIndexedAccessType(objectType, indexType, accessNode) {
|
||||
if (indexType.flags & 16384 ||
|
||||
objectType.flags & 16384 && indexType.flags & 262144 ||
|
||||
isGenericMappedType(objectType)) {
|
||||
if (maybeTypeOfKind(indexType, 540672 | 262144) || isGenericMappedType(objectType)) {
|
||||
if (objectType.flags & 1) {
|
||||
return objectType;
|
||||
}
|
||||
if (accessNode) {
|
||||
if (!isTypeAssignableTo(indexType, getIndexType(objectType))) {
|
||||
error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
||||
@@ -26260,12 +26261,12 @@ var ts;
|
||||
function instantiateMappedType(type, mapper) {
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
if (constraintType.flags & 262144) {
|
||||
var typeParameter_1 = constraintType.type;
|
||||
var mappedTypeParameter = mapper(typeParameter_1);
|
||||
if (typeParameter_1 !== mappedTypeParameter) {
|
||||
return mapType(mappedTypeParameter, function (t) {
|
||||
var typeVariable_1 = constraintType.type;
|
||||
var mappedTypeVariable = instantiateType(typeVariable_1, mapper);
|
||||
if (typeVariable_1 !== mappedTypeVariable) {
|
||||
return mapType(mappedTypeVariable, function (t) {
|
||||
if (isMappableType(t)) {
|
||||
var replacementMapper = createUnaryTypeMapper(typeParameter_1, t);
|
||||
var replacementMapper = createUnaryTypeMapper(typeVariable_1, t);
|
||||
var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper);
|
||||
combinedMapper.mappedTypes = mapper.mappedTypes;
|
||||
return instantiateMappedObjectType(type, combinedMapper);
|
||||
@@ -26825,10 +26826,12 @@ var ts;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
var constraint = getConstraintOfTypeParameter(target.type);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
|
||||
return result;
|
||||
if (target.type.flags & 16384) {
|
||||
var constraint = getConstraintOfTypeParameter(target.type);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27814,62 +27817,61 @@ var ts;
|
||||
isFixed: false,
|
||||
};
|
||||
}
|
||||
function couldContainTypeParameters(type) {
|
||||
function couldContainTypeVariables(type) {
|
||||
var objectFlags = getObjectFlags(type);
|
||||
return !!(type.flags & (16384 | 524288) ||
|
||||
objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeParameters) ||
|
||||
return !!(type.flags & 540672 ||
|
||||
objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) ||
|
||||
objectFlags & 16 && type.symbol && type.symbol.flags & (8192 | 2048 | 32) ||
|
||||
objectFlags & 32 ||
|
||||
type.flags & 196608 && couldUnionOrIntersectionContainTypeParameters(type));
|
||||
type.flags & 196608 && couldUnionOrIntersectionContainTypeVariables(type));
|
||||
}
|
||||
function couldUnionOrIntersectionContainTypeParameters(type) {
|
||||
if (type.couldContainTypeParameters === undefined) {
|
||||
type.couldContainTypeParameters = ts.forEach(type.types, couldContainTypeParameters);
|
||||
function couldUnionOrIntersectionContainTypeVariables(type) {
|
||||
if (type.couldContainTypeVariables === undefined) {
|
||||
type.couldContainTypeVariables = ts.forEach(type.types, couldContainTypeVariables);
|
||||
}
|
||||
return type.couldContainTypeParameters;
|
||||
return type.couldContainTypeVariables;
|
||||
}
|
||||
function isTypeParameterAtTopLevel(type, typeParameter) {
|
||||
return type === typeParameter || type.flags & 196608 && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); });
|
||||
}
|
||||
function inferTypeForIsomorphicMappedType(source, target) {
|
||||
if (!isMappableType(source)) {
|
||||
return source;
|
||||
function inferTypeForHomomorphicMappedType(source, target) {
|
||||
var properties = getPropertiesOfType(source);
|
||||
var indexInfo = getIndexInfoOfType(source, 0);
|
||||
if (properties.length === 0 && !indexInfo) {
|
||||
return undefined;
|
||||
}
|
||||
var typeParameter = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target));
|
||||
var typeParameterArray = [typeParameter];
|
||||
var typeVariable = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target));
|
||||
var typeVariableArray = [typeVariable];
|
||||
var typeInferences = createTypeInferencesObject();
|
||||
var typeInferencesArray = [typeInferences];
|
||||
var templateType = getTemplateTypeFromMappedType(target);
|
||||
var readonlyMask = target.declaration.readonlyToken ? false : true;
|
||||
var optionalMask = target.declaration.questionToken ? 0 : 536870912;
|
||||
var properties = getPropertiesOfType(source);
|
||||
var members = createSymbolTable(properties);
|
||||
var hasInferredTypes = false;
|
||||
for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) {
|
||||
var prop = properties_4[_i];
|
||||
var inferredPropType = inferTargetType(getTypeOfSymbol(prop));
|
||||
if (inferredPropType) {
|
||||
var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name);
|
||||
inferredProp.declarations = prop.declarations;
|
||||
inferredProp.type = inferredPropType;
|
||||
inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop);
|
||||
members[prop.name] = inferredProp;
|
||||
hasInferredTypes = true;
|
||||
if (!inferredPropType) {
|
||||
return undefined;
|
||||
}
|
||||
var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name);
|
||||
inferredProp.declarations = prop.declarations;
|
||||
inferredProp.type = inferredPropType;
|
||||
inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop);
|
||||
members[prop.name] = inferredProp;
|
||||
}
|
||||
var indexInfo = getIndexInfoOfType(source, 0);
|
||||
if (indexInfo) {
|
||||
var inferredIndexType = inferTargetType(indexInfo.type);
|
||||
if (inferredIndexType) {
|
||||
indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly);
|
||||
hasInferredTypes = true;
|
||||
if (!inferredIndexType) {
|
||||
return undefined;
|
||||
}
|
||||
indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly);
|
||||
}
|
||||
return hasInferredTypes ? createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfo, undefined) : source;
|
||||
return createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfo, undefined);
|
||||
function inferTargetType(sourceType) {
|
||||
typeInferences.primary = undefined;
|
||||
typeInferences.secondary = undefined;
|
||||
inferTypes(typeParameterArray, typeInferencesArray, sourceType, templateType);
|
||||
inferTypes(typeVariableArray, typeInferencesArray, sourceType, templateType);
|
||||
var inferences = typeInferences.primary || typeInferences.secondary;
|
||||
return inferences && getUnionType(inferences, true);
|
||||
}
|
||||
@@ -27877,7 +27879,7 @@ var ts;
|
||||
function inferTypesWithContext(context, originalSource, originalTarget) {
|
||||
inferTypes(context.signature.typeParameters, context.inferences, originalSource, originalTarget);
|
||||
}
|
||||
function inferTypes(typeParameters, typeInferences, originalSource, originalTarget) {
|
||||
function inferTypes(typeVariables, typeInferences, originalSource, originalTarget) {
|
||||
var sourceStack;
|
||||
var targetStack;
|
||||
var depth = 0;
|
||||
@@ -27893,7 +27895,7 @@ var ts;
|
||||
return false;
|
||||
}
|
||||
function inferFromTypes(source, target) {
|
||||
if (!couldContainTypeParameters(target)) {
|
||||
if (!couldContainTypeVariables(target)) {
|
||||
return;
|
||||
}
|
||||
if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
|
||||
@@ -27932,12 +27934,12 @@ var ts;
|
||||
target = removeTypesFromUnionOrIntersection(target, matchingTypes);
|
||||
}
|
||||
}
|
||||
if (target.flags & (16384 | 524288)) {
|
||||
if (target.flags & 540672) {
|
||||
if (source.flags & 8388608) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < typeParameters.length; i++) {
|
||||
if (target === typeParameters[i]) {
|
||||
for (var i = 0; i < typeVariables.length; i++) {
|
||||
if (target === typeVariables[i]) {
|
||||
var inferences = typeInferences[i];
|
||||
if (!inferences.isFixed) {
|
||||
var candidates = inferiority ?
|
||||
@@ -27964,21 +27966,21 @@ var ts;
|
||||
}
|
||||
else if (target.flags & 196608) {
|
||||
var targetTypes = target.types;
|
||||
var typeParameterCount = 0;
|
||||
var typeParameter = void 0;
|
||||
var typeVariableCount = 0;
|
||||
var typeVariable = void 0;
|
||||
for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) {
|
||||
var t = targetTypes_2[_d];
|
||||
if (t.flags & 16384 && ts.contains(typeParameters, t)) {
|
||||
typeParameter = t;
|
||||
typeParameterCount++;
|
||||
if (t.flags & 540672 && ts.contains(typeVariables, t)) {
|
||||
typeVariable = t;
|
||||
typeVariableCount++;
|
||||
}
|
||||
else {
|
||||
inferFromTypes(source, t);
|
||||
}
|
||||
}
|
||||
if (typeParameterCount === 1) {
|
||||
if (typeVariableCount === 1) {
|
||||
inferiority++;
|
||||
inferFromTypes(source, typeParameter);
|
||||
inferFromTypes(source, typeVariable);
|
||||
inferiority--;
|
||||
}
|
||||
}
|
||||
@@ -28019,9 +28021,14 @@ var ts;
|
||||
if (getObjectFlags(target) & 32) {
|
||||
var constraintType = getConstraintTypeFromMappedType(target);
|
||||
if (constraintType.flags & 262144) {
|
||||
var index = ts.indexOf(typeParameters, constraintType.type);
|
||||
var index = ts.indexOf(typeVariables, constraintType.type);
|
||||
if (index >= 0 && !typeInferences[index].isFixed) {
|
||||
inferFromTypes(inferTypeForIsomorphicMappedType(source, target), typeParameters[index]);
|
||||
var inferredType = inferTypeForHomomorphicMappedType(source, target);
|
||||
if (inferredType) {
|
||||
inferiority++;
|
||||
inferFromTypes(inferredType, typeVariables[index]);
|
||||
inferiority--;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -32147,7 +32154,7 @@ var ts;
|
||||
if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) {
|
||||
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
|
||||
}
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384 | 524288)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) {
|
||||
error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
return booleanType;
|
||||
@@ -34338,7 +34345,7 @@ var ts;
|
||||
checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access);
|
||||
}
|
||||
}
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384 | 524288)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) {
|
||||
error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
checkSourceElement(node.statement);
|
||||
@@ -39136,6 +39143,7 @@ var ts;
|
||||
case 145:
|
||||
case 228:
|
||||
case 147:
|
||||
return undefined;
|
||||
case 150:
|
||||
return visitConstructor(node);
|
||||
case 227:
|
||||
|
||||
Vendored
+12
-8
@@ -2820,6 +2820,7 @@ declare namespace ts {
|
||||
UnionOrIntersection = 196608,
|
||||
StructuredType = 229376,
|
||||
StructuredOrTypeParameter = 507904,
|
||||
TypeVariable = 540672,
|
||||
Narrowable = 1033215,
|
||||
NotUnionOrUnit = 33281,
|
||||
RequiresWidening = 6291456,
|
||||
@@ -2889,7 +2890,8 @@ declare namespace ts {
|
||||
interface UnionOrIntersectionType extends Type {
|
||||
types: Type[];
|
||||
resolvedProperties: SymbolTable;
|
||||
couldContainTypeParameters: boolean;
|
||||
resolvedIndexType: IndexType;
|
||||
couldContainTypeVariables: boolean;
|
||||
}
|
||||
interface UnionType extends UnionOrIntersectionType {
|
||||
}
|
||||
@@ -2926,21 +2928,23 @@ declare namespace ts {
|
||||
iterableElementType?: Type;
|
||||
iteratorElementType?: Type;
|
||||
}
|
||||
interface TypeParameter extends Type {
|
||||
interface TypeVariable extends Type {
|
||||
resolvedIndexType: IndexType;
|
||||
}
|
||||
interface TypeParameter extends TypeVariable {
|
||||
constraint: Type;
|
||||
target?: TypeParameter;
|
||||
mapper?: TypeMapper;
|
||||
resolvedApparentType: Type;
|
||||
resolvedIndexType: IndexType;
|
||||
isThisType?: boolean;
|
||||
}
|
||||
interface IndexType extends Type {
|
||||
type: TypeParameter;
|
||||
}
|
||||
interface IndexedAccessType extends Type {
|
||||
interface IndexedAccessType extends TypeVariable {
|
||||
objectType: Type;
|
||||
indexType: Type;
|
||||
}
|
||||
interface IndexType extends Type {
|
||||
type: TypeVariable | UnionOrIntersectionType;
|
||||
}
|
||||
const enum SignatureKind {
|
||||
Call = 0,
|
||||
Construct = 1,
|
||||
@@ -7530,7 +7534,7 @@ declare namespace ts {
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: {
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
key: string;
|
||||
|
||||
+75
-67
@@ -3034,7 +3034,7 @@ var ts;
|
||||
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." },
|
||||
Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." },
|
||||
Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'" },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" },
|
||||
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
|
||||
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." },
|
||||
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." },
|
||||
@@ -5043,7 +5043,7 @@ var ts;
|
||||
"es2017": 4,
|
||||
"esnext": 5,
|
||||
}),
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT,
|
||||
paramType: ts.Diagnostics.VERSION,
|
||||
},
|
||||
{
|
||||
@@ -24574,11 +24574,11 @@ var ts;
|
||||
setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
var typeParameter = getTypeParameterFromMappedType(type);
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
var isomorphicType = getIsomorphicTypeFromMappedType(type);
|
||||
var homomorphicType = getHomomorphicTypeFromMappedType(type);
|
||||
var templateType = getTemplateTypeFromMappedType(type);
|
||||
var templateReadonly = !!type.declaration.readonlyToken;
|
||||
var templateOptional = !!type.declaration.questionToken;
|
||||
var keyType = constraintType.flags & 16384 ? getApparentType(constraintType) : constraintType;
|
||||
var keyType = constraintType.flags & 540672 ? getApparentType(constraintType) : constraintType;
|
||||
var iterationType = keyType.flags & 262144 ? getIndexType(getApparentType(keyType.type)) : keyType;
|
||||
forEachType(iterationType, function (t) {
|
||||
var iterationMapper = createUnaryTypeMapper(typeParameter, t);
|
||||
@@ -24586,11 +24586,11 @@ var ts;
|
||||
var propType = instantiateType(templateType, templateMapper);
|
||||
if (t.flags & 32) {
|
||||
var propName = t.text;
|
||||
var isomorphicProp = isomorphicType && getPropertyOfType(isomorphicType, propName);
|
||||
var isOptional = templateOptional || !!(isomorphicProp && isomorphicProp.flags & 536870912);
|
||||
var homomorphicProp = homomorphicType && getPropertyOfType(homomorphicType, propName);
|
||||
var isOptional = templateOptional || !!(homomorphicProp && homomorphicProp.flags & 536870912);
|
||||
var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName);
|
||||
prop.type = propType;
|
||||
prop.isReadonly = templateReadonly || isomorphicProp && isReadonlySymbol(isomorphicProp);
|
||||
prop.isReadonly = templateReadonly || homomorphicProp && isReadonlySymbol(homomorphicProp);
|
||||
members[propName] = prop;
|
||||
}
|
||||
else if (t.flags & 2) {
|
||||
@@ -24613,7 +24613,7 @@ var ts;
|
||||
instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!type.declaration.questionToken), type.mapper || identityMapper) :
|
||||
unknownType);
|
||||
}
|
||||
function getIsomorphicTypeFromMappedType(type) {
|
||||
function getHomomorphicTypeFromMappedType(type) {
|
||||
var constraint = getConstraintDeclaration(getTypeParameterFromMappedType(type));
|
||||
return constraint.kind === 168 ? instantiateType(getTypeFromTypeNode(constraint.type), type.mapper || identityMapper) : undefined;
|
||||
}
|
||||
@@ -24623,7 +24623,7 @@ var ts;
|
||||
function isGenericMappedType(type) {
|
||||
if (getObjectFlags(type) & 32) {
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
return !!(constraintType.flags & (16384 | 262144));
|
||||
return maybeTypeOfKind(constraintType, 540672 | 262144);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -25715,7 +25715,7 @@ var ts;
|
||||
}
|
||||
return links.resolvedType;
|
||||
}
|
||||
function getIndexTypeForTypeParameter(type) {
|
||||
function getIndexTypeForGenericType(type) {
|
||||
if (!type.resolvedIndexType) {
|
||||
type.resolvedIndexType = createType(262144);
|
||||
type.resolvedIndexType.type = type;
|
||||
@@ -25731,7 +25731,7 @@ var ts;
|
||||
return getUnionType(ts.map(getPropertiesOfType(type), getLiteralTypeFromPropertyName));
|
||||
}
|
||||
function getIndexType(type) {
|
||||
return type.flags & 16384 ? getIndexTypeForTypeParameter(type) :
|
||||
return maybeTypeOfKind(type, 540672) ? getIndexTypeForGenericType(type) :
|
||||
getObjectFlags(type) & 32 ? getConstraintTypeFromMappedType(type) :
|
||||
type.flags & 1 || getIndexInfoOfType(type, 0) ? stringType :
|
||||
getLiteralTypeFromPropertyNames(type);
|
||||
@@ -25826,9 +25826,10 @@ var ts;
|
||||
return instantiateType(getTemplateTypeFromMappedType(type), templateMapper);
|
||||
}
|
||||
function getIndexedAccessType(objectType, indexType, accessNode) {
|
||||
if (indexType.flags & 16384 ||
|
||||
objectType.flags & 16384 && indexType.flags & 262144 ||
|
||||
isGenericMappedType(objectType)) {
|
||||
if (maybeTypeOfKind(indexType, 540672 | 262144) || isGenericMappedType(objectType)) {
|
||||
if (objectType.flags & 1) {
|
||||
return objectType;
|
||||
}
|
||||
if (accessNode) {
|
||||
if (!isTypeAssignableTo(indexType, getIndexType(objectType))) {
|
||||
error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
||||
@@ -26260,12 +26261,12 @@ var ts;
|
||||
function instantiateMappedType(type, mapper) {
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
if (constraintType.flags & 262144) {
|
||||
var typeParameter_1 = constraintType.type;
|
||||
var mappedTypeParameter = mapper(typeParameter_1);
|
||||
if (typeParameter_1 !== mappedTypeParameter) {
|
||||
return mapType(mappedTypeParameter, function (t) {
|
||||
var typeVariable_1 = constraintType.type;
|
||||
var mappedTypeVariable = instantiateType(typeVariable_1, mapper);
|
||||
if (typeVariable_1 !== mappedTypeVariable) {
|
||||
return mapType(mappedTypeVariable, function (t) {
|
||||
if (isMappableType(t)) {
|
||||
var replacementMapper = createUnaryTypeMapper(typeParameter_1, t);
|
||||
var replacementMapper = createUnaryTypeMapper(typeVariable_1, t);
|
||||
var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper);
|
||||
combinedMapper.mappedTypes = mapper.mappedTypes;
|
||||
return instantiateMappedObjectType(type, combinedMapper);
|
||||
@@ -26825,10 +26826,12 @@ var ts;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
var constraint = getConstraintOfTypeParameter(target.type);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
|
||||
return result;
|
||||
if (target.type.flags & 16384) {
|
||||
var constraint = getConstraintOfTypeParameter(target.type);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27814,62 +27817,61 @@ var ts;
|
||||
isFixed: false,
|
||||
};
|
||||
}
|
||||
function couldContainTypeParameters(type) {
|
||||
function couldContainTypeVariables(type) {
|
||||
var objectFlags = getObjectFlags(type);
|
||||
return !!(type.flags & (16384 | 524288) ||
|
||||
objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeParameters) ||
|
||||
return !!(type.flags & 540672 ||
|
||||
objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) ||
|
||||
objectFlags & 16 && type.symbol && type.symbol.flags & (8192 | 2048 | 32) ||
|
||||
objectFlags & 32 ||
|
||||
type.flags & 196608 && couldUnionOrIntersectionContainTypeParameters(type));
|
||||
type.flags & 196608 && couldUnionOrIntersectionContainTypeVariables(type));
|
||||
}
|
||||
function couldUnionOrIntersectionContainTypeParameters(type) {
|
||||
if (type.couldContainTypeParameters === undefined) {
|
||||
type.couldContainTypeParameters = ts.forEach(type.types, couldContainTypeParameters);
|
||||
function couldUnionOrIntersectionContainTypeVariables(type) {
|
||||
if (type.couldContainTypeVariables === undefined) {
|
||||
type.couldContainTypeVariables = ts.forEach(type.types, couldContainTypeVariables);
|
||||
}
|
||||
return type.couldContainTypeParameters;
|
||||
return type.couldContainTypeVariables;
|
||||
}
|
||||
function isTypeParameterAtTopLevel(type, typeParameter) {
|
||||
return type === typeParameter || type.flags & 196608 && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); });
|
||||
}
|
||||
function inferTypeForIsomorphicMappedType(source, target) {
|
||||
if (!isMappableType(source)) {
|
||||
return source;
|
||||
function inferTypeForHomomorphicMappedType(source, target) {
|
||||
var properties = getPropertiesOfType(source);
|
||||
var indexInfo = getIndexInfoOfType(source, 0);
|
||||
if (properties.length === 0 && !indexInfo) {
|
||||
return undefined;
|
||||
}
|
||||
var typeParameter = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target));
|
||||
var typeParameterArray = [typeParameter];
|
||||
var typeVariable = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target));
|
||||
var typeVariableArray = [typeVariable];
|
||||
var typeInferences = createTypeInferencesObject();
|
||||
var typeInferencesArray = [typeInferences];
|
||||
var templateType = getTemplateTypeFromMappedType(target);
|
||||
var readonlyMask = target.declaration.readonlyToken ? false : true;
|
||||
var optionalMask = target.declaration.questionToken ? 0 : 536870912;
|
||||
var properties = getPropertiesOfType(source);
|
||||
var members = createSymbolTable(properties);
|
||||
var hasInferredTypes = false;
|
||||
for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) {
|
||||
var prop = properties_4[_i];
|
||||
var inferredPropType = inferTargetType(getTypeOfSymbol(prop));
|
||||
if (inferredPropType) {
|
||||
var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name);
|
||||
inferredProp.declarations = prop.declarations;
|
||||
inferredProp.type = inferredPropType;
|
||||
inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop);
|
||||
members[prop.name] = inferredProp;
|
||||
hasInferredTypes = true;
|
||||
if (!inferredPropType) {
|
||||
return undefined;
|
||||
}
|
||||
var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name);
|
||||
inferredProp.declarations = prop.declarations;
|
||||
inferredProp.type = inferredPropType;
|
||||
inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop);
|
||||
members[prop.name] = inferredProp;
|
||||
}
|
||||
var indexInfo = getIndexInfoOfType(source, 0);
|
||||
if (indexInfo) {
|
||||
var inferredIndexType = inferTargetType(indexInfo.type);
|
||||
if (inferredIndexType) {
|
||||
indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly);
|
||||
hasInferredTypes = true;
|
||||
if (!inferredIndexType) {
|
||||
return undefined;
|
||||
}
|
||||
indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly);
|
||||
}
|
||||
return hasInferredTypes ? createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfo, undefined) : source;
|
||||
return createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfo, undefined);
|
||||
function inferTargetType(sourceType) {
|
||||
typeInferences.primary = undefined;
|
||||
typeInferences.secondary = undefined;
|
||||
inferTypes(typeParameterArray, typeInferencesArray, sourceType, templateType);
|
||||
inferTypes(typeVariableArray, typeInferencesArray, sourceType, templateType);
|
||||
var inferences = typeInferences.primary || typeInferences.secondary;
|
||||
return inferences && getUnionType(inferences, true);
|
||||
}
|
||||
@@ -27877,7 +27879,7 @@ var ts;
|
||||
function inferTypesWithContext(context, originalSource, originalTarget) {
|
||||
inferTypes(context.signature.typeParameters, context.inferences, originalSource, originalTarget);
|
||||
}
|
||||
function inferTypes(typeParameters, typeInferences, originalSource, originalTarget) {
|
||||
function inferTypes(typeVariables, typeInferences, originalSource, originalTarget) {
|
||||
var sourceStack;
|
||||
var targetStack;
|
||||
var depth = 0;
|
||||
@@ -27893,7 +27895,7 @@ var ts;
|
||||
return false;
|
||||
}
|
||||
function inferFromTypes(source, target) {
|
||||
if (!couldContainTypeParameters(target)) {
|
||||
if (!couldContainTypeVariables(target)) {
|
||||
return;
|
||||
}
|
||||
if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
|
||||
@@ -27932,12 +27934,12 @@ var ts;
|
||||
target = removeTypesFromUnionOrIntersection(target, matchingTypes);
|
||||
}
|
||||
}
|
||||
if (target.flags & (16384 | 524288)) {
|
||||
if (target.flags & 540672) {
|
||||
if (source.flags & 8388608) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < typeParameters.length; i++) {
|
||||
if (target === typeParameters[i]) {
|
||||
for (var i = 0; i < typeVariables.length; i++) {
|
||||
if (target === typeVariables[i]) {
|
||||
var inferences = typeInferences[i];
|
||||
if (!inferences.isFixed) {
|
||||
var candidates = inferiority ?
|
||||
@@ -27964,21 +27966,21 @@ var ts;
|
||||
}
|
||||
else if (target.flags & 196608) {
|
||||
var targetTypes = target.types;
|
||||
var typeParameterCount = 0;
|
||||
var typeParameter = void 0;
|
||||
var typeVariableCount = 0;
|
||||
var typeVariable = void 0;
|
||||
for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) {
|
||||
var t = targetTypes_2[_d];
|
||||
if (t.flags & 16384 && ts.contains(typeParameters, t)) {
|
||||
typeParameter = t;
|
||||
typeParameterCount++;
|
||||
if (t.flags & 540672 && ts.contains(typeVariables, t)) {
|
||||
typeVariable = t;
|
||||
typeVariableCount++;
|
||||
}
|
||||
else {
|
||||
inferFromTypes(source, t);
|
||||
}
|
||||
}
|
||||
if (typeParameterCount === 1) {
|
||||
if (typeVariableCount === 1) {
|
||||
inferiority++;
|
||||
inferFromTypes(source, typeParameter);
|
||||
inferFromTypes(source, typeVariable);
|
||||
inferiority--;
|
||||
}
|
||||
}
|
||||
@@ -28019,9 +28021,14 @@ var ts;
|
||||
if (getObjectFlags(target) & 32) {
|
||||
var constraintType = getConstraintTypeFromMappedType(target);
|
||||
if (constraintType.flags & 262144) {
|
||||
var index = ts.indexOf(typeParameters, constraintType.type);
|
||||
var index = ts.indexOf(typeVariables, constraintType.type);
|
||||
if (index >= 0 && !typeInferences[index].isFixed) {
|
||||
inferFromTypes(inferTypeForIsomorphicMappedType(source, target), typeParameters[index]);
|
||||
var inferredType = inferTypeForHomomorphicMappedType(source, target);
|
||||
if (inferredType) {
|
||||
inferiority++;
|
||||
inferFromTypes(inferredType, typeVariables[index]);
|
||||
inferiority--;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -32147,7 +32154,7 @@ var ts;
|
||||
if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) {
|
||||
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
|
||||
}
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384 | 524288)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) {
|
||||
error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
return booleanType;
|
||||
@@ -34338,7 +34345,7 @@ var ts;
|
||||
checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access);
|
||||
}
|
||||
}
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384 | 524288)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) {
|
||||
error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
checkSourceElement(node.statement);
|
||||
@@ -39136,6 +39143,7 @@ var ts;
|
||||
case 145:
|
||||
case 228:
|
||||
case 147:
|
||||
return undefined;
|
||||
case 150:
|
||||
return visitConstructor(node);
|
||||
case 227:
|
||||
|
||||
Vendored
+8
-5
@@ -1775,6 +1775,7 @@ declare namespace ts {
|
||||
UnionOrIntersection = 196608,
|
||||
StructuredType = 229376,
|
||||
StructuredOrTypeParameter = 507904,
|
||||
TypeVariable = 540672,
|
||||
Narrowable = 1033215,
|
||||
NotUnionOrUnit = 33281,
|
||||
}
|
||||
@@ -1844,16 +1845,18 @@ declare namespace ts {
|
||||
elementType: Type;
|
||||
finalArrayType?: Type;
|
||||
}
|
||||
interface TypeParameter extends Type {
|
||||
interface TypeVariable extends Type {
|
||||
}
|
||||
interface TypeParameter extends TypeVariable {
|
||||
constraint: Type;
|
||||
}
|
||||
interface IndexType extends Type {
|
||||
type: TypeParameter;
|
||||
}
|
||||
interface IndexedAccessType extends Type {
|
||||
interface IndexedAccessType extends TypeVariable {
|
||||
objectType: Type;
|
||||
indexType: Type;
|
||||
}
|
||||
interface IndexType extends Type {
|
||||
type: TypeVariable | UnionOrIntersectionType;
|
||||
}
|
||||
enum SignatureKind {
|
||||
Call = 0,
|
||||
Construct = 1,
|
||||
|
||||
+95
-85
@@ -713,6 +713,7 @@ var ts;
|
||||
TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection";
|
||||
TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType";
|
||||
TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 507904] = "StructuredOrTypeParameter";
|
||||
TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable";
|
||||
// 'Narrowable' types are types where narrowing actually narrows.
|
||||
// This *should* be every type other than null, undefined, void, and never
|
||||
TypeFlags[TypeFlags["Narrowable"] = 1033215] = "Narrowable";
|
||||
@@ -4483,7 +4484,7 @@ var ts;
|
||||
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." },
|
||||
Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." },
|
||||
Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'" },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" },
|
||||
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
|
||||
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." },
|
||||
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." },
|
||||
@@ -28238,17 +28239,17 @@ var ts;
|
||||
setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
// In { [P in K]: T }, we refer to P as the type parameter type, K as the constraint type,
|
||||
// and T as the template type. If K is of the form 'keyof S', the mapped type and S are
|
||||
// isomorphic and we copy property modifiers from corresponding properties in S.
|
||||
// homomorphic and we copy property modifiers from corresponding properties in S.
|
||||
var typeParameter = getTypeParameterFromMappedType(type);
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
var isomorphicType = getIsomorphicTypeFromMappedType(type);
|
||||
var homomorphicType = getHomomorphicTypeFromMappedType(type);
|
||||
var templateType = getTemplateTypeFromMappedType(type);
|
||||
var templateReadonly = !!type.declaration.readonlyToken;
|
||||
var templateOptional = !!type.declaration.questionToken;
|
||||
// First, if the constraint type is a type parameter, obtain the base constraint. Then,
|
||||
// if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X.
|
||||
// Finally, iterate over the constituents of the resulting iteration type.
|
||||
var keyType = constraintType.flags & 16384 /* TypeParameter */ ? getApparentType(constraintType) : constraintType;
|
||||
var keyType = constraintType.flags & 540672 /* TypeVariable */ ? getApparentType(constraintType) : constraintType;
|
||||
var iterationType = keyType.flags & 262144 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType;
|
||||
forEachType(iterationType, function (t) {
|
||||
// Create a mapper from T to the current iteration type constituent. Then, if the
|
||||
@@ -28261,11 +28262,11 @@ var ts;
|
||||
// Otherwise, for type string create a string index signature.
|
||||
if (t.flags & 32 /* StringLiteral */) {
|
||||
var propName = t.text;
|
||||
var isomorphicProp = isomorphicType && getPropertyOfType(isomorphicType, propName);
|
||||
var isOptional = templateOptional || !!(isomorphicProp && isomorphicProp.flags & 536870912 /* Optional */);
|
||||
var homomorphicProp = homomorphicType && getPropertyOfType(homomorphicType, propName);
|
||||
var isOptional = templateOptional || !!(homomorphicProp && homomorphicProp.flags & 536870912 /* Optional */);
|
||||
var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | (isOptional ? 536870912 /* Optional */ : 0), propName);
|
||||
prop.type = propType;
|
||||
prop.isReadonly = templateReadonly || isomorphicProp && isReadonlySymbol(isomorphicProp);
|
||||
prop.isReadonly = templateReadonly || homomorphicProp && isReadonlySymbol(homomorphicProp);
|
||||
members[propName] = prop;
|
||||
}
|
||||
else if (t.flags & 2 /* String */) {
|
||||
@@ -28288,7 +28289,7 @@ var ts;
|
||||
instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!type.declaration.questionToken), type.mapper || identityMapper) :
|
||||
unknownType);
|
||||
}
|
||||
function getIsomorphicTypeFromMappedType(type) {
|
||||
function getHomomorphicTypeFromMappedType(type) {
|
||||
var constraint = getConstraintDeclaration(getTypeParameterFromMappedType(type));
|
||||
return constraint.kind === 168 /* TypeOperator */ ? instantiateType(getTypeFromTypeNode(constraint.type), type.mapper || identityMapper) : undefined;
|
||||
}
|
||||
@@ -28298,7 +28299,7 @@ var ts;
|
||||
function isGenericMappedType(type) {
|
||||
if (getObjectFlags(type) & 32 /* Mapped */) {
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
return !!(constraintType.flags & (16384 /* TypeParameter */ | 262144 /* Index */));
|
||||
return maybeTypeOfKind(constraintType, 540672 /* TypeVariable */ | 262144 /* Index */);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -29515,7 +29516,7 @@ var ts;
|
||||
}
|
||||
return links.resolvedType;
|
||||
}
|
||||
function getIndexTypeForTypeParameter(type) {
|
||||
function getIndexTypeForGenericType(type) {
|
||||
if (!type.resolvedIndexType) {
|
||||
type.resolvedIndexType = createType(262144 /* Index */);
|
||||
type.resolvedIndexType.type = type;
|
||||
@@ -29531,7 +29532,7 @@ var ts;
|
||||
return getUnionType(ts.map(getPropertiesOfType(type), getLiteralTypeFromPropertyName));
|
||||
}
|
||||
function getIndexType(type) {
|
||||
return type.flags & 16384 /* TypeParameter */ ? getIndexTypeForTypeParameter(type) :
|
||||
return maybeTypeOfKind(type, 540672 /* TypeVariable */) ? getIndexTypeForGenericType(type) :
|
||||
getObjectFlags(type) & 32 /* Mapped */ ? getConstraintTypeFromMappedType(type) :
|
||||
type.flags & 1 /* Any */ || getIndexInfoOfType(type, 0 /* String */) ? stringType :
|
||||
getLiteralTypeFromPropertyNames(type);
|
||||
@@ -29626,13 +29627,14 @@ var ts;
|
||||
return instantiateType(getTemplateTypeFromMappedType(type), templateMapper);
|
||||
}
|
||||
function getIndexedAccessType(objectType, indexType, accessNode) {
|
||||
if (indexType.flags & 16384 /* TypeParameter */ ||
|
||||
objectType.flags & 16384 /* TypeParameter */ && indexType.flags & 262144 /* Index */ ||
|
||||
isGenericMappedType(objectType)) {
|
||||
// If either the object type or the index type are type parameters, or if the object type is a mapped
|
||||
// type with a generic constraint, we are performing a higher-order index access where we cannot
|
||||
// meaningfully access the properties of the object type. In those cases, we first check that the
|
||||
// index type is assignable to 'keyof T' for the object type.
|
||||
if (maybeTypeOfKind(indexType, 540672 /* TypeVariable */ | 262144 /* Index */) || isGenericMappedType(objectType)) {
|
||||
if (objectType.flags & 1 /* Any */) {
|
||||
return objectType;
|
||||
}
|
||||
// If the index type is generic or if the object type is a mapped type with a generic constraint,
|
||||
// we are performing a higher-order index access where we cannot meaningfully access the properties
|
||||
// of the object type. In those cases, we first check that the index type is assignable to 'keyof T'
|
||||
// for the object type.
|
||||
if (accessNode) {
|
||||
if (!isTypeAssignableTo(indexType, getIndexType(objectType))) {
|
||||
error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
||||
@@ -30086,19 +30088,19 @@ var ts;
|
||||
return result;
|
||||
}
|
||||
function instantiateMappedType(type, mapper) {
|
||||
// Check if we have an isomorphic mapped type, i.e. a type of the form { [P in keyof T]: X } for some
|
||||
// type parameter T. If so, the mapped type is distributive over a union type and when T is instantiated
|
||||
// Check if we have a homomorphic mapped type, i.e. a type of the form { [P in keyof T]: X } for some
|
||||
// type variable T. If so, the mapped type is distributive over a union type and when T is instantiated
|
||||
// to a union type A | B, we produce { [P in keyof A]: X } | { [P in keyof B]: X }. Furthermore, for
|
||||
// isomorphic mapped types we leave primitive types alone. For example, when T is instantiated to a
|
||||
// homomorphic mapped types we leave primitive types alone. For example, when T is instantiated to a
|
||||
// union type A | undefined, we produce { [P in keyof A]: X } | undefined.
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
if (constraintType.flags & 262144 /* Index */) {
|
||||
var typeParameter_1 = constraintType.type;
|
||||
var mappedTypeParameter = mapper(typeParameter_1);
|
||||
if (typeParameter_1 !== mappedTypeParameter) {
|
||||
return mapType(mappedTypeParameter, function (t) {
|
||||
var typeVariable_1 = constraintType.type;
|
||||
var mappedTypeVariable = instantiateType(typeVariable_1, mapper);
|
||||
if (typeVariable_1 !== mappedTypeVariable) {
|
||||
return mapType(mappedTypeVariable, function (t) {
|
||||
if (isMappableType(t)) {
|
||||
var replacementMapper = createUnaryTypeMapper(typeParameter_1, t);
|
||||
var replacementMapper = createUnaryTypeMapper(typeVariable_1, t);
|
||||
var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper);
|
||||
combinedMapper.mappedTypes = mapper.mappedTypes;
|
||||
return instantiateMappedObjectType(type, combinedMapper);
|
||||
@@ -30758,10 +30760,12 @@ var ts;
|
||||
}
|
||||
// Given a type parameter T with a constraint C, a type S is assignable to
|
||||
// keyof T if S is assignable to keyof C.
|
||||
var constraint = getConstraintOfTypeParameter(target.type);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
|
||||
return result;
|
||||
if (target.type.flags & 16384 /* TypeParameter */) {
|
||||
var constraint = getConstraintOfTypeParameter(target.type);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31867,66 +31871,65 @@ var ts;
|
||||
// Return true if the given type could possibly reference a type parameter for which
|
||||
// we perform type inference (i.e. a type parameter of a generic function). We cache
|
||||
// results for union and intersection types for performance reasons.
|
||||
function couldContainTypeParameters(type) {
|
||||
function couldContainTypeVariables(type) {
|
||||
var objectFlags = getObjectFlags(type);
|
||||
return !!(type.flags & (16384 /* TypeParameter */ | 524288 /* IndexedAccess */) ||
|
||||
objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeParameters) ||
|
||||
return !!(type.flags & 540672 /* TypeVariable */ ||
|
||||
objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) ||
|
||||
objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) ||
|
||||
objectFlags & 32 /* Mapped */ ||
|
||||
type.flags & 196608 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeParameters(type));
|
||||
type.flags & 196608 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type));
|
||||
}
|
||||
function couldUnionOrIntersectionContainTypeParameters(type) {
|
||||
if (type.couldContainTypeParameters === undefined) {
|
||||
type.couldContainTypeParameters = ts.forEach(type.types, couldContainTypeParameters);
|
||||
function couldUnionOrIntersectionContainTypeVariables(type) {
|
||||
if (type.couldContainTypeVariables === undefined) {
|
||||
type.couldContainTypeVariables = ts.forEach(type.types, couldContainTypeVariables);
|
||||
}
|
||||
return type.couldContainTypeParameters;
|
||||
return type.couldContainTypeVariables;
|
||||
}
|
||||
function isTypeParameterAtTopLevel(type, typeParameter) {
|
||||
return type === typeParameter || type.flags & 196608 /* UnionOrIntersection */ && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); });
|
||||
}
|
||||
// Infer a suitable input type for an isomorphic mapped type { [P in keyof T]: X }. We construct
|
||||
// Infer a suitable input type for a homomorphic mapped type { [P in keyof T]: X }. We construct
|
||||
// an object type with the same set of properties as the source type, where the type of each
|
||||
// property is computed by inferring from the source property type to X for a synthetic type
|
||||
// parameter T[P] (i.e. we treat the type T[P] as the type parameter we're inferring for).
|
||||
function inferTypeForIsomorphicMappedType(source, target) {
|
||||
if (!isMappableType(source)) {
|
||||
return source;
|
||||
// property is computed by inferring from the source property type to X for the type
|
||||
// variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for).
|
||||
function inferTypeForHomomorphicMappedType(source, target) {
|
||||
var properties = getPropertiesOfType(source);
|
||||
var indexInfo = getIndexInfoOfType(source, 0 /* String */);
|
||||
if (properties.length === 0 && !indexInfo) {
|
||||
return undefined;
|
||||
}
|
||||
var typeParameter = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target));
|
||||
var typeParameterArray = [typeParameter];
|
||||
var typeVariable = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target));
|
||||
var typeVariableArray = [typeVariable];
|
||||
var typeInferences = createTypeInferencesObject();
|
||||
var typeInferencesArray = [typeInferences];
|
||||
var templateType = getTemplateTypeFromMappedType(target);
|
||||
var readonlyMask = target.declaration.readonlyToken ? false : true;
|
||||
var optionalMask = target.declaration.questionToken ? 0 : 536870912 /* Optional */;
|
||||
var properties = getPropertiesOfType(source);
|
||||
var members = createSymbolTable(properties);
|
||||
var hasInferredTypes = false;
|
||||
for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) {
|
||||
var prop = properties_4[_i];
|
||||
var inferredPropType = inferTargetType(getTypeOfSymbol(prop));
|
||||
if (inferredPropType) {
|
||||
var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & optionalMask, prop.name);
|
||||
inferredProp.declarations = prop.declarations;
|
||||
inferredProp.type = inferredPropType;
|
||||
inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop);
|
||||
members[prop.name] = inferredProp;
|
||||
hasInferredTypes = true;
|
||||
if (!inferredPropType) {
|
||||
return undefined;
|
||||
}
|
||||
var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & optionalMask, prop.name);
|
||||
inferredProp.declarations = prop.declarations;
|
||||
inferredProp.type = inferredPropType;
|
||||
inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop);
|
||||
members[prop.name] = inferredProp;
|
||||
}
|
||||
var indexInfo = getIndexInfoOfType(source, 0 /* String */);
|
||||
if (indexInfo) {
|
||||
var inferredIndexType = inferTargetType(indexInfo.type);
|
||||
if (inferredIndexType) {
|
||||
indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly);
|
||||
hasInferredTypes = true;
|
||||
if (!inferredIndexType) {
|
||||
return undefined;
|
||||
}
|
||||
indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly);
|
||||
}
|
||||
return hasInferredTypes ? createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfo, undefined) : source;
|
||||
return createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfo, undefined);
|
||||
function inferTargetType(sourceType) {
|
||||
typeInferences.primary = undefined;
|
||||
typeInferences.secondary = undefined;
|
||||
inferTypes(typeParameterArray, typeInferencesArray, sourceType, templateType);
|
||||
inferTypes(typeVariableArray, typeInferencesArray, sourceType, templateType);
|
||||
var inferences = typeInferences.primary || typeInferences.secondary;
|
||||
return inferences && getUnionType(inferences, /*subtypeReduction*/ true);
|
||||
}
|
||||
@@ -31934,7 +31937,7 @@ var ts;
|
||||
function inferTypesWithContext(context, originalSource, originalTarget) {
|
||||
inferTypes(context.signature.typeParameters, context.inferences, originalSource, originalTarget);
|
||||
}
|
||||
function inferTypes(typeParameters, typeInferences, originalSource, originalTarget) {
|
||||
function inferTypes(typeVariables, typeInferences, originalSource, originalTarget) {
|
||||
var sourceStack;
|
||||
var targetStack;
|
||||
var depth = 0;
|
||||
@@ -31950,7 +31953,7 @@ var ts;
|
||||
return false;
|
||||
}
|
||||
function inferFromTypes(source, target) {
|
||||
if (!couldContainTypeParameters(target)) {
|
||||
if (!couldContainTypeVariables(target)) {
|
||||
return;
|
||||
}
|
||||
if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
|
||||
@@ -32002,7 +32005,7 @@ var ts;
|
||||
target = removeTypesFromUnionOrIntersection(target, matchingTypes);
|
||||
}
|
||||
}
|
||||
if (target.flags & (16384 /* TypeParameter */ | 524288 /* IndexedAccess */)) {
|
||||
if (target.flags & 540672 /* TypeVariable */) {
|
||||
// If target is a type parameter, make an inference, unless the source type contains
|
||||
// the anyFunctionType (the wildcard type that's used to avoid contextually typing functions).
|
||||
// Because the anyFunctionType is internal, it should not be exposed to the user by adding
|
||||
@@ -32012,8 +32015,8 @@ var ts;
|
||||
if (source.flags & 8388608 /* ContainsAnyFunctionType */) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < typeParameters.length; i++) {
|
||||
if (target === typeParameters[i]) {
|
||||
for (var i = 0; i < typeVariables.length; i++) {
|
||||
if (target === typeVariables[i]) {
|
||||
var inferences = typeInferences[i];
|
||||
if (!inferences.isFixed) {
|
||||
// Any inferences that are made to a type parameter in a union type are inferior
|
||||
@@ -32047,25 +32050,25 @@ var ts;
|
||||
}
|
||||
else if (target.flags & 196608 /* UnionOrIntersection */) {
|
||||
var targetTypes = target.types;
|
||||
var typeParameterCount = 0;
|
||||
var typeParameter = void 0;
|
||||
// First infer to each type in union or intersection that isn't a type parameter
|
||||
var typeVariableCount = 0;
|
||||
var typeVariable = void 0;
|
||||
// First infer to each type in union or intersection that isn't a type variable
|
||||
for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) {
|
||||
var t = targetTypes_2[_d];
|
||||
if (t.flags & 16384 /* TypeParameter */ && ts.contains(typeParameters, t)) {
|
||||
typeParameter = t;
|
||||
typeParameterCount++;
|
||||
if (t.flags & 540672 /* TypeVariable */ && ts.contains(typeVariables, t)) {
|
||||
typeVariable = t;
|
||||
typeVariableCount++;
|
||||
}
|
||||
else {
|
||||
inferFromTypes(source, t);
|
||||
}
|
||||
}
|
||||
// Next, if target containings a single naked type parameter, make a secondary inference to that type
|
||||
// parameter. This gives meaningful results for union types in co-variant positions and intersection
|
||||
// Next, if target containings a single naked type variable, make a secondary inference to that type
|
||||
// variable. This gives meaningful results for union types in co-variant positions and intersection
|
||||
// types in contra-variant positions (such as callback parameters).
|
||||
if (typeParameterCount === 1) {
|
||||
if (typeVariableCount === 1) {
|
||||
inferiority++;
|
||||
inferFromTypes(source, typeParameter);
|
||||
inferFromTypes(source, typeVariable);
|
||||
inferiority--;
|
||||
}
|
||||
}
|
||||
@@ -32107,12 +32110,18 @@ var ts;
|
||||
if (getObjectFlags(target) & 32 /* Mapped */) {
|
||||
var constraintType = getConstraintTypeFromMappedType(target);
|
||||
if (constraintType.flags & 262144 /* Index */) {
|
||||
// We're inferring from some source type S to an isomorphic mapped type { [P in keyof T]: X },
|
||||
// where T is a type parameter. Use inferTypeForIsomorphicMappedType to infer a suitable source
|
||||
// type and then infer from that type to T.
|
||||
var index = ts.indexOf(typeParameters, constraintType.type);
|
||||
// We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X },
|
||||
// where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source
|
||||
// type and then make a secondary inference from that type to T. We make a secondary inference
|
||||
// such that direct inferences to T get priority over inferences to Partial<T>, for example.
|
||||
var index = ts.indexOf(typeVariables, constraintType.type);
|
||||
if (index >= 0 && !typeInferences[index].isFixed) {
|
||||
inferFromTypes(inferTypeForIsomorphicMappedType(source, target), typeParameters[index]);
|
||||
var inferredType = inferTypeForHomomorphicMappedType(source, target);
|
||||
if (inferredType) {
|
||||
inferiority++;
|
||||
inferFromTypes(inferredType, typeVariables[index]);
|
||||
inferiority--;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -37257,7 +37266,7 @@ var ts;
|
||||
if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 /* NumberLike */ | 512 /* ESSymbol */))) {
|
||||
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
|
||||
}
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 16384 /* TypeParameter */ | 524288 /* IndexedAccess */)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */)) {
|
||||
error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
return booleanType;
|
||||
@@ -39890,7 +39899,7 @@ var ts;
|
||||
}
|
||||
// unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved
|
||||
// in this case error about missing name is already reported - do not report extra one
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 16384 /* TypeParameter */ | 524288 /* IndexedAccess */)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */)) {
|
||||
error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
checkSourceElement(node.statement);
|
||||
@@ -45506,7 +45515,8 @@ var ts;
|
||||
case 228 /* TypeAliasDeclaration */:
|
||||
// TypeScript type-only declarations are elided.
|
||||
case 147 /* PropertyDeclaration */:
|
||||
// TypeScript property declarations are elided.
|
||||
// TypeScript property declarations are elided.
|
||||
return undefined;
|
||||
case 150 /* Constructor */:
|
||||
return visitConstructor(node);
|
||||
case 227 /* InterfaceDeclaration */:
|
||||
@@ -63693,7 +63703,7 @@ var ts;
|
||||
"es2017": 4 /* ES2017 */,
|
||||
"esnext": 5 /* ESNext */,
|
||||
}),
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT,
|
||||
paramType: ts.Diagnostics.VERSION,
|
||||
},
|
||||
{
|
||||
|
||||
Vendored
+8
-5
@@ -1775,6 +1775,7 @@ declare namespace ts {
|
||||
UnionOrIntersection = 196608,
|
||||
StructuredType = 229376,
|
||||
StructuredOrTypeParameter = 507904,
|
||||
TypeVariable = 540672,
|
||||
Narrowable = 1033215,
|
||||
NotUnionOrUnit = 33281,
|
||||
}
|
||||
@@ -1844,16 +1845,18 @@ declare namespace ts {
|
||||
elementType: Type;
|
||||
finalArrayType?: Type;
|
||||
}
|
||||
interface TypeParameter extends Type {
|
||||
interface TypeVariable extends Type {
|
||||
}
|
||||
interface TypeParameter extends TypeVariable {
|
||||
constraint: Type;
|
||||
}
|
||||
interface IndexType extends Type {
|
||||
type: TypeParameter;
|
||||
}
|
||||
interface IndexedAccessType extends Type {
|
||||
interface IndexedAccessType extends TypeVariable {
|
||||
objectType: Type;
|
||||
indexType: Type;
|
||||
}
|
||||
interface IndexType extends Type {
|
||||
type: TypeVariable | UnionOrIntersectionType;
|
||||
}
|
||||
enum SignatureKind {
|
||||
Call = 0,
|
||||
Construct = 1,
|
||||
|
||||
+95
-85
@@ -713,6 +713,7 @@ var ts;
|
||||
TypeFlags[TypeFlags["UnionOrIntersection"] = 196608] = "UnionOrIntersection";
|
||||
TypeFlags[TypeFlags["StructuredType"] = 229376] = "StructuredType";
|
||||
TypeFlags[TypeFlags["StructuredOrTypeParameter"] = 507904] = "StructuredOrTypeParameter";
|
||||
TypeFlags[TypeFlags["TypeVariable"] = 540672] = "TypeVariable";
|
||||
// 'Narrowable' types are types where narrowing actually narrows.
|
||||
// This *should* be every type other than null, undefined, void, and never
|
||||
TypeFlags[TypeFlags["Narrowable"] = 1033215] = "Narrowable";
|
||||
@@ -4483,7 +4484,7 @@ var ts;
|
||||
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." },
|
||||
Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." },
|
||||
Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'" },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" },
|
||||
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
|
||||
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." },
|
||||
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." },
|
||||
@@ -28238,17 +28239,17 @@ var ts;
|
||||
setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
// In { [P in K]: T }, we refer to P as the type parameter type, K as the constraint type,
|
||||
// and T as the template type. If K is of the form 'keyof S', the mapped type and S are
|
||||
// isomorphic and we copy property modifiers from corresponding properties in S.
|
||||
// homomorphic and we copy property modifiers from corresponding properties in S.
|
||||
var typeParameter = getTypeParameterFromMappedType(type);
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
var isomorphicType = getIsomorphicTypeFromMappedType(type);
|
||||
var homomorphicType = getHomomorphicTypeFromMappedType(type);
|
||||
var templateType = getTemplateTypeFromMappedType(type);
|
||||
var templateReadonly = !!type.declaration.readonlyToken;
|
||||
var templateOptional = !!type.declaration.questionToken;
|
||||
// First, if the constraint type is a type parameter, obtain the base constraint. Then,
|
||||
// if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X.
|
||||
// Finally, iterate over the constituents of the resulting iteration type.
|
||||
var keyType = constraintType.flags & 16384 /* TypeParameter */ ? getApparentType(constraintType) : constraintType;
|
||||
var keyType = constraintType.flags & 540672 /* TypeVariable */ ? getApparentType(constraintType) : constraintType;
|
||||
var iterationType = keyType.flags & 262144 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType;
|
||||
forEachType(iterationType, function (t) {
|
||||
// Create a mapper from T to the current iteration type constituent. Then, if the
|
||||
@@ -28261,11 +28262,11 @@ var ts;
|
||||
// Otherwise, for type string create a string index signature.
|
||||
if (t.flags & 32 /* StringLiteral */) {
|
||||
var propName = t.text;
|
||||
var isomorphicProp = isomorphicType && getPropertyOfType(isomorphicType, propName);
|
||||
var isOptional = templateOptional || !!(isomorphicProp && isomorphicProp.flags & 536870912 /* Optional */);
|
||||
var homomorphicProp = homomorphicType && getPropertyOfType(homomorphicType, propName);
|
||||
var isOptional = templateOptional || !!(homomorphicProp && homomorphicProp.flags & 536870912 /* Optional */);
|
||||
var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | (isOptional ? 536870912 /* Optional */ : 0), propName);
|
||||
prop.type = propType;
|
||||
prop.isReadonly = templateReadonly || isomorphicProp && isReadonlySymbol(isomorphicProp);
|
||||
prop.isReadonly = templateReadonly || homomorphicProp && isReadonlySymbol(homomorphicProp);
|
||||
members[propName] = prop;
|
||||
}
|
||||
else if (t.flags & 2 /* String */) {
|
||||
@@ -28288,7 +28289,7 @@ var ts;
|
||||
instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!type.declaration.questionToken), type.mapper || identityMapper) :
|
||||
unknownType);
|
||||
}
|
||||
function getIsomorphicTypeFromMappedType(type) {
|
||||
function getHomomorphicTypeFromMappedType(type) {
|
||||
var constraint = getConstraintDeclaration(getTypeParameterFromMappedType(type));
|
||||
return constraint.kind === 168 /* TypeOperator */ ? instantiateType(getTypeFromTypeNode(constraint.type), type.mapper || identityMapper) : undefined;
|
||||
}
|
||||
@@ -28298,7 +28299,7 @@ var ts;
|
||||
function isGenericMappedType(type) {
|
||||
if (getObjectFlags(type) & 32 /* Mapped */) {
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
return !!(constraintType.flags & (16384 /* TypeParameter */ | 262144 /* Index */));
|
||||
return maybeTypeOfKind(constraintType, 540672 /* TypeVariable */ | 262144 /* Index */);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -29515,7 +29516,7 @@ var ts;
|
||||
}
|
||||
return links.resolvedType;
|
||||
}
|
||||
function getIndexTypeForTypeParameter(type) {
|
||||
function getIndexTypeForGenericType(type) {
|
||||
if (!type.resolvedIndexType) {
|
||||
type.resolvedIndexType = createType(262144 /* Index */);
|
||||
type.resolvedIndexType.type = type;
|
||||
@@ -29531,7 +29532,7 @@ var ts;
|
||||
return getUnionType(ts.map(getPropertiesOfType(type), getLiteralTypeFromPropertyName));
|
||||
}
|
||||
function getIndexType(type) {
|
||||
return type.flags & 16384 /* TypeParameter */ ? getIndexTypeForTypeParameter(type) :
|
||||
return maybeTypeOfKind(type, 540672 /* TypeVariable */) ? getIndexTypeForGenericType(type) :
|
||||
getObjectFlags(type) & 32 /* Mapped */ ? getConstraintTypeFromMappedType(type) :
|
||||
type.flags & 1 /* Any */ || getIndexInfoOfType(type, 0 /* String */) ? stringType :
|
||||
getLiteralTypeFromPropertyNames(type);
|
||||
@@ -29626,13 +29627,14 @@ var ts;
|
||||
return instantiateType(getTemplateTypeFromMappedType(type), templateMapper);
|
||||
}
|
||||
function getIndexedAccessType(objectType, indexType, accessNode) {
|
||||
if (indexType.flags & 16384 /* TypeParameter */ ||
|
||||
objectType.flags & 16384 /* TypeParameter */ && indexType.flags & 262144 /* Index */ ||
|
||||
isGenericMappedType(objectType)) {
|
||||
// If either the object type or the index type are type parameters, or if the object type is a mapped
|
||||
// type with a generic constraint, we are performing a higher-order index access where we cannot
|
||||
// meaningfully access the properties of the object type. In those cases, we first check that the
|
||||
// index type is assignable to 'keyof T' for the object type.
|
||||
if (maybeTypeOfKind(indexType, 540672 /* TypeVariable */ | 262144 /* Index */) || isGenericMappedType(objectType)) {
|
||||
if (objectType.flags & 1 /* Any */) {
|
||||
return objectType;
|
||||
}
|
||||
// If the index type is generic or if the object type is a mapped type with a generic constraint,
|
||||
// we are performing a higher-order index access where we cannot meaningfully access the properties
|
||||
// of the object type. In those cases, we first check that the index type is assignable to 'keyof T'
|
||||
// for the object type.
|
||||
if (accessNode) {
|
||||
if (!isTypeAssignableTo(indexType, getIndexType(objectType))) {
|
||||
error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
|
||||
@@ -30086,19 +30088,19 @@ var ts;
|
||||
return result;
|
||||
}
|
||||
function instantiateMappedType(type, mapper) {
|
||||
// Check if we have an isomorphic mapped type, i.e. a type of the form { [P in keyof T]: X } for some
|
||||
// type parameter T. If so, the mapped type is distributive over a union type and when T is instantiated
|
||||
// Check if we have a homomorphic mapped type, i.e. a type of the form { [P in keyof T]: X } for some
|
||||
// type variable T. If so, the mapped type is distributive over a union type and when T is instantiated
|
||||
// to a union type A | B, we produce { [P in keyof A]: X } | { [P in keyof B]: X }. Furthermore, for
|
||||
// isomorphic mapped types we leave primitive types alone. For example, when T is instantiated to a
|
||||
// homomorphic mapped types we leave primitive types alone. For example, when T is instantiated to a
|
||||
// union type A | undefined, we produce { [P in keyof A]: X } | undefined.
|
||||
var constraintType = getConstraintTypeFromMappedType(type);
|
||||
if (constraintType.flags & 262144 /* Index */) {
|
||||
var typeParameter_1 = constraintType.type;
|
||||
var mappedTypeParameter = mapper(typeParameter_1);
|
||||
if (typeParameter_1 !== mappedTypeParameter) {
|
||||
return mapType(mappedTypeParameter, function (t) {
|
||||
var typeVariable_1 = constraintType.type;
|
||||
var mappedTypeVariable = instantiateType(typeVariable_1, mapper);
|
||||
if (typeVariable_1 !== mappedTypeVariable) {
|
||||
return mapType(mappedTypeVariable, function (t) {
|
||||
if (isMappableType(t)) {
|
||||
var replacementMapper = createUnaryTypeMapper(typeParameter_1, t);
|
||||
var replacementMapper = createUnaryTypeMapper(typeVariable_1, t);
|
||||
var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper);
|
||||
combinedMapper.mappedTypes = mapper.mappedTypes;
|
||||
return instantiateMappedObjectType(type, combinedMapper);
|
||||
@@ -30758,10 +30760,12 @@ var ts;
|
||||
}
|
||||
// Given a type parameter T with a constraint C, a type S is assignable to
|
||||
// keyof T if S is assignable to keyof C.
|
||||
var constraint = getConstraintOfTypeParameter(target.type);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
|
||||
return result;
|
||||
if (target.type.flags & 16384 /* TypeParameter */) {
|
||||
var constraint = getConstraintOfTypeParameter(target.type);
|
||||
if (constraint) {
|
||||
if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31867,66 +31871,65 @@ var ts;
|
||||
// Return true if the given type could possibly reference a type parameter for which
|
||||
// we perform type inference (i.e. a type parameter of a generic function). We cache
|
||||
// results for union and intersection types for performance reasons.
|
||||
function couldContainTypeParameters(type) {
|
||||
function couldContainTypeVariables(type) {
|
||||
var objectFlags = getObjectFlags(type);
|
||||
return !!(type.flags & (16384 /* TypeParameter */ | 524288 /* IndexedAccess */) ||
|
||||
objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeParameters) ||
|
||||
return !!(type.flags & 540672 /* TypeVariable */ ||
|
||||
objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) ||
|
||||
objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) ||
|
||||
objectFlags & 32 /* Mapped */ ||
|
||||
type.flags & 196608 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeParameters(type));
|
||||
type.flags & 196608 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type));
|
||||
}
|
||||
function couldUnionOrIntersectionContainTypeParameters(type) {
|
||||
if (type.couldContainTypeParameters === undefined) {
|
||||
type.couldContainTypeParameters = ts.forEach(type.types, couldContainTypeParameters);
|
||||
function couldUnionOrIntersectionContainTypeVariables(type) {
|
||||
if (type.couldContainTypeVariables === undefined) {
|
||||
type.couldContainTypeVariables = ts.forEach(type.types, couldContainTypeVariables);
|
||||
}
|
||||
return type.couldContainTypeParameters;
|
||||
return type.couldContainTypeVariables;
|
||||
}
|
||||
function isTypeParameterAtTopLevel(type, typeParameter) {
|
||||
return type === typeParameter || type.flags & 196608 /* UnionOrIntersection */ && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); });
|
||||
}
|
||||
// Infer a suitable input type for an isomorphic mapped type { [P in keyof T]: X }. We construct
|
||||
// Infer a suitable input type for a homomorphic mapped type { [P in keyof T]: X }. We construct
|
||||
// an object type with the same set of properties as the source type, where the type of each
|
||||
// property is computed by inferring from the source property type to X for a synthetic type
|
||||
// parameter T[P] (i.e. we treat the type T[P] as the type parameter we're inferring for).
|
||||
function inferTypeForIsomorphicMappedType(source, target) {
|
||||
if (!isMappableType(source)) {
|
||||
return source;
|
||||
// property is computed by inferring from the source property type to X for the type
|
||||
// variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for).
|
||||
function inferTypeForHomomorphicMappedType(source, target) {
|
||||
var properties = getPropertiesOfType(source);
|
||||
var indexInfo = getIndexInfoOfType(source, 0 /* String */);
|
||||
if (properties.length === 0 && !indexInfo) {
|
||||
return undefined;
|
||||
}
|
||||
var typeParameter = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target));
|
||||
var typeParameterArray = [typeParameter];
|
||||
var typeVariable = getIndexedAccessType(getConstraintTypeFromMappedType(target).type, getTypeParameterFromMappedType(target));
|
||||
var typeVariableArray = [typeVariable];
|
||||
var typeInferences = createTypeInferencesObject();
|
||||
var typeInferencesArray = [typeInferences];
|
||||
var templateType = getTemplateTypeFromMappedType(target);
|
||||
var readonlyMask = target.declaration.readonlyToken ? false : true;
|
||||
var optionalMask = target.declaration.questionToken ? 0 : 536870912 /* Optional */;
|
||||
var properties = getPropertiesOfType(source);
|
||||
var members = createSymbolTable(properties);
|
||||
var hasInferredTypes = false;
|
||||
for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) {
|
||||
var prop = properties_4[_i];
|
||||
var inferredPropType = inferTargetType(getTypeOfSymbol(prop));
|
||||
if (inferredPropType) {
|
||||
var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & optionalMask, prop.name);
|
||||
inferredProp.declarations = prop.declarations;
|
||||
inferredProp.type = inferredPropType;
|
||||
inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop);
|
||||
members[prop.name] = inferredProp;
|
||||
hasInferredTypes = true;
|
||||
if (!inferredPropType) {
|
||||
return undefined;
|
||||
}
|
||||
var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & optionalMask, prop.name);
|
||||
inferredProp.declarations = prop.declarations;
|
||||
inferredProp.type = inferredPropType;
|
||||
inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop);
|
||||
members[prop.name] = inferredProp;
|
||||
}
|
||||
var indexInfo = getIndexInfoOfType(source, 0 /* String */);
|
||||
if (indexInfo) {
|
||||
var inferredIndexType = inferTargetType(indexInfo.type);
|
||||
if (inferredIndexType) {
|
||||
indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly);
|
||||
hasInferredTypes = true;
|
||||
if (!inferredIndexType) {
|
||||
return undefined;
|
||||
}
|
||||
indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly);
|
||||
}
|
||||
return hasInferredTypes ? createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfo, undefined) : source;
|
||||
return createAnonymousType(undefined, members, emptyArray, emptyArray, indexInfo, undefined);
|
||||
function inferTargetType(sourceType) {
|
||||
typeInferences.primary = undefined;
|
||||
typeInferences.secondary = undefined;
|
||||
inferTypes(typeParameterArray, typeInferencesArray, sourceType, templateType);
|
||||
inferTypes(typeVariableArray, typeInferencesArray, sourceType, templateType);
|
||||
var inferences = typeInferences.primary || typeInferences.secondary;
|
||||
return inferences && getUnionType(inferences, /*subtypeReduction*/ true);
|
||||
}
|
||||
@@ -31934,7 +31937,7 @@ var ts;
|
||||
function inferTypesWithContext(context, originalSource, originalTarget) {
|
||||
inferTypes(context.signature.typeParameters, context.inferences, originalSource, originalTarget);
|
||||
}
|
||||
function inferTypes(typeParameters, typeInferences, originalSource, originalTarget) {
|
||||
function inferTypes(typeVariables, typeInferences, originalSource, originalTarget) {
|
||||
var sourceStack;
|
||||
var targetStack;
|
||||
var depth = 0;
|
||||
@@ -31950,7 +31953,7 @@ var ts;
|
||||
return false;
|
||||
}
|
||||
function inferFromTypes(source, target) {
|
||||
if (!couldContainTypeParameters(target)) {
|
||||
if (!couldContainTypeVariables(target)) {
|
||||
return;
|
||||
}
|
||||
if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
|
||||
@@ -32002,7 +32005,7 @@ var ts;
|
||||
target = removeTypesFromUnionOrIntersection(target, matchingTypes);
|
||||
}
|
||||
}
|
||||
if (target.flags & (16384 /* TypeParameter */ | 524288 /* IndexedAccess */)) {
|
||||
if (target.flags & 540672 /* TypeVariable */) {
|
||||
// If target is a type parameter, make an inference, unless the source type contains
|
||||
// the anyFunctionType (the wildcard type that's used to avoid contextually typing functions).
|
||||
// Because the anyFunctionType is internal, it should not be exposed to the user by adding
|
||||
@@ -32012,8 +32015,8 @@ var ts;
|
||||
if (source.flags & 8388608 /* ContainsAnyFunctionType */) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < typeParameters.length; i++) {
|
||||
if (target === typeParameters[i]) {
|
||||
for (var i = 0; i < typeVariables.length; i++) {
|
||||
if (target === typeVariables[i]) {
|
||||
var inferences = typeInferences[i];
|
||||
if (!inferences.isFixed) {
|
||||
// Any inferences that are made to a type parameter in a union type are inferior
|
||||
@@ -32047,25 +32050,25 @@ var ts;
|
||||
}
|
||||
else if (target.flags & 196608 /* UnionOrIntersection */) {
|
||||
var targetTypes = target.types;
|
||||
var typeParameterCount = 0;
|
||||
var typeParameter = void 0;
|
||||
// First infer to each type in union or intersection that isn't a type parameter
|
||||
var typeVariableCount = 0;
|
||||
var typeVariable = void 0;
|
||||
// First infer to each type in union or intersection that isn't a type variable
|
||||
for (var _d = 0, targetTypes_2 = targetTypes; _d < targetTypes_2.length; _d++) {
|
||||
var t = targetTypes_2[_d];
|
||||
if (t.flags & 16384 /* TypeParameter */ && ts.contains(typeParameters, t)) {
|
||||
typeParameter = t;
|
||||
typeParameterCount++;
|
||||
if (t.flags & 540672 /* TypeVariable */ && ts.contains(typeVariables, t)) {
|
||||
typeVariable = t;
|
||||
typeVariableCount++;
|
||||
}
|
||||
else {
|
||||
inferFromTypes(source, t);
|
||||
}
|
||||
}
|
||||
// Next, if target containings a single naked type parameter, make a secondary inference to that type
|
||||
// parameter. This gives meaningful results for union types in co-variant positions and intersection
|
||||
// Next, if target containings a single naked type variable, make a secondary inference to that type
|
||||
// variable. This gives meaningful results for union types in co-variant positions and intersection
|
||||
// types in contra-variant positions (such as callback parameters).
|
||||
if (typeParameterCount === 1) {
|
||||
if (typeVariableCount === 1) {
|
||||
inferiority++;
|
||||
inferFromTypes(source, typeParameter);
|
||||
inferFromTypes(source, typeVariable);
|
||||
inferiority--;
|
||||
}
|
||||
}
|
||||
@@ -32107,12 +32110,18 @@ var ts;
|
||||
if (getObjectFlags(target) & 32 /* Mapped */) {
|
||||
var constraintType = getConstraintTypeFromMappedType(target);
|
||||
if (constraintType.flags & 262144 /* Index */) {
|
||||
// We're inferring from some source type S to an isomorphic mapped type { [P in keyof T]: X },
|
||||
// where T is a type parameter. Use inferTypeForIsomorphicMappedType to infer a suitable source
|
||||
// type and then infer from that type to T.
|
||||
var index = ts.indexOf(typeParameters, constraintType.type);
|
||||
// We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X },
|
||||
// where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source
|
||||
// type and then make a secondary inference from that type to T. We make a secondary inference
|
||||
// such that direct inferences to T get priority over inferences to Partial<T>, for example.
|
||||
var index = ts.indexOf(typeVariables, constraintType.type);
|
||||
if (index >= 0 && !typeInferences[index].isFixed) {
|
||||
inferFromTypes(inferTypeForIsomorphicMappedType(source, target), typeParameters[index]);
|
||||
var inferredType = inferTypeForHomomorphicMappedType(source, target);
|
||||
if (inferredType) {
|
||||
inferiority++;
|
||||
inferFromTypes(inferredType, typeVariables[index]);
|
||||
inferiority--;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -37257,7 +37266,7 @@ var ts;
|
||||
if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 /* NumberLike */ | 512 /* ESSymbol */))) {
|
||||
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
|
||||
}
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 16384 /* TypeParameter */ | 524288 /* IndexedAccess */)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */)) {
|
||||
error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
return booleanType;
|
||||
@@ -39890,7 +39899,7 @@ var ts;
|
||||
}
|
||||
// unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved
|
||||
// in this case error about missing name is already reported - do not report extra one
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 16384 /* TypeParameter */ | 524288 /* IndexedAccess */)) {
|
||||
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */)) {
|
||||
error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
|
||||
}
|
||||
checkSourceElement(node.statement);
|
||||
@@ -45506,7 +45515,8 @@ var ts;
|
||||
case 228 /* TypeAliasDeclaration */:
|
||||
// TypeScript type-only declarations are elided.
|
||||
case 147 /* PropertyDeclaration */:
|
||||
// TypeScript property declarations are elided.
|
||||
// TypeScript property declarations are elided.
|
||||
return undefined;
|
||||
case 150 /* Constructor */:
|
||||
return visitConstructor(node);
|
||||
case 227 /* InterfaceDeclaration */:
|
||||
@@ -63693,7 +63703,7 @@ var ts;
|
||||
"es2017": 4 /* ES2017 */,
|
||||
"esnext": 5 /* ESNext */,
|
||||
}),
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT,
|
||||
paramType: ts.Diagnostics.VERSION,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -3034,7 +3034,7 @@ var ts;
|
||||
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." },
|
||||
Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." },
|
||||
Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'" },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" },
|
||||
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
|
||||
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." },
|
||||
Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." },
|
||||
@@ -5043,7 +5043,7 @@ var ts;
|
||||
"es2017": 4,
|
||||
"esnext": 5,
|
||||
}),
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,
|
||||
description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT,
|
||||
paramType: ts.Diagnostics.VERSION,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user