mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #3823 from Microsoft/strictObjectLiterals
Strict object literal assignment checking
This commit is contained in:
+195
-87
@@ -1993,15 +1993,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
return _displayBuilder || (_displayBuilder = {
|
||||
symbolToString: symbolToString,
|
||||
typeToString: typeToString,
|
||||
buildSymbolDisplay: buildSymbolDisplay,
|
||||
buildTypeDisplay: buildTypeDisplay,
|
||||
buildTypeParameterDisplay: buildTypeParameterDisplay,
|
||||
buildParameterDisplay: buildParameterDisplay,
|
||||
buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters,
|
||||
buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters,
|
||||
buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters,
|
||||
buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol,
|
||||
buildSignatureDisplay: buildSignatureDisplay,
|
||||
buildReturnTypeDisplay: buildReturnTypeDisplay
|
||||
@@ -3115,44 +3112,57 @@ namespace ts {
|
||||
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
|
||||
}
|
||||
|
||||
function signatureListsIdentical(s: Signature[], t: Signature[]): boolean {
|
||||
if (s.length !== t.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
if (!compareSignatures(s[i], t[i], /*compareReturnTypes*/ false, compareTypes)) {
|
||||
return false;
|
||||
function findMatchingSignature(signature: Signature, signatureList: Signature[]): Signature {
|
||||
for (let s of signatureList) {
|
||||
// Only signatures with no type parameters may differ in return types
|
||||
if (compareSignatures(signature, s, /*compareReturnTypes*/ !!signature.typeParameters, compareTypes)) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the lists of call or construct signatures in the given types are all identical except for return types,
|
||||
// and if none of the signatures are generic, return a list of signatures that has substitutes a union of the
|
||||
// return types of the corresponding signatures in each resulting signature.
|
||||
function getUnionSignatures(types: Type[], kind: SignatureKind): Signature[] {
|
||||
let signatureLists = map(types, t => getSignaturesOfType(t, kind));
|
||||
let signatures = signatureLists[0];
|
||||
for (let signature of signatures) {
|
||||
if (signature.typeParameters) {
|
||||
return emptyArray;
|
||||
}
|
||||
}
|
||||
function findMatchingSignatures(signature: Signature, signatureLists: Signature[][]): Signature[] {
|
||||
let result: Signature[] = undefined;
|
||||
for (let i = 1; i < signatureLists.length; i++) {
|
||||
if (!signatureListsIdentical(signatures, signatureLists[i])) {
|
||||
return emptyArray;
|
||||
let match = findMatchingSignature(signature, signatureLists[i]);
|
||||
if (!match) {
|
||||
return undefined;
|
||||
}
|
||||
if (!result) {
|
||||
result = [signature];
|
||||
}
|
||||
if (match !== signature) {
|
||||
result.push(match);
|
||||
}
|
||||
}
|
||||
let result = map(signatures, cloneSignature);
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
let s = result[i];
|
||||
// Clear resolved return type we possibly got from cloneSignature
|
||||
s.resolvedReturnType = undefined;
|
||||
s.unionSignatures = map(signatureLists, signatures => signatures[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// The signatures of a union type are those signatures that are present and identical in each of the
|
||||
// constituent types, except that non-generic signatures may differ in return types. When signatures
|
||||
// differ in return types, the resulting return type is the union of the constituent return types.
|
||||
function getUnionSignatures(types: Type[], kind: SignatureKind): Signature[] {
|
||||
let signatureLists = map(types, t => getSignaturesOfType(t, kind));
|
||||
let result: Signature[] = undefined;
|
||||
for (let source of signatureLists[0]) {
|
||||
let unionSignatures = findMatchingSignatures(source, signatureLists);
|
||||
if (unionSignatures) {
|
||||
let signature: Signature = undefined;
|
||||
if (unionSignatures.length === 1 || source.typeParameters) {
|
||||
signature = source;
|
||||
}
|
||||
else {
|
||||
signature = cloneSignature(source);
|
||||
// Clear resolved return type we possibly got from cloneSignature
|
||||
signature.resolvedReturnType = undefined;
|
||||
signature.unionSignatures = unionSignatures;
|
||||
}
|
||||
(result || (result = [])).push(signature);
|
||||
}
|
||||
}
|
||||
return result || emptyArray;
|
||||
}
|
||||
|
||||
function getUnionIndexType(types: Type[], kind: IndexKind): Type {
|
||||
let indexTypes: Type[] = [];
|
||||
for (let type of types) {
|
||||
@@ -3310,9 +3320,6 @@ namespace ts {
|
||||
* type itself. Note that the apparent type of a union type is the union type itself.
|
||||
*/
|
||||
function getApparentType(type: Type): Type {
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
type = getReducedTypeOfUnionType(<UnionType>type);
|
||||
}
|
||||
if (type.flags & TypeFlags.TypeParameter) {
|
||||
do {
|
||||
type = getConstraintOfTypeParameter(<TypeParameter>type);
|
||||
@@ -3417,6 +3424,29 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Check if a property with the given name is known anywhere in the given type. In an object
|
||||
// type, a property is considered known if the object type is empty, if it has any index
|
||||
// signatures, or if the property is actually declared in the type. In a union or intersection
|
||||
// type, a property is considered known if it is known in any constituent type.
|
||||
function isKnownProperty(type: Type, name: string): boolean {
|
||||
if (type.flags & TypeFlags.ObjectType && type !== globalObjectType) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
return !!(resolved.properties.length === 0 ||
|
||||
resolved.stringIndexType ||
|
||||
resolved.numberIndexType ||
|
||||
getPropertyOfType(type, name));
|
||||
}
|
||||
if (type.flags & TypeFlags.UnionOrIntersection) {
|
||||
for (let t of (<UnionOrIntersectionType>type).types) {
|
||||
if (isKnownProperty(t, name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getSignaturesOfStructuredType(type: Type, kind: SignatureKind): Signature[] {
|
||||
if (type.flags & TypeFlags.StructuredType) {
|
||||
let resolved = resolveStructuredTypeMembers(<ObjectType>type);
|
||||
@@ -4026,26 +4056,79 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isSubtypeOfAny(candidate: Type, types: Type[]): boolean {
|
||||
function isObjectLiteralTypeDuplicateOf(source: ObjectType, target: ObjectType): boolean {
|
||||
let sourceProperties = getPropertiesOfObjectType(source);
|
||||
let targetProperties = getPropertiesOfObjectType(target);
|
||||
if (sourceProperties.length !== targetProperties.length) {
|
||||
return false;
|
||||
}
|
||||
for (let sourceProp of sourceProperties) {
|
||||
let targetProp = getPropertyOfObjectType(target, sourceProp.name);
|
||||
if (!targetProp ||
|
||||
getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected) ||
|
||||
!isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function isTupleTypeDuplicateOf(source: TupleType, target: TupleType): boolean {
|
||||
let sourceTypes = source.elementTypes;
|
||||
let targetTypes = target.elementTypes;
|
||||
if (sourceTypes.length !== targetTypes.length) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < sourceTypes.length; i++) {
|
||||
if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true if the source type is a duplicate of the target type. A source type is a duplicate of
|
||||
// a target type if the the two are identical, with the exception that the source type may have null or
|
||||
// undefined in places where the target type doesn't. This is by design an asymmetric relationship.
|
||||
function isTypeDuplicateOf(source: Type, target: Type): boolean {
|
||||
if (source === target) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & TypeFlags.Undefined || source.flags & TypeFlags.Null && !(target.flags & TypeFlags.Undefined)) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & TypeFlags.ObjectLiteral && target.flags & TypeFlags.ObjectType) {
|
||||
return isObjectLiteralTypeDuplicateOf(<ObjectType>source, <ObjectType>target);
|
||||
}
|
||||
if (isArrayType(source) && isArrayType(target)) {
|
||||
return isTypeDuplicateOf((<TypeReference>source).typeArguments[0], (<TypeReference>target).typeArguments[0]);
|
||||
}
|
||||
if (isTupleType(source) && isTupleType(target)) {
|
||||
return isTupleTypeDuplicateOf(<TupleType>source, <TupleType>target);
|
||||
}
|
||||
return isTypeIdenticalTo(source, target);
|
||||
}
|
||||
|
||||
function isTypeDuplicateOfSomeType(candidate: Type, types: Type[]): boolean {
|
||||
for (let type of types) {
|
||||
if (candidate !== type && isTypeSubtypeOf(candidate, type)) {
|
||||
if (candidate !== type && isTypeDuplicateOf(candidate, type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function removeSubtypes(types: Type[]) {
|
||||
function removeDuplicateTypes(types: Type[]) {
|
||||
let i = types.length;
|
||||
while (i > 0) {
|
||||
i--;
|
||||
if (isSubtypeOfAny(types[i], types)) {
|
||||
if (isTypeDuplicateOfSomeType(types[i], types)) {
|
||||
types.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function containsTypeAny(types: Type[]) {
|
||||
function containsTypeAny(types: Type[]): boolean {
|
||||
for (let type of types) {
|
||||
if (isTypeAny(type)) {
|
||||
return true;
|
||||
@@ -4064,30 +4147,26 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function compareTypeIds(type1: Type, type2: Type): number {
|
||||
return type1.id - type2.id;
|
||||
}
|
||||
|
||||
// The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag
|
||||
// is true when creating a union type from a type node and when instantiating a union type. In both of those
|
||||
// cases subtype reduction has to be deferred to properly support recursive union types. For example, a
|
||||
// type alias of the form "type Item = string | (() => Item)" cannot be reduced during its declaration.
|
||||
function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type {
|
||||
// We always deduplicate the constituent type set based on object identity, but we'll also deduplicate
|
||||
// based on the structure of the types unless the noDeduplication flag is true, which is the case when
|
||||
// creating a union type from a type node and when instantiating a union type. In both of those cases,
|
||||
// structural deduplication has to be deferred to properly support recursive union types. For example,
|
||||
// a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration.
|
||||
function getUnionType(types: Type[], noDeduplication?: boolean): Type {
|
||||
if (types.length === 0) {
|
||||
return emptyObjectType;
|
||||
}
|
||||
let typeSet: Type[] = [];
|
||||
addTypesToSet(typeSet, types, TypeFlags.Union);
|
||||
typeSet.sort(compareTypeIds);
|
||||
if (noSubtypeReduction) {
|
||||
if (containsTypeAny(typeSet)) {
|
||||
return anyType;
|
||||
}
|
||||
if (containsTypeAny(typeSet)) {
|
||||
return anyType;
|
||||
}
|
||||
if (noDeduplication) {
|
||||
removeAllButLast(typeSet, undefinedType);
|
||||
removeAllButLast(typeSet, nullType);
|
||||
}
|
||||
else {
|
||||
removeSubtypes(typeSet);
|
||||
removeDuplicateTypes(typeSet);
|
||||
}
|
||||
if (typeSet.length === 1) {
|
||||
return typeSet[0];
|
||||
@@ -4097,38 +4176,19 @@ namespace ts {
|
||||
if (!type) {
|
||||
type = unionTypes[id] = <UnionType>createObjectType(TypeFlags.Union | getWideningFlagsOfTypes(typeSet));
|
||||
type.types = typeSet;
|
||||
type.reducedType = noSubtypeReduction ? undefined : type;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
// Subtype reduction is basically an optimization we do to avoid excessively large union types, which take longer
|
||||
// to process and look strange in quick info and error messages. Semantically there is no difference between the
|
||||
// reduced type and the type itself. So, when we detect a circularity we simply say that the reduced type is the
|
||||
// type itself.
|
||||
function getReducedTypeOfUnionType(type: UnionType): Type {
|
||||
if (!type.reducedType) {
|
||||
type.reducedType = circularType;
|
||||
let reducedType = getUnionType(type.types, /*noSubtypeReduction*/ false);
|
||||
if (type.reducedType === circularType) {
|
||||
type.reducedType = reducedType;
|
||||
}
|
||||
}
|
||||
else if (type.reducedType === circularType) {
|
||||
type.reducedType = type;
|
||||
}
|
||||
return type.reducedType;
|
||||
}
|
||||
|
||||
function getTypeFromUnionTypeNode(node: UnionTypeNode): Type {
|
||||
let links = getNodeLinks(node);
|
||||
if (!links.resolvedType) {
|
||||
links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true);
|
||||
links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true);
|
||||
}
|
||||
return links.resolvedType;
|
||||
}
|
||||
|
||||
// We do not perform supertype reduction on intersection types. Intersection types are created only by the &
|
||||
// We do not perform structural deduplication on intersection types. Intersection types are created only by the &
|
||||
// type operator and we can't reduce those because we want to support recursive intersection types. For example,
|
||||
// a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
|
||||
// Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
|
||||
@@ -4409,7 +4469,7 @@ namespace ts {
|
||||
return createTupleType(instantiateList((<TupleType>type).elementTypes, mapper, instantiateType));
|
||||
}
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
return getUnionType(instantiateList((<UnionType>type).types, mapper, instantiateType), /*noSubtypeReduction*/ true);
|
||||
return getUnionType(instantiateList((<UnionType>type).types, mapper, instantiateType), /*noDeduplication*/ true);
|
||||
}
|
||||
if (type.flags & TypeFlags.Intersection) {
|
||||
return getIntersectionType(instantiateList((<IntersectionType>type).types, mapper, instantiateType));
|
||||
@@ -4554,6 +4614,16 @@ namespace ts {
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
function reportRelationError(message: DiagnosticMessage, source: Type, target: Type) {
|
||||
let sourceType = typeToString(source);
|
||||
let targetType = typeToString(target);
|
||||
if (sourceType === targetType) {
|
||||
sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType);
|
||||
targetType = typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType);
|
||||
}
|
||||
reportError(message || Diagnostics.Type_0_is_not_assignable_to_type_1, sourceType, targetType);
|
||||
}
|
||||
|
||||
// Compare two types and return
|
||||
// Ternary.True if they are related with no assumptions,
|
||||
// Ternary.Maybe if they are related with assumptions of other relationships, or
|
||||
@@ -4573,7 +4643,23 @@ namespace ts {
|
||||
if (source === numberType && target.flags & TypeFlags.Enum) return Ternary.True;
|
||||
}
|
||||
}
|
||||
|
||||
if (relation !== identityRelation && source.flags & TypeFlags.FreshObjectLiteral) {
|
||||
if (hasExcessProperties(<FreshObjectLiteralType>source, target, reportErrors)) {
|
||||
if (reportErrors) {
|
||||
reportRelationError(headMessage, source, target);
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
// Above we check for excess properties with respect to the entire target type. When union
|
||||
// and intersection types are further deconstructed on the target side, we don't want to
|
||||
// make the check again (as it might fail for a partial target type). Therefore we obtain
|
||||
// the regular source type and proceed with that.
|
||||
source = getRegularTypeOfObjectLiteral(source);
|
||||
}
|
||||
|
||||
let saveErrorInfo = errorInfo;
|
||||
|
||||
if (source.flags & TypeFlags.Reference && target.flags & TypeFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
|
||||
// We have type references to same target type, see if relationship holds for all type arguments
|
||||
if (result = typesRelatedTo((<TypeReference>source).typeArguments, (<TypeReference>target).typeArguments, reportErrors)) {
|
||||
@@ -4650,18 +4736,22 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (reportErrors) {
|
||||
headMessage = headMessage || Diagnostics.Type_0_is_not_assignable_to_type_1;
|
||||
let sourceType = typeToString(source);
|
||||
let targetType = typeToString(target);
|
||||
if (sourceType === targetType) {
|
||||
sourceType = typeToString(source, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType);
|
||||
targetType = typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType);
|
||||
}
|
||||
reportError(headMessage, sourceType, targetType);
|
||||
reportRelationError(headMessage, source, target);
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
|
||||
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
|
||||
for (let prop of getPropertiesOfObjectType(source)) {
|
||||
if (!isKnownProperty(target, prop.name)) {
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function eachTypeRelatedToSomeType(source: UnionOrIntersectionType, target: UnionOrIntersectionType): Ternary {
|
||||
let result = Ternary.True;
|
||||
let sourceTypes = source.types;
|
||||
@@ -5358,6 +5448,24 @@ namespace ts {
|
||||
return !!(type.flags & TypeFlags.Tuple);
|
||||
}
|
||||
|
||||
function getRegularTypeOfObjectLiteral(type: Type): Type {
|
||||
if (type.flags & TypeFlags.FreshObjectLiteral) {
|
||||
let regularType = (<FreshObjectLiteralType>type).regularType;
|
||||
if (!regularType) {
|
||||
regularType = <ResolvedType>createType((<ResolvedType>type).flags & ~TypeFlags.FreshObjectLiteral);
|
||||
regularType.symbol = (<ResolvedType>type).symbol;
|
||||
regularType.members = (<ResolvedType>type).members;
|
||||
regularType.properties = (<ResolvedType>type).properties;
|
||||
regularType.callSignatures = (<ResolvedType>type).callSignatures;
|
||||
regularType.constructSignatures = (<ResolvedType>type).constructSignatures;
|
||||
regularType.stringIndexType = (<ResolvedType>type).stringIndexType;
|
||||
regularType.numberIndexType = (<ResolvedType>type).numberIndexType;
|
||||
}
|
||||
return regularType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function getWidenedTypeOfObjectLiteral(type: Type): Type {
|
||||
let properties = getPropertiesOfObjectType(type);
|
||||
let members: SymbolTable = {};
|
||||
@@ -6984,7 +7092,7 @@ namespace ts {
|
||||
let stringIndexType = getIndexType(IndexKind.String);
|
||||
let numberIndexType = getIndexType(IndexKind.Number);
|
||||
let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
|
||||
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.ContainsUndefinedOrNull);
|
||||
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.ContainsUndefinedOrNull);
|
||||
return result;
|
||||
|
||||
function getIndexType(kind: IndexKind) {
|
||||
@@ -8867,7 +8975,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkAssertion(node: AssertionExpression) {
|
||||
let exprType = checkExpression(node.expression);
|
||||
let exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression));
|
||||
let targetType = getTypeFromTypeNode(node.type);
|
||||
if (produceDiagnostics && targetType !== unknownType) {
|
||||
let widenedType = getWidenedType(exprType);
|
||||
@@ -9692,7 +9800,7 @@ namespace ts {
|
||||
return getUnionType([leftType, rightType]);
|
||||
case SyntaxKind.EqualsToken:
|
||||
checkAssignmentOperator(rightType);
|
||||
return rightType;
|
||||
return getRegularTypeOfObjectLiteral(rightType);
|
||||
case SyntaxKind.CommaToken:
|
||||
return rightType;
|
||||
}
|
||||
|
||||
@@ -254,6 +254,7 @@ namespace ts {
|
||||
Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: DiagnosticCategory.Error, key: "Only a void function can be called with the 'new' keyword." },
|
||||
Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: DiagnosticCategory.Error, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." },
|
||||
Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: DiagnosticCategory.Error, key: "Neither type '{0}' nor type '{1}' is assignable to the other." },
|
||||
Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: DiagnosticCategory.Error, key: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." },
|
||||
No_best_common_type_exists_among_return_expressions: { code: 2354, category: DiagnosticCategory.Error, key: "No best common type exists among return expressions." },
|
||||
A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: DiagnosticCategory.Error, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." },
|
||||
An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: DiagnosticCategory.Error, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." },
|
||||
|
||||
@@ -1005,6 +1005,10 @@
|
||||
"category": "Error",
|
||||
"code": 2352
|
||||
},
|
||||
"Object literal may only specify known properties, and '{0}' does not exist in type '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2353
|
||||
},
|
||||
"No best common type exists among return expressions.": {
|
||||
"category": "Error",
|
||||
"code": 2354
|
||||
|
||||
+14
-3
@@ -1762,10 +1762,12 @@ namespace ts {
|
||||
FromSignature = 0x00040000, // Created for signature assignment check
|
||||
ObjectLiteral = 0x00080000, // Originates in an object literal
|
||||
/* @internal */
|
||||
ContainsUndefinedOrNull = 0x00100000, // Type is or contains Undefined or Null type
|
||||
FreshObjectLiteral = 0x00100000, // Fresh object literal type
|
||||
/* @internal */
|
||||
ContainsObjectLiteral = 0x00200000, // Type is or contains object literal type
|
||||
ESSymbol = 0x00400000, // Type of symbol primitive introduced in ES6
|
||||
ContainsUndefinedOrNull = 0x00200000, // Type is or contains Undefined or Null type
|
||||
/* @internal */
|
||||
ContainsObjectLiteral = 0x00400000, // Type is or contains object literal type
|
||||
ESSymbol = 0x00800000, // Type of symbol primitive introduced in ES6
|
||||
|
||||
/* @internal */
|
||||
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
|
||||
@@ -1858,6 +1860,14 @@ namespace ts {
|
||||
numberIndexType?: Type; // Numeric index type
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
// Object literals are initially marked fresh. Freshness disappears following an assignment,
|
||||
// before a type assertion, or when when an object literal's type is widened. The regular
|
||||
// version of a fresh type is identical except for the TypeFlags.FreshObjectLiteral flag.
|
||||
export interface FreshObjectLiteralType extends ResolvedType {
|
||||
regularType: ResolvedType; // Regular version of fresh type
|
||||
}
|
||||
|
||||
// Just a place to cache element types of iterables and iterators
|
||||
/* @internal */
|
||||
export interface IterableOrIteratorType extends ObjectType, UnionType {
|
||||
@@ -2211,6 +2221,7 @@ namespace ts {
|
||||
|
||||
export interface CompilerHost {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
|
||||
@@ -26,9 +26,8 @@ module FourSlash {
|
||||
export interface FourSlashFile {
|
||||
// The contents of the file (with markers, etc stripped out)
|
||||
content: string;
|
||||
|
||||
fileName: string;
|
||||
|
||||
version: number;
|
||||
// File-specific options (name/value pairs)
|
||||
fileOptions: { [index: string]: string; };
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ interface FindFileResult {
|
||||
}
|
||||
|
||||
interface IOLog {
|
||||
timestamp: string;
|
||||
arguments: string[];
|
||||
executingPath: string;
|
||||
currentDirectory: string;
|
||||
|
||||
@@ -202,9 +202,7 @@ namespace ts.server {
|
||||
return {
|
||||
isMemberCompletion: false,
|
||||
isNewIdentifierLocation: false,
|
||||
entries: response.body,
|
||||
fileName: fileName,
|
||||
position: position
|
||||
entries: response.body
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1105,6 +1105,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface HighlightSpan {
|
||||
fileName?: string;
|
||||
textSpan: TextSpan;
|
||||
kind: string;
|
||||
}
|
||||
@@ -1411,7 +1412,9 @@ namespace ts {
|
||||
* @param fileName The name of the file to be released
|
||||
* @param compilationSettings The compilation settings used to acquire the file
|
||||
*/
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void
|
||||
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
|
||||
|
||||
reportStats(): string;
|
||||
}
|
||||
|
||||
// TODO: move these to enums
|
||||
|
||||
@@ -454,11 +454,11 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { message: string; start: number; length: number; category: string; } []{
|
||||
export function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { message: string; start: number; length: number; category: string; code: number; } []{
|
||||
return diagnostics.map(d => realizeDiagnostic(d, newLine));
|
||||
}
|
||||
|
||||
function realizeDiagnostic(diagnostic: Diagnostic, newLine: string): { message: string; start: number; length: number; category: string; } {
|
||||
function realizeDiagnostic(diagnostic: Diagnostic, newLine: string): { message: string; start: number; length: number; category: string; code: number; } {
|
||||
return {
|
||||
message: flattenDiagnosticMessageText(diagnostic.messageText, newLine),
|
||||
start: diagnostic.start,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'string | number' is not an array type.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'number | string' is not an array type.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,7): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
@@ -8,7 +8,7 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error
|
||||
var tuple: [number, string] = [2, "3"];
|
||||
for ([a = 1, b = ""] of tuple) {
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2461: Type 'string | number' is not an array type.
|
||||
!!! error TS2461: Type 'number | string' is not an array type.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts(3,6): error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts(3,6): error TS2322: Type 'number | string' is not assignable to type 'string'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts(3,6)
|
||||
var v: string;
|
||||
for (v of union) { }
|
||||
~
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'number | string' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
@@ -3,6 +3,6 @@ var union: string | number[];
|
||||
>union : string | number[]
|
||||
|
||||
for (var v of union) { }
|
||||
>v : string | number
|
||||
>v : number | string
|
||||
>union : string | number[]
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts(2,15): error TS2461: Type 'number | symbol | string[]' is not an array type.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts(2,15): error TS2461: Type 'string[] | number | symbol' is not an array type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts (1 errors) ====
|
||||
var union: string | string[] | number | symbol;
|
||||
for (let v of union) { }
|
||||
~~~~~
|
||||
!!! error TS2461: Type 'number | symbol | string[]' is not an array type.
|
||||
!!! error TS2461: Type 'string[] | number | symbol' is not an array type.
|
||||
@@ -6,14 +6,14 @@ enum Color { R, G, B }
|
||||
>B : Color
|
||||
|
||||
function f1(x: Color | string) {
|
||||
>f1 : (x: string | Color) => void
|
||||
>x : string | Color
|
||||
>f1 : (x: Color | string) => void
|
||||
>x : Color | string
|
||||
>Color : Color
|
||||
|
||||
if (typeof x === "number") {
|
||||
>typeof x === "number" : boolean
|
||||
>typeof x : string
|
||||
>x : string | Color
|
||||
>x : Color | string
|
||||
>"number" : string
|
||||
|
||||
var y = x;
|
||||
@@ -35,14 +35,14 @@ function f1(x: Color | string) {
|
||||
}
|
||||
|
||||
function f2(x: Color | string | string[]) {
|
||||
>f2 : (x: string | Color | string[]) => void
|
||||
>x : string | Color | string[]
|
||||
>f2 : (x: Color | string | string[]) => void
|
||||
>x : Color | string | string[]
|
||||
>Color : Color
|
||||
|
||||
if (typeof x === "object") {
|
||||
>typeof x === "object" : boolean
|
||||
>typeof x : string
|
||||
>x : string | Color | string[]
|
||||
>x : Color | string | string[]
|
||||
>"object" : string
|
||||
|
||||
var y = x;
|
||||
@@ -55,7 +55,7 @@ function f2(x: Color | string | string[]) {
|
||||
if (typeof x === "number") {
|
||||
>typeof x === "number" : boolean
|
||||
>typeof x : string
|
||||
>x : string | Color | string[]
|
||||
>x : Color | string | string[]
|
||||
>"number" : string
|
||||
|
||||
var z = x;
|
||||
@@ -77,7 +77,7 @@ function f2(x: Color | string | string[]) {
|
||||
if (typeof x === "string") {
|
||||
>typeof x === "string" : boolean
|
||||
>typeof x : string
|
||||
>x : string | Color | string[]
|
||||
>x : Color | string | string[]
|
||||
>"string" : string
|
||||
|
||||
var a = x;
|
||||
|
||||
@@ -34,7 +34,7 @@ var d2: IHasVisualizationModel = i || moduleA;
|
||||
var d2: IHasVisualizationModel = moduleA || i;
|
||||
>d2 : IHasVisualizationModel
|
||||
>IHasVisualizationModel : IHasVisualizationModel
|
||||
>moduleA || i : IHasVisualizationModel
|
||||
>moduleA || i : typeof moduleA
|
||||
>moduleA : typeof moduleA
|
||||
>i : IHasVisualizationModel
|
||||
|
||||
|
||||
@@ -294,8 +294,8 @@ module EmptyTypes {
|
||||
|
||||
// Order matters here so test all the variants
|
||||
var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }];
|
||||
>a1 : { x: any; y: string; }[]
|
||||
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[]
|
||||
>a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
|
||||
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
|
||||
>{ x: 0, y: 'a' } : { x: number; y: string; }
|
||||
>x : number
|
||||
>0 : number
|
||||
@@ -313,8 +313,8 @@ module EmptyTypes {
|
||||
>'a' : string
|
||||
|
||||
var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }];
|
||||
>a2 : { x: any; y: string; }[]
|
||||
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
|
||||
>a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
|
||||
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
|
||||
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
|
||||
>x : any
|
||||
>anyObj : any
|
||||
@@ -332,8 +332,8 @@ module EmptyTypes {
|
||||
>'a' : string
|
||||
|
||||
var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }];
|
||||
>a3 : { x: any; y: string; }[]
|
||||
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
|
||||
>a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
|
||||
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
|
||||
>{ x: 0, y: 'a' } : { x: number; y: string; }
|
||||
>x : number
|
||||
>0 : number
|
||||
@@ -366,22 +366,22 @@ module EmptyTypes {
|
||||
>base2 : typeof base2
|
||||
|
||||
var b1 = [baseObj, base2Obj, ifaceObj];
|
||||
>b1 : iface[]
|
||||
>[baseObj, base2Obj, ifaceObj] : iface[]
|
||||
>b1 : base[]
|
||||
>[baseObj, base2Obj, ifaceObj] : base[]
|
||||
>baseObj : base
|
||||
>base2Obj : base2
|
||||
>ifaceObj : iface
|
||||
|
||||
var b2 = [base2Obj, baseObj, ifaceObj];
|
||||
>b2 : iface[]
|
||||
>[base2Obj, baseObj, ifaceObj] : iface[]
|
||||
>b2 : base2[]
|
||||
>[base2Obj, baseObj, ifaceObj] : base2[]
|
||||
>base2Obj : base2
|
||||
>baseObj : base
|
||||
>ifaceObj : iface
|
||||
|
||||
var b3 = [baseObj, ifaceObj, base2Obj];
|
||||
>b3 : iface[]
|
||||
>[baseObj, ifaceObj, base2Obj] : iface[]
|
||||
>b3 : base[]
|
||||
>[baseObj, ifaceObj, base2Obj] : base[]
|
||||
>baseObj : base
|
||||
>ifaceObj : iface
|
||||
>base2Obj : base2
|
||||
@@ -639,7 +639,7 @@ module NonEmptyTypes {
|
||||
>x : number
|
||||
>y : base
|
||||
>base : base
|
||||
>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: base; }[]
|
||||
>[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : ({ x: number; y: derived; } | { x: number; y: base; })[]
|
||||
>{ x: 7, y: new derived() } : { x: number; y: derived; }
|
||||
>x : number
|
||||
>7 : number
|
||||
@@ -658,7 +658,7 @@ module NonEmptyTypes {
|
||||
>x : boolean
|
||||
>y : base
|
||||
>base : base
|
||||
>[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: base; }[]
|
||||
>[{ x: true, y: new derived() }, { x: false, y: new base() }] : ({ x: boolean; y: derived; } | { x: boolean; y: base; })[]
|
||||
>{ x: true, y: new derived() } : { x: boolean; y: derived; }
|
||||
>x : boolean
|
||||
>true : boolean
|
||||
@@ -697,8 +697,8 @@ module NonEmptyTypes {
|
||||
|
||||
// Order matters here so test all the variants
|
||||
var a1 = [{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }];
|
||||
>a1 : { x: any; y: string; }[]
|
||||
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[]
|
||||
>a1 : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
|
||||
>[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : ({ x: number; y: string; } | { x: string; y: string; } | { x: any; y: string; })[]
|
||||
>{ x: 0, y: 'a' } : { x: number; y: string; }
|
||||
>x : number
|
||||
>0 : number
|
||||
@@ -716,8 +716,8 @@ module NonEmptyTypes {
|
||||
>'a' : string
|
||||
|
||||
var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }];
|
||||
>a2 : { x: any; y: string; }[]
|
||||
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
|
||||
>a2 : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
|
||||
>[{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: any; y: string; } | { x: number; y: string; } | { x: string; y: string; })[]
|
||||
>{ x: anyObj, y: 'a' } : { x: any; y: string; }
|
||||
>x : any
|
||||
>anyObj : any
|
||||
@@ -735,8 +735,8 @@ module NonEmptyTypes {
|
||||
>'a' : string
|
||||
|
||||
var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }];
|
||||
>a3 : { x: any; y: string; }[]
|
||||
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[]
|
||||
>a3 : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
|
||||
>[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : ({ x: number; y: string; } | { x: any; y: string; } | { x: string; y: string; })[]
|
||||
>{ x: 0, y: 'a' } : { x: number; y: string; }
|
||||
>x : number
|
||||
>0 : number
|
||||
@@ -769,29 +769,29 @@ module NonEmptyTypes {
|
||||
>base2 : typeof base2
|
||||
|
||||
var b1 = [baseObj, base2Obj, ifaceObj];
|
||||
>b1 : iface[]
|
||||
>[baseObj, base2Obj, ifaceObj] : iface[]
|
||||
>b1 : (base | base2 | iface)[]
|
||||
>[baseObj, base2Obj, ifaceObj] : (base | base2 | iface)[]
|
||||
>baseObj : base
|
||||
>base2Obj : base2
|
||||
>ifaceObj : iface
|
||||
|
||||
var b2 = [base2Obj, baseObj, ifaceObj];
|
||||
>b2 : iface[]
|
||||
>[base2Obj, baseObj, ifaceObj] : iface[]
|
||||
>b2 : (base2 | base | iface)[]
|
||||
>[base2Obj, baseObj, ifaceObj] : (base2 | base | iface)[]
|
||||
>base2Obj : base2
|
||||
>baseObj : base
|
||||
>ifaceObj : iface
|
||||
|
||||
var b3 = [baseObj, ifaceObj, base2Obj];
|
||||
>b3 : iface[]
|
||||
>[baseObj, ifaceObj, base2Obj] : iface[]
|
||||
>b3 : (base | iface | base2)[]
|
||||
>[baseObj, ifaceObj, base2Obj] : (base | iface | base2)[]
|
||||
>baseObj : base
|
||||
>ifaceObj : iface
|
||||
>base2Obj : base2
|
||||
|
||||
var b4 = [ifaceObj, baseObj, base2Obj];
|
||||
>b4 : iface[]
|
||||
>[ifaceObj, baseObj, base2Obj] : iface[]
|
||||
>b4 : (iface | base | base2)[]
|
||||
>[ifaceObj, baseObj, base2Obj] : (iface | base | base2)[]
|
||||
>ifaceObj : iface
|
||||
>baseObj : base
|
||||
>base2Obj : base2
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
|
||||
Type '{ foo: string; }' is not assignable to type '{ id: number; }'.
|
||||
Property 'id' is missing in type '{ foo: string; }'.
|
||||
Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/arrayCast.ts (1 errors) ====
|
||||
@@ -10,7 +10,7 @@ tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: strin
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
|
||||
!!! error TS2352: Type '{ foo: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2352: Property 'id' is missing in type '{ foo: string; }'.
|
||||
!!! error TS2352: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'.
|
||||
|
||||
// Should succeed, as the {} element causes the type of the array to be {}[]
|
||||
<{ id: number; }[]>[{ foo: "s" }, {}];
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(8,5): error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number' is not assignable to type '() => number'.
|
||||
Type 'string | number' is not assignable to type 'number'.
|
||||
Type '() => number | string' is not assignable to type '() => number'.
|
||||
Type 'number | string' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts(14,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
|
||||
Property '0' is missing in type 'number[]'.
|
||||
@@ -19,8 +19,8 @@ tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionConte
|
||||
~~~~
|
||||
!!! error TS2322: Type '[number, number, number, string]' is not assignable to type '[number, number, number]'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => string | number' is not assignable to type '() => number'.
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '() => number | string' is not assignable to type '() => number'.
|
||||
!!! error TS2322: Type 'number | string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
// In a contextually typed array literal expression containing one or more spread elements,
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
tests/cases/compiler/arrayLiteralTypeInference.ts(13,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'.
|
||||
Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'.
|
||||
Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'.
|
||||
Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'.
|
||||
tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/arrayLiteralTypeInference.ts (2 errors) ====
|
||||
class Action {
|
||||
id: number;
|
||||
}
|
||||
|
||||
class ActionA extends Action {
|
||||
value: string;
|
||||
}
|
||||
|
||||
class ActionB extends Action {
|
||||
trueNess: boolean;
|
||||
}
|
||||
|
||||
var x1: Action[] = [
|
||||
~~
|
||||
!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'.
|
||||
!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'.
|
||||
!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'.
|
||||
{ id: 2, trueness: false },
|
||||
{ id: 3, name: "three" }
|
||||
]
|
||||
|
||||
var x2: Action[] = [
|
||||
new ActionA(),
|
||||
new ActionB()
|
||||
]
|
||||
|
||||
var x3: Action[] = [
|
||||
new Action(),
|
||||
new ActionA(),
|
||||
new ActionB()
|
||||
]
|
||||
|
||||
var z1: { id: number }[] =
|
||||
~~
|
||||
!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'.
|
||||
[
|
||||
{ id: 2, trueness: false },
|
||||
{ id: 3, name: "three" }
|
||||
]
|
||||
|
||||
var z2: { id: number }[] =
|
||||
[
|
||||
new ActionA(),
|
||||
new ActionB()
|
||||
]
|
||||
|
||||
var z3: { id: number }[] =
|
||||
[
|
||||
new Action(),
|
||||
new ActionA(),
|
||||
new ActionB()
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
=== tests/cases/compiler/arrayLiteralTypeInference.ts ===
|
||||
class Action {
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
id: number;
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 0, 14))
|
||||
}
|
||||
|
||||
class ActionA extends Action {
|
||||
>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1))
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
value: string;
|
||||
>value : Symbol(value, Decl(arrayLiteralTypeInference.ts, 4, 30))
|
||||
}
|
||||
|
||||
class ActionB extends Action {
|
||||
>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1))
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
trueNess: boolean;
|
||||
>trueNess : Symbol(trueNess, Decl(arrayLiteralTypeInference.ts, 8, 30))
|
||||
}
|
||||
|
||||
var x1: Action[] = [
|
||||
>x1 : Symbol(x1, Decl(arrayLiteralTypeInference.ts, 12, 3))
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
{ id: 2, trueness: false },
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 13, 5))
|
||||
>trueness : Symbol(trueness, Decl(arrayLiteralTypeInference.ts, 13, 12))
|
||||
|
||||
{ id: 3, name: "three" }
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 14, 5))
|
||||
>name : Symbol(name, Decl(arrayLiteralTypeInference.ts, 14, 12))
|
||||
|
||||
]
|
||||
|
||||
var x2: Action[] = [
|
||||
>x2 : Symbol(x2, Decl(arrayLiteralTypeInference.ts, 17, 3))
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
new ActionA(),
|
||||
>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1))
|
||||
|
||||
new ActionB()
|
||||
>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1))
|
||||
|
||||
]
|
||||
|
||||
var x3: Action[] = [
|
||||
>x3 : Symbol(x3, Decl(arrayLiteralTypeInference.ts, 22, 3))
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
new Action(),
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
new ActionA(),
|
||||
>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1))
|
||||
|
||||
new ActionB()
|
||||
>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1))
|
||||
|
||||
]
|
||||
|
||||
var z1: { id: number }[] =
|
||||
>z1 : Symbol(z1, Decl(arrayLiteralTypeInference.ts, 28, 3))
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 28, 9))
|
||||
|
||||
[
|
||||
{ id: 2, trueness: false },
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 30, 9))
|
||||
>trueness : Symbol(trueness, Decl(arrayLiteralTypeInference.ts, 30, 16))
|
||||
|
||||
{ id: 3, name: "three" }
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 31, 9))
|
||||
>name : Symbol(name, Decl(arrayLiteralTypeInference.ts, 31, 16))
|
||||
|
||||
]
|
||||
|
||||
var z2: { id: number }[] =
|
||||
>z2 : Symbol(z2, Decl(arrayLiteralTypeInference.ts, 34, 3))
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 34, 9))
|
||||
|
||||
[
|
||||
new ActionA(),
|
||||
>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1))
|
||||
|
||||
new ActionB()
|
||||
>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1))
|
||||
|
||||
]
|
||||
|
||||
var z3: { id: number }[] =
|
||||
>z3 : Symbol(z3, Decl(arrayLiteralTypeInference.ts, 40, 3))
|
||||
>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 40, 9))
|
||||
|
||||
[
|
||||
new Action(),
|
||||
>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0))
|
||||
|
||||
new ActionA(),
|
||||
>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1))
|
||||
|
||||
new ActionB()
|
||||
>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1))
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
=== tests/cases/compiler/arrayLiteralTypeInference.ts ===
|
||||
class Action {
|
||||
>Action : Action
|
||||
|
||||
id: number;
|
||||
>id : number
|
||||
}
|
||||
|
||||
class ActionA extends Action {
|
||||
>ActionA : ActionA
|
||||
>Action : Action
|
||||
|
||||
value: string;
|
||||
>value : string
|
||||
}
|
||||
|
||||
class ActionB extends Action {
|
||||
>ActionB : ActionB
|
||||
>Action : Action
|
||||
|
||||
trueNess: boolean;
|
||||
>trueNess : boolean
|
||||
}
|
||||
|
||||
var x1: Action[] = [
|
||||
>x1 : Action[]
|
||||
>Action : Action
|
||||
>[ { id: 2, trueness: false }, { id: 3, name: "three" }] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[]
|
||||
|
||||
{ id: 2, trueness: false },
|
||||
>{ id: 2, trueness: false } : { id: number; trueness: boolean; }
|
||||
>id : number
|
||||
>2 : number
|
||||
>trueness : boolean
|
||||
>false : boolean
|
||||
|
||||
{ id: 3, name: "three" }
|
||||
>{ id: 3, name: "three" } : { id: number; name: string; }
|
||||
>id : number
|
||||
>3 : number
|
||||
>name : string
|
||||
>"three" : string
|
||||
|
||||
]
|
||||
|
||||
var x2: Action[] = [
|
||||
>x2 : Action[]
|
||||
>Action : Action
|
||||
>[ new ActionA(), new ActionB()] : (ActionA | ActionB)[]
|
||||
|
||||
new ActionA(),
|
||||
>new ActionA() : ActionA
|
||||
>ActionA : typeof ActionA
|
||||
|
||||
new ActionB()
|
||||
>new ActionB() : ActionB
|
||||
>ActionB : typeof ActionB
|
||||
|
||||
]
|
||||
|
||||
var x3: Action[] = [
|
||||
>x3 : Action[]
|
||||
>Action : Action
|
||||
>[ new Action(), new ActionA(), new ActionB()] : Action[]
|
||||
|
||||
new Action(),
|
||||
>new Action() : Action
|
||||
>Action : typeof Action
|
||||
|
||||
new ActionA(),
|
||||
>new ActionA() : ActionA
|
||||
>ActionA : typeof ActionA
|
||||
|
||||
new ActionB()
|
||||
>new ActionB() : ActionB
|
||||
>ActionB : typeof ActionB
|
||||
|
||||
]
|
||||
|
||||
var z1: { id: number }[] =
|
||||
>z1 : { id: number; }[]
|
||||
>id : number
|
||||
|
||||
[
|
||||
>[ { id: 2, trueness: false }, { id: 3, name: "three" } ] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[]
|
||||
|
||||
{ id: 2, trueness: false },
|
||||
>{ id: 2, trueness: false } : { id: number; trueness: boolean; }
|
||||
>id : number
|
||||
>2 : number
|
||||
>trueness : boolean
|
||||
>false : boolean
|
||||
|
||||
{ id: 3, name: "three" }
|
||||
>{ id: 3, name: "three" } : { id: number; name: string; }
|
||||
>id : number
|
||||
>3 : number
|
||||
>name : string
|
||||
>"three" : string
|
||||
|
||||
]
|
||||
|
||||
var z2: { id: number }[] =
|
||||
>z2 : { id: number; }[]
|
||||
>id : number
|
||||
|
||||
[
|
||||
>[ new ActionA(), new ActionB() ] : (ActionA | ActionB)[]
|
||||
|
||||
new ActionA(),
|
||||
>new ActionA() : ActionA
|
||||
>ActionA : typeof ActionA
|
||||
|
||||
new ActionB()
|
||||
>new ActionB() : ActionB
|
||||
>ActionB : typeof ActionB
|
||||
|
||||
]
|
||||
|
||||
var z3: { id: number }[] =
|
||||
>z3 : { id: number; }[]
|
||||
>id : number
|
||||
|
||||
[
|
||||
>[ new Action(), new ActionA(), new ActionB() ] : Action[]
|
||||
|
||||
new Action(),
|
||||
>new Action() : Action
|
||||
>Action : typeof Action
|
||||
|
||||
new ActionA(),
|
||||
>new ActionA() : ActionA
|
||||
>ActionA : typeof ActionA
|
||||
|
||||
new ActionB()
|
||||
>new ActionB() : ActionB
|
||||
>ActionB : typeof ActionB
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ var as = [a, b]; // { x: number; y?: number };[]
|
||||
>b : { x: number; z?: number; }
|
||||
|
||||
var bs = [b, a]; // { x: number; z?: number };[]
|
||||
>bs : ({ x: number; y?: number; } | { x: number; z?: number; })[]
|
||||
>[b, a] : ({ x: number; y?: number; } | { x: number; z?: number; })[]
|
||||
>bs : ({ x: number; z?: number; } | { x: number; y?: number; })[]
|
||||
>[b, a] : ({ x: number; z?: number; } | { x: number; y?: number; })[]
|
||||
>b : { x: number; z?: number; }
|
||||
>a : { x: number; y?: number; }
|
||||
|
||||
@@ -36,8 +36,8 @@ var cs = [a, b, c]; // { x: number; y?: number };[]
|
||||
>c : { x: number; a?: number; }
|
||||
|
||||
var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[]
|
||||
>ds : ((x: Object) => number)[]
|
||||
>[(x: Object) => 1, (x: string) => 2] : ((x: Object) => number)[]
|
||||
>ds : (((x: Object) => number) | ((x: string) => number))[]
|
||||
>[(x: Object) => 1, (x: string) => 2] : (((x: Object) => number) | ((x: string) => number))[]
|
||||
>(x: Object) => 1 : (x: Object) => number
|
||||
>x : Object
|
||||
>Object : Object
|
||||
@@ -47,8 +47,8 @@ var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[]
|
||||
>2 : number
|
||||
|
||||
var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[]
|
||||
>es : ((x: string) => number)[]
|
||||
>[(x: string) => 2, (x: Object) => 1] : ((x: string) => number)[]
|
||||
>es : (((x: string) => number) | ((x: Object) => number))[]
|
||||
>[(x: string) => 2, (x: Object) => 1] : (((x: string) => number) | ((x: Object) => number))[]
|
||||
>(x: string) => 2 : (x: string) => number
|
||||
>x : string
|
||||
>2 : number
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'.
|
||||
Index signatures are incompatible.
|
||||
Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'.
|
||||
Type '{ a: string; b: number; c: string; }' is not assignable to type '{ a: string; b: number; }'.
|
||||
Object literal may only specify known properties, and 'c' does not exist in type '{ a: string; b: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts (1 errors) ====
|
||||
// Empty array literal with no contextual type has type Undefined[]
|
||||
|
||||
var arr1= [[], [1], ['']];
|
||||
|
||||
var arr2 = [[null], [1], ['']];
|
||||
|
||||
|
||||
// Array literal with elements of only EveryType E has type E[]
|
||||
var stringArrArr = [[''], [""]];
|
||||
|
||||
var stringArr = ['', ""];
|
||||
|
||||
var numberArr = [0, 0.0, 0x00, 1e1];
|
||||
|
||||
var boolArr = [false, true, false, true];
|
||||
|
||||
class C { private p; }
|
||||
var classArr = [new C(), new C()];
|
||||
|
||||
var classTypeArray = [C, C, C];
|
||||
var classTypeArray: Array<typeof C>; // Should OK, not be a parse error
|
||||
|
||||
// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[]
|
||||
var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'.
|
||||
!!! error TS2322: Index signatures are incompatible.
|
||||
!!! error TS2322: Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'.
|
||||
!!! error TS2322: Type '{ a: string; b: number; c: string; }' is not assignable to type '{ a: string; b: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'c' does not exist in type '{ a: string; b: number; }'.
|
||||
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
|
||||
class Base { private p; }
|
||||
class Derived1 extends Base { private m };
|
||||
class Derived2 extends Base { private n };
|
||||
var context3: Base[] = [new Derived1(), new Derived2()];
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[]
|
||||
var context4: Base[] = [new Derived1(), new Derived1()];
|
||||
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts ===
|
||||
// Empty array literal with no contextual type has type Undefined[]
|
||||
|
||||
var arr1= [[], [1], ['']];
|
||||
>arr1 : Symbol(arr1, Decl(arrayLiterals.ts, 2, 3))
|
||||
|
||||
var arr2 = [[null], [1], ['']];
|
||||
>arr2 : Symbol(arr2, Decl(arrayLiterals.ts, 4, 3))
|
||||
|
||||
|
||||
// Array literal with elements of only EveryType E has type E[]
|
||||
var stringArrArr = [[''], [""]];
|
||||
>stringArrArr : Symbol(stringArrArr, Decl(arrayLiterals.ts, 8, 3))
|
||||
|
||||
var stringArr = ['', ""];
|
||||
>stringArr : Symbol(stringArr, Decl(arrayLiterals.ts, 10, 3))
|
||||
|
||||
var numberArr = [0, 0.0, 0x00, 1e1];
|
||||
>numberArr : Symbol(numberArr, Decl(arrayLiterals.ts, 12, 3))
|
||||
|
||||
var boolArr = [false, true, false, true];
|
||||
>boolArr : Symbol(boolArr, Decl(arrayLiterals.ts, 14, 3))
|
||||
|
||||
class C { private p; }
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
>p : Symbol(p, Decl(arrayLiterals.ts, 16, 9))
|
||||
|
||||
var classArr = [new C(), new C()];
|
||||
>classArr : Symbol(classArr, Decl(arrayLiterals.ts, 17, 3))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
|
||||
var classTypeArray = [C, C, C];
|
||||
>classTypeArray : Symbol(classTypeArray, Decl(arrayLiterals.ts, 19, 3), Decl(arrayLiterals.ts, 20, 3))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
|
||||
var classTypeArray: Array<typeof C>; // Should OK, not be a parse error
|
||||
>classTypeArray : Symbol(classTypeArray, Decl(arrayLiterals.ts, 19, 3), Decl(arrayLiterals.ts, 20, 3))
|
||||
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
|
||||
>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41))
|
||||
|
||||
// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[]
|
||||
var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
|
||||
>context1 : Symbol(context1, Decl(arrayLiterals.ts, 23, 3))
|
||||
>n : Symbol(n, Decl(arrayLiterals.ts, 23, 17))
|
||||
>a : Symbol(a, Decl(arrayLiterals.ts, 23, 30))
|
||||
>b : Symbol(b, Decl(arrayLiterals.ts, 23, 41))
|
||||
>a : Symbol(a, Decl(arrayLiterals.ts, 23, 62))
|
||||
>b : Symbol(b, Decl(arrayLiterals.ts, 23, 69))
|
||||
>c : Symbol(c, Decl(arrayLiterals.ts, 23, 75))
|
||||
>a : Symbol(a, Decl(arrayLiterals.ts, 23, 86))
|
||||
>b : Symbol(b, Decl(arrayLiterals.ts, 23, 93))
|
||||
>c : Symbol(c, Decl(arrayLiterals.ts, 23, 99))
|
||||
|
||||
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
|
||||
>context2 : Symbol(context2, Decl(arrayLiterals.ts, 24, 3))
|
||||
>a : Symbol(a, Decl(arrayLiterals.ts, 24, 17))
|
||||
>b : Symbol(b, Decl(arrayLiterals.ts, 24, 24))
|
||||
>c : Symbol(c, Decl(arrayLiterals.ts, 24, 30))
|
||||
>a : Symbol(a, Decl(arrayLiterals.ts, 24, 41))
|
||||
>b : Symbol(b, Decl(arrayLiterals.ts, 24, 48))
|
||||
>c : Symbol(c, Decl(arrayLiterals.ts, 24, 54))
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
|
||||
class Base { private p; }
|
||||
>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63))
|
||||
>p : Symbol(p, Decl(arrayLiterals.ts, 27, 12))
|
||||
|
||||
class Derived1 extends Base { private m };
|
||||
>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25))
|
||||
>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63))
|
||||
>m : Symbol(m, Decl(arrayLiterals.ts, 28, 29))
|
||||
|
||||
class Derived2 extends Base { private n };
|
||||
>Derived2 : Symbol(Derived2, Decl(arrayLiterals.ts, 28, 42))
|
||||
>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63))
|
||||
>n : Symbol(n, Decl(arrayLiterals.ts, 29, 29))
|
||||
|
||||
var context3: Base[] = [new Derived1(), new Derived2()];
|
||||
>context3 : Symbol(context3, Decl(arrayLiterals.ts, 30, 3))
|
||||
>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63))
|
||||
>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25))
|
||||
>Derived2 : Symbol(Derived2, Decl(arrayLiterals.ts, 28, 42))
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[]
|
||||
var context4: Base[] = [new Derived1(), new Derived1()];
|
||||
>context4 : Symbol(context4, Decl(arrayLiterals.ts, 33, 3))
|
||||
>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63))
|
||||
>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25))
|
||||
>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25))
|
||||
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts ===
|
||||
// Empty array literal with no contextual type has type Undefined[]
|
||||
|
||||
var arr1= [[], [1], ['']];
|
||||
>arr1 : (number[] | string[])[]
|
||||
>[[], [1], ['']] : (number[] | string[])[]
|
||||
>[] : undefined[]
|
||||
>[1] : number[]
|
||||
>1 : number
|
||||
>[''] : string[]
|
||||
>'' : string
|
||||
|
||||
var arr2 = [[null], [1], ['']];
|
||||
>arr2 : (number[] | string[])[]
|
||||
>[[null], [1], ['']] : (number[] | string[])[]
|
||||
>[null] : null[]
|
||||
>null : null
|
||||
>[1] : number[]
|
||||
>1 : number
|
||||
>[''] : string[]
|
||||
>'' : string
|
||||
|
||||
|
||||
// Array literal with elements of only EveryType E has type E[]
|
||||
var stringArrArr = [[''], [""]];
|
||||
>stringArrArr : string[][]
|
||||
>[[''], [""]] : string[][]
|
||||
>[''] : string[]
|
||||
>'' : string
|
||||
>[""] : string[]
|
||||
>"" : string
|
||||
|
||||
var stringArr = ['', ""];
|
||||
>stringArr : string[]
|
||||
>['', ""] : string[]
|
||||
>'' : string
|
||||
>"" : string
|
||||
|
||||
var numberArr = [0, 0.0, 0x00, 1e1];
|
||||
>numberArr : number[]
|
||||
>[0, 0.0, 0x00, 1e1] : number[]
|
||||
>0 : number
|
||||
>0.0 : number
|
||||
>0x00 : number
|
||||
>1e1 : number
|
||||
|
||||
var boolArr = [false, true, false, true];
|
||||
>boolArr : boolean[]
|
||||
>[false, true, false, true] : boolean[]
|
||||
>false : boolean
|
||||
>true : boolean
|
||||
>false : boolean
|
||||
>true : boolean
|
||||
|
||||
class C { private p; }
|
||||
>C : C
|
||||
>p : any
|
||||
|
||||
var classArr = [new C(), new C()];
|
||||
>classArr : C[]
|
||||
>[new C(), new C()] : C[]
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
>new C() : C
|
||||
>C : typeof C
|
||||
|
||||
var classTypeArray = [C, C, C];
|
||||
>classTypeArray : typeof C[]
|
||||
>[C, C, C] : typeof C[]
|
||||
>C : typeof C
|
||||
>C : typeof C
|
||||
>C : typeof C
|
||||
|
||||
var classTypeArray: Array<typeof C>; // Should OK, not be a parse error
|
||||
>classTypeArray : typeof C[]
|
||||
>Array : T[]
|
||||
>C : typeof C
|
||||
|
||||
// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[]
|
||||
var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
|
||||
>context1 : { [n: number]: { a: string; b: number; }; }
|
||||
>n : number
|
||||
>a : string
|
||||
>b : number
|
||||
>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]
|
||||
>{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; }
|
||||
>a : string
|
||||
>'' : string
|
||||
>b : number
|
||||
>0 : number
|
||||
>c : string
|
||||
>'' : string
|
||||
>{ a: "", b: 3, c: 0 } : { a: string; b: number; c: number; }
|
||||
>a : string
|
||||
>"" : string
|
||||
>b : number
|
||||
>3 : number
|
||||
>c : number
|
||||
>0 : number
|
||||
|
||||
var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
|
||||
>context2 : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]
|
||||
>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]
|
||||
>{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; }
|
||||
>a : string
|
||||
>'' : string
|
||||
>b : number
|
||||
>0 : number
|
||||
>c : string
|
||||
>'' : string
|
||||
>{ a: "", b: 3, c: 0 } : { a: string; b: number; c: number; }
|
||||
>a : string
|
||||
>"" : string
|
||||
>b : number
|
||||
>3 : number
|
||||
>c : number
|
||||
>0 : number
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[]
|
||||
class Base { private p; }
|
||||
>Base : Base
|
||||
>p : any
|
||||
|
||||
class Derived1 extends Base { private m };
|
||||
>Derived1 : Derived1
|
||||
>Base : Base
|
||||
>m : any
|
||||
|
||||
class Derived2 extends Base { private n };
|
||||
>Derived2 : Derived2
|
||||
>Base : Base
|
||||
>n : any
|
||||
|
||||
var context3: Base[] = [new Derived1(), new Derived2()];
|
||||
>context3 : Base[]
|
||||
>Base : Base
|
||||
>[new Derived1(), new Derived2()] : (Derived1 | Derived2)[]
|
||||
>new Derived1() : Derived1
|
||||
>Derived1 : typeof Derived1
|
||||
>new Derived2() : Derived2
|
||||
>Derived2 : typeof Derived2
|
||||
|
||||
// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[]
|
||||
var context4: Base[] = [new Derived1(), new Derived1()];
|
||||
>context4 : Base[]
|
||||
>Base : Base
|
||||
>[new Derived1(), new Derived1()] : Derived1[]
|
||||
>new Derived1() : Derived1
|
||||
>Derived1 : typeof Derived1
|
||||
>new Derived1() : Derived1
|
||||
>Derived1 : typeof Derived1
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ var a1 = ["hello", "world"]
|
||||
>"world" : string
|
||||
|
||||
var a2 = [, , , ...a0, "hello"];
|
||||
>a2 : (string | number)[]
|
||||
>[, , , ...a0, "hello"] : (string | number)[]
|
||||
>a2 : (number | string)[]
|
||||
>[, , , ...a0, "hello"] : (number | string)[]
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
@@ -151,8 +151,8 @@ interface myArray2 extends Array<Number|String> { }
|
||||
>String : String
|
||||
|
||||
var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[]
|
||||
>d0 : (string | number | boolean)[]
|
||||
>[1, true, ...temp,] : (string | number | boolean)[]
|
||||
>d0 : (number | boolean | string)[]
|
||||
>[1, true, ...temp,] : (number | boolean | string)[]
|
||||
>1 : number
|
||||
>true : boolean
|
||||
>...temp : string
|
||||
@@ -214,8 +214,8 @@ var d8: number[][] = [[...temp1]]
|
||||
>temp1 : number[]
|
||||
|
||||
var d9 = [[...temp1], ...["hello"]];
|
||||
>d9 : (string | number[])[]
|
||||
>[[...temp1], ...["hello"]] : (string | number[])[]
|
||||
>d9 : (number[] | string)[]
|
||||
>[[...temp1], ...["hello"]] : (number[] | string)[]
|
||||
>[...temp1] : number[]
|
||||
>...temp1 : number
|
||||
>temp1 : number[]
|
||||
|
||||
@@ -24,8 +24,8 @@ var a1 = ["hello", "world"]
|
||||
>"world" : string
|
||||
|
||||
var a2 = [, , , ...a0, "hello"];
|
||||
>a2 : (string | number)[]
|
||||
>[, , , ...a0, "hello"] : (string | number)[]
|
||||
>a2 : (number | string)[]
|
||||
>[, , , ...a0, "hello"] : (number | string)[]
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
@@ -140,8 +140,8 @@ interface myArray2 extends Array<Number|String> { }
|
||||
>String : String
|
||||
|
||||
var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[]
|
||||
>d0 : (string | number | boolean)[]
|
||||
>[1, true, ...temp, ] : (string | number | boolean)[]
|
||||
>d0 : (number | boolean | string)[]
|
||||
>[1, true, ...temp, ] : (number | boolean | string)[]
|
||||
>1 : number
|
||||
>true : boolean
|
||||
>...temp : string
|
||||
@@ -176,10 +176,10 @@ var d4: myArray2 = [...temp, ...temp1];
|
||||
>temp1 : number[]
|
||||
|
||||
var d5 = [...a2];
|
||||
>d5 : (string | number)[]
|
||||
>[...a2] : (string | number)[]
|
||||
>...a2 : string | number
|
||||
>a2 : (string | number)[]
|
||||
>d5 : (number | string)[]
|
||||
>[...a2] : (number | string)[]
|
||||
>...a2 : number | string
|
||||
>a2 : (number | string)[]
|
||||
|
||||
var d6 = [...a3];
|
||||
>d6 : number[]
|
||||
@@ -201,8 +201,8 @@ var d8: number[][] = [[...temp1]]
|
||||
>temp1 : number[]
|
||||
|
||||
var d9 = [[...temp1], ...["hello"]];
|
||||
>d9 : (string | number[])[]
|
||||
>[[...temp1], ...["hello"]] : (string | number[])[]
|
||||
>d9 : (number[] | string)[]
|
||||
>[[...temp1], ...["hello"]] : (number[] | string)[]
|
||||
>[...temp1] : number[]
|
||||
>...temp1 : number
|
||||
>temp1 : number[]
|
||||
|
||||
@@ -5,18 +5,18 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,5): error
|
||||
Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number | boolean' is not assignable to type '() => number'.
|
||||
Type 'string | number | boolean' is not assignable to type 'number'.
|
||||
Type '() => number | string | boolean' is not assignable to type '() => number'.
|
||||
Type 'number | string | boolean' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error TS2322: Type '(number[] | string[])[]' is not assignable to type 'tup'.
|
||||
Property '0' is missing in type '(number[] | string[])[]'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
|
||||
Property '0' is missing in type 'number[]'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(number | string)[]' is not assignable to type 'myArray'.
|
||||
Types of property 'push' are incompatible.
|
||||
Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
Type '(...items: (number | string)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
Types of parameters 'items' and 'items' are incompatible.
|
||||
Type 'string | number' is not assignable to type 'Number'.
|
||||
Type 'number | string' is not assignable to type 'Number'.
|
||||
Type 'string' is not assignable to type 'Number'.
|
||||
Property 'toFixed' is missing in type 'String'.
|
||||
|
||||
@@ -49,8 +49,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => string | number | boolean' is not assignable to type '() => number'.
|
||||
!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '() => number | string | boolean' is not assignable to type '() => number'.
|
||||
!!! error TS2322: Type 'number | string | boolean' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
// The resulting type an array literal expression is determined as follows:
|
||||
@@ -76,11 +76,11 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
|
||||
!!! error TS2322: Property '0' is missing in type 'number[]'.
|
||||
var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[]
|
||||
~~
|
||||
!!! error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
|
||||
!!! error TS2322: Type '(number | string)[]' is not assignable to type 'myArray'.
|
||||
!!! error TS2322: Types of property 'push' are incompatible.
|
||||
!!! error TS2322: Type '(...items: (string | number)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
!!! error TS2322: Type '(...items: (number | string)[]) => number' is not assignable to type '(...items: Number[]) => number'.
|
||||
!!! error TS2322: Types of parameters 'items' and 'items' are incompatible.
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'Number'.
|
||||
!!! error TS2322: Type 'number | string' is not assignable to type 'Number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
|
||||
!!! error TS2322: Property 'toFixed' is missing in type 'String'.
|
||||
|
||||
@@ -77,8 +77,8 @@ var myDerivedList: DerivedList<number>;
|
||||
>DerivedList : DerivedList<U>
|
||||
|
||||
var as = [list, myDerivedList]; // List<number>[]
|
||||
>as : List<number>[]
|
||||
>[list, myDerivedList] : List<number>[]
|
||||
>as : (List<number> | DerivedList<number>)[]
|
||||
>[list, myDerivedList] : (List<number> | DerivedList<number>)[]
|
||||
>list : List<number>
|
||||
>myDerivedList : DerivedList<number>
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(17,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(26,10): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts (2 errors) ====
|
||||
// valid uses of arrays of function types
|
||||
|
||||
var x = [() => 1, () => { }];
|
||||
var r2 = x[0]();
|
||||
|
||||
class C {
|
||||
foo: string;
|
||||
}
|
||||
var y = [C, C];
|
||||
var r3 = new y[0]();
|
||||
|
||||
var a: { (x: number): number; (x: string): string; };
|
||||
var b: { (x: number): number; (x: string): string; };
|
||||
var c: { (x: number): number; (x: any): any; };
|
||||
var z = [a, b, c];
|
||||
var r4 = z[0];
|
||||
var r5 = r4(''); // any not string
|
||||
~~
|
||||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
var r5b = r4(1);
|
||||
|
||||
var a2: { <T>(x: T): number; (x: string): string;};
|
||||
var b2: { <T>(x: T): number; (x: string): string; };
|
||||
var c2: { (x: number): number; <T>(x: T): any; };
|
||||
|
||||
var z2 = [a2, b2, c2];
|
||||
var r6 = z2[0];
|
||||
var r7 = r6(''); // any not string
|
||||
~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
@@ -1,93 +0,0 @@
|
||||
=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts ===
|
||||
// valid uses of arrays of function types
|
||||
|
||||
var x = [() => 1, () => { }];
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3))
|
||||
|
||||
var r2 = x[0]();
|
||||
>r2 : Symbol(r2, Decl(arrayOfFunctionTypes3.ts, 3, 3))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 2, 3))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16))
|
||||
|
||||
foo: string;
|
||||
>foo : Symbol(foo, Decl(arrayOfFunctionTypes3.ts, 5, 9))
|
||||
}
|
||||
var y = [C, C];
|
||||
>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3))
|
||||
>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16))
|
||||
>C : Symbol(C, Decl(arrayOfFunctionTypes3.ts, 3, 16))
|
||||
|
||||
var r3 = new y[0]();
|
||||
>r3 : Symbol(r3, Decl(arrayOfFunctionTypes3.ts, 9, 3))
|
||||
>y : Symbol(y, Decl(arrayOfFunctionTypes3.ts, 8, 3))
|
||||
|
||||
var a: { (x: number): number; (x: string): string; };
|
||||
>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 10))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 11, 31))
|
||||
|
||||
var b: { (x: number): number; (x: string): string; };
|
||||
>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 10))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 12, 31))
|
||||
|
||||
var c: { (x: number): number; (x: any): any; };
|
||||
>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 10))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 13, 31))
|
||||
|
||||
var z = [a, b, c];
|
||||
>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3))
|
||||
>a : Symbol(a, Decl(arrayOfFunctionTypes3.ts, 11, 3))
|
||||
>b : Symbol(b, Decl(arrayOfFunctionTypes3.ts, 12, 3))
|
||||
>c : Symbol(c, Decl(arrayOfFunctionTypes3.ts, 13, 3))
|
||||
|
||||
var r4 = z[0];
|
||||
>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3))
|
||||
>z : Symbol(z, Decl(arrayOfFunctionTypes3.ts, 14, 3))
|
||||
|
||||
var r5 = r4(''); // any not string
|
||||
>r5 : Symbol(r5, Decl(arrayOfFunctionTypes3.ts, 16, 3))
|
||||
>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3))
|
||||
|
||||
var r5b = r4(1);
|
||||
>r5b : Symbol(r5b, Decl(arrayOfFunctionTypes3.ts, 17, 3))
|
||||
>r4 : Symbol(r4, Decl(arrayOfFunctionTypes3.ts, 15, 3))
|
||||
|
||||
var a2: { <T>(x: T): number; (x: string): string;};
|
||||
>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 14))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 19, 11))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 19, 30))
|
||||
|
||||
var b2: { <T>(x: T): number; (x: string): string; };
|
||||
>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 14))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 20, 11))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 20, 30))
|
||||
|
||||
var c2: { (x: number): number; <T>(x: T): any; };
|
||||
>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 11))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32))
|
||||
>x : Symbol(x, Decl(arrayOfFunctionTypes3.ts, 21, 35))
|
||||
>T : Symbol(T, Decl(arrayOfFunctionTypes3.ts, 21, 32))
|
||||
|
||||
var z2 = [a2, b2, c2];
|
||||
>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3))
|
||||
>a2 : Symbol(a2, Decl(arrayOfFunctionTypes3.ts, 19, 3))
|
||||
>b2 : Symbol(b2, Decl(arrayOfFunctionTypes3.ts, 20, 3))
|
||||
>c2 : Symbol(c2, Decl(arrayOfFunctionTypes3.ts, 21, 3))
|
||||
|
||||
var r6 = z2[0];
|
||||
>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3))
|
||||
>z2 : Symbol(z2, Decl(arrayOfFunctionTypes3.ts, 23, 3))
|
||||
|
||||
var r7 = r6(''); // any not string
|
||||
>r7 : Symbol(r7, Decl(arrayOfFunctionTypes3.ts, 25, 3))
|
||||
>r6 : Symbol(r6, Decl(arrayOfFunctionTypes3.ts, 24, 3))
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts ===
|
||||
// valid uses of arrays of function types
|
||||
|
||||
var x = [() => 1, () => { }];
|
||||
>x : (() => void)[]
|
||||
>[() => 1, () => { }] : (() => void)[]
|
||||
>() => 1 : () => number
|
||||
>1 : number
|
||||
>() => { } : () => void
|
||||
|
||||
var r2 = x[0]();
|
||||
>r2 : void
|
||||
>x[0]() : void
|
||||
>x[0] : () => void
|
||||
>x : (() => void)[]
|
||||
>0 : number
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
foo: string;
|
||||
>foo : string
|
||||
}
|
||||
var y = [C, C];
|
||||
>y : typeof C[]
|
||||
>[C, C] : typeof C[]
|
||||
>C : typeof C
|
||||
>C : typeof C
|
||||
|
||||
var r3 = new y[0]();
|
||||
>r3 : C
|
||||
>new y[0]() : C
|
||||
>y[0] : typeof C
|
||||
>y : typeof C[]
|
||||
>0 : number
|
||||
|
||||
var a: { (x: number): number; (x: string): string; };
|
||||
>a : { (x: number): number; (x: string): string; }
|
||||
>x : number
|
||||
>x : string
|
||||
|
||||
var b: { (x: number): number; (x: string): string; };
|
||||
>b : { (x: number): number; (x: string): string; }
|
||||
>x : number
|
||||
>x : string
|
||||
|
||||
var c: { (x: number): number; (x: any): any; };
|
||||
>c : { (x: number): number; (x: any): any; }
|
||||
>x : number
|
||||
>x : any
|
||||
|
||||
var z = [a, b, c];
|
||||
>z : { (x: number): number; (x: any): any; }[]
|
||||
>[a, b, c] : { (x: number): number; (x: any): any; }[]
|
||||
>a : { (x: number): number; (x: string): string; }
|
||||
>b : { (x: number): number; (x: string): string; }
|
||||
>c : { (x: number): number; (x: any): any; }
|
||||
|
||||
var r4 = z[0];
|
||||
>r4 : { (x: number): number; (x: any): any; }
|
||||
>z[0] : { (x: number): number; (x: any): any; }
|
||||
>z : { (x: number): number; (x: any): any; }[]
|
||||
>0 : number
|
||||
|
||||
var r5 = r4(''); // any not string
|
||||
>r5 : any
|
||||
>r4('') : any
|
||||
>r4 : { (x: number): number; (x: any): any; }
|
||||
>'' : string
|
||||
|
||||
var r5b = r4(1);
|
||||
>r5b : number
|
||||
>r4(1) : number
|
||||
>r4 : { (x: number): number; (x: any): any; }
|
||||
>1 : number
|
||||
|
||||
var a2: { <T>(x: T): number; (x: string): string;};
|
||||
>a2 : { <T>(x: T): number; (x: string): string; }
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>x : string
|
||||
|
||||
var b2: { <T>(x: T): number; (x: string): string; };
|
||||
>b2 : { <T>(x: T): number; (x: string): string; }
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>x : string
|
||||
|
||||
var c2: { (x: number): number; <T>(x: T): any; };
|
||||
>c2 : { (x: number): number; <T>(x: T): any; }
|
||||
>x : number
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
|
||||
var z2 = [a2, b2, c2];
|
||||
>z2 : { (x: number): number; <T>(x: T): any; }[]
|
||||
>[a2, b2, c2] : { (x: number): number; <T>(x: T): any; }[]
|
||||
>a2 : { <T>(x: T): number; (x: string): string; }
|
||||
>b2 : { <T>(x: T): number; (x: string): string; }
|
||||
>c2 : { (x: number): number; <T>(x: T): any; }
|
||||
|
||||
var r6 = z2[0];
|
||||
>r6 : { (x: number): number; <T>(x: T): any; }
|
||||
>z2[0] : { (x: number): number; <T>(x: T): any; }
|
||||
>z2 : { (x: number): number; <T>(x: T): any; }[]
|
||||
>0 : number
|
||||
|
||||
var r7 = r6(''); // any not string
|
||||
>r7 : any
|
||||
>r6('') : any
|
||||
>r6 : { (x: number): number; <T>(x: T): any; }
|
||||
>'' : string
|
||||
|
||||
@@ -24,12 +24,12 @@ var z = Date as any as string;
|
||||
|
||||
// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string'
|
||||
var j = 32 as number|string;
|
||||
>j : string | number
|
||||
>32 as number|string : string | number
|
||||
>j : number | string
|
||||
>32 as number|string : number | string
|
||||
>32 : number
|
||||
|
||||
j = '';
|
||||
>j = '' : string
|
||||
>j : string | number
|
||||
>j : number | string
|
||||
>'' : string
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts(17,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number' is not assignable to type '() => number'.
|
||||
Type 'string | number' is not assignable to type 'number'.
|
||||
Type '() => number | string' is not assignable to type '() => number'.
|
||||
Type 'number | string' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts(18,1): error TS2322: Type '{}[]' is not assignable to type '[{}]'.
|
||||
Property '0' is missing in type '{}[]'.
|
||||
@@ -28,8 +28,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '[number, string]' is not assignable to type 'number[]'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => string | number' is not assignable to type '() => number'.
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '() => number | string' is not assignable to type '() => number'.
|
||||
!!! error TS2322: Type 'number | string' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
emptyObjTuple = emptyObjArray;
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(1,5): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
|
||||
Property 'b' is missing in type '{ a: number; }'.
|
||||
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(3,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
|
||||
Property 'b' is missing in type '{ a: number; }'.
|
||||
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(5,1): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'.
|
||||
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug2.ts(20,1): error TS2322: Type '{ f: (n: number) => number; m: number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
|
||||
@@ -10,18 +12,21 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n:
|
||||
Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/assignmentCompatBug2.ts (5 errors) ====
|
||||
==== tests/cases/compiler/assignmentCompatBug2.ts (6 errors) ====
|
||||
var b2: { b: number;} = { a: 0 }; // error
|
||||
~~
|
||||
!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
|
||||
!!! error TS2322: Property 'b' is missing in type '{ a: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
|
||||
b2 = { a: 0 }; // error
|
||||
~~
|
||||
!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
|
||||
!!! error TS2322: Property 'b' is missing in type '{ a: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
|
||||
b2 = {b: 0, a: 0 };
|
||||
~~
|
||||
!!! error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
|
||||
|
||||
var b3: { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; };
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/assignmentCompatBug5.ts(2,6): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
|
||||
Property 'a' is missing in type '{ b: number; }'.
|
||||
Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
|
||||
tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'number[]'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/compiler/assignmentCompatBug5.ts(8,6): error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'.
|
||||
@@ -14,7 +14,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of typ
|
||||
foo1({ b: 5 });
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
|
||||
!!! error TS2345: Property 'a' is missing in type '{ b: number; }'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
|
||||
|
||||
function foo2(x: number[]) { }
|
||||
foo2(["s", "t"]);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/conformance/async/es6/awaitUnion_es6.ts ===
|
||||
declare let a: number | string;
|
||||
>a : string | number
|
||||
>a : number | string
|
||||
|
||||
declare let b: PromiseLike<number> | PromiseLike<string>;
|
||||
>b : PromiseLike<number> | PromiseLike<string>
|
||||
@@ -8,7 +8,7 @@ declare let b: PromiseLike<number> | PromiseLike<string>;
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
declare let c: PromiseLike<number | string>;
|
||||
>c : PromiseLike<string | number>
|
||||
>c : PromiseLike<number | string>
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
declare let d: number | PromiseLike<string>;
|
||||
@@ -16,29 +16,29 @@ declare let d: number | PromiseLike<string>;
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
declare let e: number | PromiseLike<number | string>;
|
||||
>e : number | PromiseLike<string | number>
|
||||
>e : number | PromiseLike<number | string>
|
||||
>PromiseLike : PromiseLike<T>
|
||||
|
||||
async function f() {
|
||||
>f : () => Promise<void>
|
||||
|
||||
let await_a = await a;
|
||||
>await_a : string | number
|
||||
>await_a : number | string
|
||||
>a : any
|
||||
|
||||
let await_b = await b;
|
||||
>await_b : string | number
|
||||
>await_b : number | string
|
||||
>b : any
|
||||
|
||||
let await_c = await c;
|
||||
>await_c : string | number
|
||||
>await_c : number | string
|
||||
>c : any
|
||||
|
||||
let await_d = await d;
|
||||
>await_d : string | number
|
||||
>await_d : number | string
|
||||
>d : any
|
||||
|
||||
let await_e = await e;
|
||||
>await_e : string | number
|
||||
>await_e : number | string
|
||||
>e : any
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ var r = true ? 1 : 2;
|
||||
>2 : number
|
||||
|
||||
var r3 = true ? 1 : {};
|
||||
>r3 : {}
|
||||
>true ? 1 : {} : {}
|
||||
>r3 : number | {}
|
||||
>true ? 1 : {} : number | {}
|
||||
>true : boolean
|
||||
>1 : number
|
||||
>{} : {}
|
||||
@@ -60,15 +60,15 @@ var r4 = true ? a : b; // typeof a
|
||||
>b : { x: number; z?: number; }
|
||||
|
||||
var r5 = true ? b : a; // typeof b
|
||||
>r5 : { x: number; y?: number; } | { x: number; z?: number; }
|
||||
>true ? b : a : { x: number; y?: number; } | { x: number; z?: number; }
|
||||
>r5 : { x: number; z?: number; } | { x: number; y?: number; }
|
||||
>true ? b : a : { x: number; z?: number; } | { x: number; y?: number; }
|
||||
>true : boolean
|
||||
>b : { x: number; z?: number; }
|
||||
>a : { x: number; y?: number; }
|
||||
|
||||
var r6 = true ? (x: number) => { } : (x: Object) => { }; // returns number => void
|
||||
>r6 : (x: number) => void
|
||||
>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void
|
||||
>r6 : ((x: number) => void) | ((x: Object) => void)
|
||||
>true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void)
|
||||
>true : boolean
|
||||
>(x: number) => { } : (x: number) => void
|
||||
>x : number
|
||||
@@ -80,7 +80,7 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { };
|
||||
>r7 : (x: Object) => void
|
||||
>x : Object
|
||||
>Object : Object
|
||||
>true ? (x: number) => { } : (x: Object) => { } : (x: number) => void
|
||||
>true ? (x: number) => { } : (x: Object) => { } : ((x: number) => void) | ((x: Object) => void)
|
||||
>true : boolean
|
||||
>(x: number) => { } : (x: number) => void
|
||||
>x : number
|
||||
@@ -89,8 +89,8 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { };
|
||||
>Object : Object
|
||||
|
||||
var r8 = true ? (x: Object) => { } : (x: number) => { }; // returns Object => void
|
||||
>r8 : (x: Object) => void
|
||||
>true ? (x: Object) => { } : (x: number) => { } : (x: Object) => void
|
||||
>r8 : ((x: Object) => void) | ((x: number) => void)
|
||||
>true ? (x: Object) => { } : (x: number) => { } : ((x: Object) => void) | ((x: number) => void)
|
||||
>true : boolean
|
||||
>(x: Object) => { } : (x: Object) => void
|
||||
>x : Object
|
||||
@@ -107,8 +107,8 @@ var r10: Base = true ? derived : derived2; // no error since we use the contextu
|
||||
>derived2 : Derived2
|
||||
|
||||
var r11 = true ? base : derived2;
|
||||
>r11 : Base
|
||||
>true ? base : derived2 : Base
|
||||
>r11 : Base | Derived2
|
||||
>true ? base : derived2 : Base | Derived2
|
||||
>true : boolean
|
||||
>base : Base
|
||||
>derived2 : Derived2
|
||||
|
||||
@@ -98,8 +98,8 @@ var e3 = t3[2]; // any
|
||||
>2 : number
|
||||
|
||||
var e4 = t4[3]; // number
|
||||
>e4 : number
|
||||
>t4[3] : number
|
||||
>e4 : E1 | E2 | number
|
||||
>t4[3] : E1 | E2 | number
|
||||
>t4 : [E1, E2, number]
|
||||
>3 : number
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ var t5: [C1, F]
|
||||
>F : F
|
||||
|
||||
var e11 = t1[4]; // base
|
||||
>e11 : base
|
||||
>t1[4] : base
|
||||
>e11 : C | base
|
||||
>t1[4] : C | base
|
||||
>t1 : [C, base]
|
||||
>4 : number
|
||||
|
||||
@@ -78,20 +78,20 @@ var e21 = t2[4]; // {}
|
||||
>4 : number
|
||||
|
||||
var e31 = t3[4]; // C1
|
||||
>e31 : C1
|
||||
>t3[4] : C1
|
||||
>e31 : C1 | D1
|
||||
>t3[4] : C1 | D1
|
||||
>t3 : [C1, D1]
|
||||
>4 : number
|
||||
|
||||
var e41 = t4[2]; // base1
|
||||
>e41 : base1
|
||||
>t4[2] : base1
|
||||
>e41 : base1 | C1
|
||||
>t4[2] : base1 | C1
|
||||
>t4 : [base1, C1]
|
||||
>2 : number
|
||||
|
||||
var e51 = t5[2]; // {}
|
||||
>e51 : F | C1
|
||||
>t5[2] : F | C1
|
||||
>e51 : C1 | F
|
||||
>t5[2] : C1 | F
|
||||
>t5 : [C1, F]
|
||||
>2 : number
|
||||
|
||||
|
||||
@@ -27,43 +27,43 @@ var z: Z;
|
||||
|
||||
// All these arrays should be X[]
|
||||
var b1 = [x, y, z];
|
||||
>b1 : X[]
|
||||
>[x, y, z] : X[]
|
||||
>b1 : (X | Y | Z)[]
|
||||
>[x, y, z] : (X | Y | Z)[]
|
||||
>x : X
|
||||
>y : Y
|
||||
>z : Z
|
||||
|
||||
var b2 = [x, z, y];
|
||||
>b2 : X[]
|
||||
>[x, z, y] : X[]
|
||||
>b2 : (X | Z | Y)[]
|
||||
>[x, z, y] : (X | Z | Y)[]
|
||||
>x : X
|
||||
>z : Z
|
||||
>y : Y
|
||||
|
||||
var b3 = [y, x, z];
|
||||
>b3 : X[]
|
||||
>[y, x, z] : X[]
|
||||
>b3 : (Y | X | Z)[]
|
||||
>[y, x, z] : (Y | X | Z)[]
|
||||
>y : Y
|
||||
>x : X
|
||||
>z : Z
|
||||
|
||||
var b4 = [y, z, x];
|
||||
>b4 : X[]
|
||||
>[y, z, x] : X[]
|
||||
>b4 : (Y | Z | X)[]
|
||||
>[y, z, x] : (Y | Z | X)[]
|
||||
>y : Y
|
||||
>z : Z
|
||||
>x : X
|
||||
|
||||
var b5 = [z, x, y];
|
||||
>b5 : X[]
|
||||
>[z, x, y] : X[]
|
||||
>b5 : (Z | X | Y)[]
|
||||
>[z, x, y] : (Z | X | Y)[]
|
||||
>z : Z
|
||||
>x : X
|
||||
>y : Y
|
||||
|
||||
var b6 = [z, y, x];
|
||||
>b6 : X[]
|
||||
>[z, y, x] : X[]
|
||||
>b6 : (Z | Y | X)[]
|
||||
>[z, y, x] : (Z | Y | X)[]
|
||||
>z : Z
|
||||
>y : Y
|
||||
>x : X
|
||||
|
||||
@@ -163,8 +163,8 @@ xa[1].foo(1, 2, ...a, "abc");
|
||||
>xa : X[]
|
||||
>1 : number
|
||||
>foo : (x: number, y: number, ...z: string[]) => any
|
||||
>...[1, 2, "abc"] : string | number
|
||||
>[1, 2, "abc"] : (string | number)[]
|
||||
>...[1, 2, "abc"] : number | string
|
||||
>[1, 2, "abc"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"abc" : string
|
||||
|
||||
@@ -164,8 +164,8 @@ xa[1].foo(1, 2, ...a, "abc");
|
||||
>xa : X[]
|
||||
>1 : number
|
||||
>foo : (x: number, y: number, ...z: string[]) => any
|
||||
>...[1, 2, "abc"] : string | number
|
||||
>[1, 2, "abc"] : (string | number)[]
|
||||
>...[1, 2, "abc"] : number | string
|
||||
>[1, 2, "abc"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"abc" : string
|
||||
|
||||
@@ -8,11 +8,12 @@ tests/cases/conformance/types/tuple/castingTuple.ts(28,10): error TS2352: Neithe
|
||||
tests/cases/conformance/types/tuple/castingTuple.ts(29,10): error TS2352: Neither type '[C, D]' nor type '[A, I]' is assignable to the other.
|
||||
Types of property '0' are incompatible.
|
||||
Type 'C' is not assignable to type 'A'.
|
||||
Property 'a' is missing in type 'C'.
|
||||
tests/cases/conformance/types/tuple/castingTuple.ts(30,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
|
||||
tests/cases/conformance/types/tuple/castingTuple.ts(30,14): error TS2352: Neither type '[number, string]' nor type 'number[]' is assignable to the other.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number' is not assignable to type '() => number'.
|
||||
Type 'string | number' is not assignable to type 'number'.
|
||||
Type '() => number | string' is not assignable to type '() => number'.
|
||||
Type 'number | string' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot find name 't4'.
|
||||
|
||||
@@ -61,14 +62,15 @@ tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot
|
||||
!!! error TS2352: Neither type '[C, D]' nor type '[A, I]' is assignable to the other.
|
||||
!!! error TS2352: Types of property '0' are incompatible.
|
||||
!!! error TS2352: Type 'C' is not assignable to type 'A'.
|
||||
!!! error TS2352: Property 'a' is missing in type 'C'.
|
||||
var array1 = <number[]>numStrTuple;
|
||||
~~~~~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2352: Neither type '[number, string]' nor type 'number[]' is assignable to the other.
|
||||
!!! error TS2352: Types of property 'pop' are incompatible.
|
||||
!!! error TS2352: Type '() => string | number' is not assignable to type '() => number'.
|
||||
!!! error TS2352: Type 'string | number' is not assignable to type 'number'.
|
||||
!!! error TS2352: Type '() => number | string' is not assignable to type '() => number'.
|
||||
!!! error TS2352: Type 'number | string' is not assignable to type 'number'.
|
||||
!!! error TS2352: Type 'string' is not assignable to type 'number'.
|
||||
t4[2] = 10;
|
||||
~~
|
||||
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[]
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | boolean | number | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[]
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | (() => void) | boolean | number | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | (() => void) | boolean | number | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | (() => void) | number[]
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | (() => void) | number[]; 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: (() => void) | number | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | (() => void) | number[]
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : (() => void) | number | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | (() => void) | number[]; 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: (() => void) | number | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2322: Type 'string | number' is not assignable to type 'boolean'.
|
||||
Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2322: Type 'number | string' is not assignable to type 'boolean'.
|
||||
Type 'number' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/conditionalExpression1.ts (1 errors) ====
|
||||
var x: boolean = (true ? 1 : ""); // should be an error
|
||||
~
|
||||
!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
!!! error TS2322: Type 'number | string' is not assignable to type 'boolean'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'boolean'.
|
||||
@@ -31,27 +31,27 @@ var b: B;
|
||||
//Cond ? Expr1 : Expr2, Expr1 is supertype
|
||||
//Be Not contextually typed
|
||||
true ? x : a;
|
||||
>true ? x : a : X
|
||||
>true ? x : a : X | A
|
||||
>true : boolean
|
||||
>x : X
|
||||
>a : A
|
||||
|
||||
var result1 = true ? x : a;
|
||||
>result1 : X
|
||||
>true ? x : a : X
|
||||
>result1 : X | A
|
||||
>true ? x : a : X | A
|
||||
>true : boolean
|
||||
>x : X
|
||||
>a : A
|
||||
|
||||
//Expr1 and Expr2 are literals
|
||||
true ? {} : 1;
|
||||
>true ? {} : 1 : {}
|
||||
>true ? {} : 1 : {} | number
|
||||
>true : boolean
|
||||
>{} : {}
|
||||
>1 : number
|
||||
|
||||
true ? { a: 1 } : { a: 2, b: 'string' };
|
||||
>true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; }
|
||||
>true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; } | { a: number; b: string; }
|
||||
>true : boolean
|
||||
>{ a: 1 } : { a: number; }
|
||||
>a : number
|
||||
@@ -63,15 +63,15 @@ true ? { a: 1 } : { a: 2, b: 'string' };
|
||||
>'string' : string
|
||||
|
||||
var result2 = true ? {} : 1;
|
||||
>result2 : {}
|
||||
>true ? {} : 1 : {}
|
||||
>result2 : {} | number
|
||||
>true ? {} : 1 : {} | number
|
||||
>true : boolean
|
||||
>{} : {}
|
||||
>1 : number
|
||||
|
||||
var result3 = true ? { a: 1 } : { a: 2, b: 'string' };
|
||||
>result3 : { a: number; }
|
||||
>true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; }
|
||||
>result3 : { a: number; } | { a: number; b: string; }
|
||||
>true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; } | { a: number; b: string; }
|
||||
>true : boolean
|
||||
>{ a: 1 } : { a: number; }
|
||||
>a : number
|
||||
@@ -86,7 +86,7 @@ var result3 = true ? { a: 1 } : { a: 2, b: 'string' };
|
||||
var resultIsX1: X = true ? x : a;
|
||||
>resultIsX1 : X
|
||||
>X : X
|
||||
>true ? x : a : X
|
||||
>true ? x : a : X | A
|
||||
>true : boolean
|
||||
>x : X
|
||||
>a : A
|
||||
@@ -95,7 +95,7 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA;
|
||||
>result4 : (t: A) => any
|
||||
>t : A
|
||||
>A : A
|
||||
>true ? (m) => m.propertyX : (n) => n.propertyA : (m: A) => any
|
||||
>true ? (m) => m.propertyX : (n) => n.propertyA : ((m: A) => any) | ((n: A) => number)
|
||||
>true : boolean
|
||||
>(m) => m.propertyX : (m: A) => any
|
||||
>m : A
|
||||
@@ -111,27 +111,27 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA;
|
||||
//Cond ? Expr1 : Expr2, Expr2 is supertype
|
||||
//Be Not contextually typed
|
||||
true ? a : x;
|
||||
>true ? a : x : X
|
||||
>true ? a : x : A | X
|
||||
>true : boolean
|
||||
>a : A
|
||||
>x : X
|
||||
|
||||
var result5 = true ? a : x;
|
||||
>result5 : X
|
||||
>true ? a : x : X
|
||||
>result5 : A | X
|
||||
>true ? a : x : A | X
|
||||
>true : boolean
|
||||
>a : A
|
||||
>x : X
|
||||
|
||||
//Expr1 and Expr2 are literals
|
||||
true ? 1 : {};
|
||||
>true ? 1 : {} : {}
|
||||
>true ? 1 : {} : number | {}
|
||||
>true : boolean
|
||||
>1 : number
|
||||
>{} : {}
|
||||
|
||||
true ? { a: 2, b: 'string' } : { a: 1 };
|
||||
>true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; }
|
||||
>true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; b: string; } | { a: number; }
|
||||
>true : boolean
|
||||
>{ a: 2, b: 'string' } : { a: number; b: string; }
|
||||
>a : number
|
||||
@@ -143,15 +143,15 @@ true ? { a: 2, b: 'string' } : { a: 1 };
|
||||
>1 : number
|
||||
|
||||
var result6 = true ? 1 : {};
|
||||
>result6 : {}
|
||||
>true ? 1 : {} : {}
|
||||
>result6 : number | {}
|
||||
>true ? 1 : {} : number | {}
|
||||
>true : boolean
|
||||
>1 : number
|
||||
>{} : {}
|
||||
|
||||
var result7 = true ? { a: 2, b: 'string' } : { a: 1 };
|
||||
>result7 : { a: number; }
|
||||
>true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; }
|
||||
>result7 : { a: number; b: string; } | { a: number; }
|
||||
>true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; b: string; } | { a: number; }
|
||||
>true : boolean
|
||||
>{ a: 2, b: 'string' } : { a: number; b: string; }
|
||||
>a : number
|
||||
@@ -166,7 +166,7 @@ var result7 = true ? { a: 2, b: 'string' } : { a: 1 };
|
||||
var resultIsX2: X = true ? x : a;
|
||||
>resultIsX2 : X
|
||||
>X : X
|
||||
>true ? x : a : X
|
||||
>true ? x : a : X | A
|
||||
>true : boolean
|
||||
>x : X
|
||||
>a : A
|
||||
@@ -175,7 +175,7 @@ var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX;
|
||||
>result8 : (t: A) => any
|
||||
>t : A
|
||||
>A : A
|
||||
>true ? (m) => m.propertyA : (n) => n.propertyX : (n: A) => any
|
||||
>true ? (m) => m.propertyA : (n) => n.propertyX : ((m: A) => number) | ((n: A) => any)
|
||||
>true : boolean
|
||||
>(m) => m.propertyA : (m: A) => number
|
||||
>m : A
|
||||
@@ -218,7 +218,7 @@ var result10: (t: X) => any = true ? (m) => m.propertyX1 : (n) => n.propertyX2;
|
||||
//Expr1 and Expr2 are literals
|
||||
var result11: any = true ? 1 : 'string';
|
||||
>result11 : any
|
||||
>true ? 1 : 'string' : string | number
|
||||
>true ? 1 : 'string' : number | string
|
||||
>true : boolean
|
||||
>1 : number
|
||||
>'string' : string
|
||||
|
||||
@@ -87,24 +87,24 @@ var a = baz(1, 1, g); // Should be number
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var b: number | string;
|
||||
>b : string | number
|
||||
>b : number | string
|
||||
|
||||
var b = foo(g); // Should be number | string
|
||||
>b : string | number
|
||||
>foo(g) : string | number
|
||||
>b : number | string
|
||||
>foo(g) : number | string
|
||||
>foo : <T>(cb: (x: number, y: string) => T) => T
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var b = bar(1, "one", g); // Should be number | string
|
||||
>b : string | number
|
||||
>bar(1, "one", g) : string | number
|
||||
>b : number | string
|
||||
>bar(1, "one", g) : number | string
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>1 : number
|
||||
>"one" : string
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var b = bar("one", 1, g); // Should be number | string
|
||||
>b : string | number
|
||||
>b : number | string
|
||||
>bar("one", 1, g) : string | number
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>"one" : string
|
||||
@@ -112,11 +112,11 @@ var b = bar("one", 1, g); // Should be number | string
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var b = baz(b, b, g); // Should be number | string
|
||||
>b : string | number
|
||||
>baz(b, b, g) : string | number
|
||||
>b : number | string
|
||||
>baz(b, b, g) : number | string
|
||||
>baz : <T, U>(x: T, y: T, cb: (x: T, y: T) => U) => U
|
||||
>b : string | number
|
||||
>b : string | number
|
||||
>b : number | string
|
||||
>b : number | string
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var d: number[] | string[];
|
||||
@@ -138,7 +138,7 @@ var d = bar(1, "one", h); // Should be number[] | string[]
|
||||
|
||||
var d = bar("one", 1, h); // Should be number[] | string[]
|
||||
>d : number[] | string[]
|
||||
>bar("one", 1, h) : number[] | string[]
|
||||
>bar("one", 1, h) : string[] | number[]
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>"one" : string
|
||||
>1 : number
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number | boolean' is not assignable to type '() => string | number'.
|
||||
Type 'string | number | boolean' is not assignable to type 'string | number'.
|
||||
Type 'boolean' is not assignable to type 'string | number'.
|
||||
Type 'boolean' is not assignable to type 'number'.
|
||||
Type '() => number | string | boolean' is not assignable to type '() => number | string'.
|
||||
Type 'number | string | boolean' is not assignable to type 'number | string'.
|
||||
Type 'boolean' is not assignable to type 'number | string'.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(15,1): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
|
||||
tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(18,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'.
|
||||
Types of property '0' are incompatible.
|
||||
@@ -31,10 +31,10 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS23
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'.
|
||||
!!! error TS2322: Types of property 'pop' are incompatible.
|
||||
!!! error TS2322: Type '() => string | number | boolean' is not assignable to type '() => string | number'.
|
||||
!!! error TS2322: Type 'string | number | boolean' is not assignable to type 'string | number'.
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'.
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '() => number | string | boolean' is not assignable to type '() => number | string'.
|
||||
!!! error TS2322: Type 'number | string | boolean' is not assignable to type 'number | string'.
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'number | string'.
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'string'.
|
||||
var numStrBoolTuple: [number, string, boolean] = [5, "foo", true];
|
||||
var objNumTuple: [{ a: string }, number] = [{ a: "world" }, 5];
|
||||
var strTupleTuple: [string, [number, {}]] = ["bar", [5, { x: 1, y: 1 }]];
|
||||
|
||||
@@ -82,7 +82,5 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any
|
||||
>IWithCallSignatures : Symbol(IWithCallSignatures, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 9, 1))
|
||||
>IWithCallSignatures4 : Symbol(IWithCallSignatures4, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 18, 1))
|
||||
>a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52))
|
||||
>a.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
|
||||
>a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52))
|
||||
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
|
||||
|
||||
|
||||
@@ -90,10 +90,10 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any
|
||||
>x4 : IWithCallSignatures | IWithCallSignatures4
|
||||
>IWithCallSignatures : IWithCallSignatures
|
||||
>IWithCallSignatures4 : IWithCallSignatures4
|
||||
>a => /*here a should be any*/ a.toString() : (a: number) => string
|
||||
>a : number
|
||||
>a.toString() : string
|
||||
>a.toString : (radix?: number) => string
|
||||
>a : number
|
||||
>toString : (radix?: number) => string
|
||||
>a => /*here a should be any*/ a.toString() : (a: any) => any
|
||||
>a : any
|
||||
>a.toString() : any
|
||||
>a.toString : any
|
||||
>a : any
|
||||
>toString : any
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ var arrayI1OrI2: Array<I1<number> | I2<number>> = [i1, i2, { // Like i1
|
||||
>Array : T[]
|
||||
>I1 : I1<T>
|
||||
>I2 : I2<T>
|
||||
>[i1, i2, { // Like i1 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", }, { // Like i2 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }, { // Like i1 and i2 both commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }] : (I1<number> | I2<number>)[]
|
||||
>[i1, i2, { // Like i1 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", }, { // Like i2 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }, { // Like i1 and i2 both commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", }] : (I1<number> | I2<number> | { commonPropertyType: string; commonMethodType: (a: string) => string; commonMethodWithTypeParameter: (a: number) => number; methodOnlyInI1: (a: string) => string; propertyOnlyInI1: string; methodOnlyInI2: (a: string) => string; propertyOnlyInI2: string; })[]
|
||||
>i1 : I1<number>
|
||||
>i2 : I2<number>
|
||||
>{ // Like i1 commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", } : { commonPropertyType: string; commonMethodType: (a: string) => string; commonMethodWithTypeParameter: (a: number) => number; methodOnlyInI1: (a: string) => string; propertyOnlyInI1: string; }
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping12.ts (1 errors) ====
|
||||
class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,9 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping12.ts ===
|
||||
class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; }
|
||||
>foo : Symbol(foo, Decl(contextualTyping12.ts, 0, 0))
|
||||
>bar : Symbol(bar, Decl(contextualTyping12.ts, 0, 11))
|
||||
>id : Symbol(id, Decl(contextualTyping12.ts, 0, 24))
|
||||
>id : Symbol(id, Decl(contextualTyping12.ts, 0, 42))
|
||||
>id : Symbol(id, Decl(contextualTyping12.ts, 0, 50))
|
||||
>name : Symbol(name, Decl(contextualTyping12.ts, 0, 55))
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping12.ts ===
|
||||
class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; }
|
||||
>foo : foo
|
||||
>bar : { id: number; }[]
|
||||
>id : number
|
||||
>[{id:1}, {id:2, name:"foo"}] : { id: number; }[]
|
||||
>{id:1} : { id: number; }
|
||||
>id : number
|
||||
>1 : number
|
||||
>{id:2, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>2 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/contextualTyping17.ts(1,33): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping17.ts (1 errors) ====
|
||||
var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"};
|
||||
~~~
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,9 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping17.ts ===
|
||||
var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"};
|
||||
>foo : Symbol(foo, Decl(contextualTyping17.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping17.ts, 0, 10))
|
||||
>id : Symbol(id, Decl(contextualTyping17.ts, 0, 25))
|
||||
>foo : Symbol(foo, Decl(contextualTyping17.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping17.ts, 0, 39))
|
||||
>name : Symbol(name, Decl(contextualTyping17.ts, 0, 45))
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping17.ts ===
|
||||
var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"};
|
||||
>foo : { id: number; }
|
||||
>id : number
|
||||
>{id:4} : { id: number; }
|
||||
>id : number
|
||||
>4 : number
|
||||
>foo = {id: 5, name:"foo"} : { id: number; name: string; }
|
||||
>foo : { id: number; }
|
||||
>{id: 5, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>5 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/contextualTyping2.ts(1,5): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping2.ts (1 errors) ====
|
||||
var foo: {id:number;} = {id:4, name:"foo"};
|
||||
~~~
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,7 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping2.ts ===
|
||||
var foo: {id:number;} = {id:4, name:"foo"};
|
||||
>foo : Symbol(foo, Decl(contextualTyping2.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping2.ts, 0, 10))
|
||||
>id : Symbol(id, Decl(contextualTyping2.ts, 0, 25))
|
||||
>name : Symbol(name, Decl(contextualTyping2.ts, 0, 30))
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping2.ts ===
|
||||
var foo: {id:number;} = {id:4, name:"foo"};
|
||||
>foo : { id: number; }
|
||||
>id : number
|
||||
>{id:4, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>4 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping20.ts (1 errors) ====
|
||||
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}];
|
||||
~~~
|
||||
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,10 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping20.ts ===
|
||||
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}];
|
||||
>foo : Symbol(foo, Decl(contextualTyping20.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping20.ts, 0, 9))
|
||||
>id : Symbol(id, Decl(contextualTyping20.ts, 0, 27))
|
||||
>foo : Symbol(foo, Decl(contextualTyping20.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping20.ts, 0, 43))
|
||||
>id : Symbol(id, Decl(contextualTyping20.ts, 0, 51))
|
||||
>name : Symbol(name, Decl(contextualTyping20.ts, 0, 56))
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping20.ts ===
|
||||
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}];
|
||||
>foo : { id: number; }[]
|
||||
>id : number
|
||||
>[{id:1}] : { id: number; }[]
|
||||
>{id:1} : { id: number; }
|
||||
>id : number
|
||||
>1 : number
|
||||
>foo = [{id:1}, {id:2, name:"foo"}] : { id: number; }[]
|
||||
>foo : { id: number; }[]
|
||||
>[{id:1}, {id:2, name:"foo"}] : { id: number; }[]
|
||||
>{id:1} : { id: number; }
|
||||
>id : number
|
||||
>1 : number
|
||||
>{id:2, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>2 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '(number | { id: number; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type 'number | { id: number; }' is not assignable to type '{ id: number; }'.
|
||||
tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type '{ id: number; } | number' is not assignable to type '{ id: number; }'.
|
||||
Type 'number' is not assignable to type '{ id: number; }'.
|
||||
Property 'id' is missing in type 'Number'.
|
||||
|
||||
@@ -7,7 +7,7 @@ tests/cases/compiler/contextualTyping21.ts(1,36): error TS2322: Type '(number |
|
||||
==== tests/cases/compiler/contextualTyping21.ts (1 errors) ====
|
||||
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, 1];
|
||||
~~~
|
||||
!!! error TS2322: Type '(number | { id: number; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
!!! error TS2322: Type 'number | { id: number; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Type '({ id: number; } | number)[]' is not assignable to type '{ id: number; }[]'.
|
||||
!!! error TS2322: Type '{ id: number; } | number' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Property 'id' is missing in type 'Number'.
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
|
||||
Type 'string | number' is not assignable to type 'number'.
|
||||
tests/cases/compiler/contextualTyping30.ts(1,37): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'.
|
||||
Type 'number | string' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping30.ts (1 errors) ====
|
||||
function foo(param:number[]){}; foo([1, "a"]);
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
|
||||
!!! error TS2345: Type 'string | number' is not assignable to type 'number'.
|
||||
!!! error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'.
|
||||
!!! error TS2345: Type 'number | string' is not assignable to type 'number'.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
@@ -3,7 +3,7 @@ var foo = <{ id: number; }[]>[{ foo: "s" }, { }];
|
||||
>foo : { id: number; }[]
|
||||
><{ id: number; }[]>[{ foo: "s" }, { }] : { id: number; }[]
|
||||
>id : number
|
||||
>[{ foo: "s" }, { }] : {}[]
|
||||
>[{ foo: "s" }, { }] : ({ foo: string; } | {})[]
|
||||
>{ foo: "s" } : { foo: string; }
|
||||
>foo : string
|
||||
>"s" : string
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/contextualTyping4.ts(1,13): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping4.ts (1 errors) ====
|
||||
class foo { public bar:{id:number;} = {id:5, name:"foo"}; }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,8 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping4.ts ===
|
||||
class foo { public bar:{id:number;} = {id:5, name:"foo"}; }
|
||||
>foo : Symbol(foo, Decl(contextualTyping4.ts, 0, 0))
|
||||
>bar : Symbol(bar, Decl(contextualTyping4.ts, 0, 11))
|
||||
>id : Symbol(id, Decl(contextualTyping4.ts, 0, 24))
|
||||
>id : Symbol(id, Decl(contextualTyping4.ts, 0, 39))
|
||||
>name : Symbol(name, Decl(contextualTyping4.ts, 0, 44))
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping4.ts ===
|
||||
class foo { public bar:{id:number;} = {id:5, name:"foo"}; }
|
||||
>foo : foo
|
||||
>bar : { id: number; }
|
||||
>id : number
|
||||
>{id:5, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>5 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping9.ts (1 errors) ====
|
||||
var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}];
|
||||
~~~
|
||||
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
|
||||
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
|
||||
@@ -1,8 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping9.ts ===
|
||||
var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}];
|
||||
>foo : Symbol(foo, Decl(contextualTyping9.ts, 0, 3))
|
||||
>id : Symbol(id, Decl(contextualTyping9.ts, 0, 9))
|
||||
>id : Symbol(id, Decl(contextualTyping9.ts, 0, 27))
|
||||
>id : Symbol(id, Decl(contextualTyping9.ts, 0, 35))
|
||||
>name : Symbol(name, Decl(contextualTyping9.ts, 0, 40))
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
=== tests/cases/compiler/contextualTyping9.ts ===
|
||||
var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}];
|
||||
>foo : { id: number; }[]
|
||||
>id : number
|
||||
>[{id:1}, {id:2, name:"foo"}] : { id: number; }[]
|
||||
>{id:1} : { id: number; }
|
||||
>id : number
|
||||
>1 : number
|
||||
>{id:2, name:"foo"} : { id: number; name: string; }
|
||||
>id : number
|
||||
>2 : number
|
||||
>name : string
|
||||
>"foo" : string
|
||||
|
||||
@@ -23,8 +23,8 @@ class C extends A {
|
||||
}
|
||||
|
||||
var xs = [(x: A) => { }, (x: B) => { }, (x: C) => { }];
|
||||
>xs : ((x: A) => void)[]
|
||||
>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : ((x: A) => void)[]
|
||||
>xs : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[]
|
||||
>[(x: A) => { }, (x: B) => { }, (x: C) => { }] : (((x: A) => void) | ((x: B) => void) | ((x: C) => void))[]
|
||||
>(x: A) => { } : (x: A) => void
|
||||
>x : A
|
||||
>A : A
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type '(number | Date)[]' is not assignable to type 'I'.
|
||||
tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Type '(Date | number)[]' is not assignable to type 'I'.
|
||||
Index signatures are incompatible.
|
||||
Type 'number | Date' is not assignable to type 'Date'.
|
||||
Type 'Date | number' is not assignable to type 'Date'.
|
||||
Type 'number' is not assignable to type 'Date'.
|
||||
Property 'toDateString' is missing in type 'Number'.
|
||||
|
||||
@@ -12,9 +12,9 @@ tests/cases/compiler/contextualTypingOfArrayLiterals1.ts(5,5): error TS2322: Typ
|
||||
|
||||
var x3: I = [new Date(), 1];
|
||||
~~
|
||||
!!! error TS2322: Type '(number | Date)[]' is not assignable to type 'I'.
|
||||
!!! error TS2322: Type '(Date | number)[]' is not assignable to type 'I'.
|
||||
!!! error TS2322: Index signatures are incompatible.
|
||||
!!! error TS2322: Type 'number | Date' is not assignable to type 'Date'.
|
||||
!!! error TS2322: Type 'Date | number' is not assignable to type 'Date'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'Date'.
|
||||
!!! error TS2322: Property 'toDateString' is missing in type 'Number'.
|
||||
var r2 = x3[1];
|
||||
|
||||
@@ -29,4 +29,4 @@ declare class c {
|
||||
declare var x: (() => c)[];
|
||||
declare var y: (() => c)[];
|
||||
declare var k: (() => c) | string;
|
||||
declare var l: string | (() => c);
|
||||
declare var l: (() => c) | string;
|
||||
|
||||
@@ -23,9 +23,9 @@ var y = [() => new c()];
|
||||
>c : typeof c
|
||||
|
||||
var k: (() => c) | string = (() => new c()) || "";
|
||||
>k : string | (() => c)
|
||||
>k : (() => c) | string
|
||||
>c : c
|
||||
>(() => new c()) || "" : string | (() => c)
|
||||
>(() => new c()) || "" : (() => c) | string
|
||||
>(() => new c()) : () => c
|
||||
>() => new c() : () => c
|
||||
>new c() : c
|
||||
@@ -33,8 +33,8 @@ var k: (() => c) | string = (() => new c()) || "";
|
||||
>"" : string
|
||||
|
||||
var l = (() => new c()) || "";
|
||||
>l : string | (() => c)
|
||||
>(() => new c()) || "" : string | (() => c)
|
||||
>l : (() => c) | string
|
||||
>(() => new c()) || "" : (() => c) | string
|
||||
>(() => new c()) : () => c
|
||||
>() => new c() : () => c
|
||||
>new c() : c
|
||||
|
||||
@@ -47,7 +47,7 @@ module M {
|
||||
>M : typeof M
|
||||
|
||||
export type W = Window | string;
|
||||
>W : string | Window
|
||||
>W : Window | string
|
||||
>Window : Window
|
||||
|
||||
export module N {
|
||||
@@ -57,7 +57,7 @@ module M {
|
||||
>Window : Window
|
||||
|
||||
export var p: W;
|
||||
>p : string | Window
|
||||
>W : string | Window
|
||||
>p : Window | string
|
||||
>W : Window | string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,4 +15,4 @@ function foo(_a) {
|
||||
|
||||
//// [declarationEmitDestructuring3.d.ts]
|
||||
declare function bar([x, z, ...w]: any[]): void;
|
||||
declare function foo([x, ...y]?: (string | number | boolean)[]): void;
|
||||
declare function foo([x, ...y]?: (number | string | boolean)[]): void;
|
||||
|
||||
@@ -6,10 +6,10 @@ function bar([x, z, ...w]) { }
|
||||
>w : any[]
|
||||
|
||||
function foo([x, ...y] = [1, "string", true]) { }
|
||||
>foo : ([x, ...y]?: (string | number | boolean)[]) => void
|
||||
>x : string | number | boolean
|
||||
>y : (string | number | boolean)[]
|
||||
>[1, "string", true] : (string | number | boolean)[]
|
||||
>foo : ([x, ...y]?: (number | string | boolean)[]) => void
|
||||
>x : number | string | boolean
|
||||
>y : (number | string | boolean)[]
|
||||
>[1, "string", true] : (number | string | boolean)[]
|
||||
>1 : number
|
||||
>"string" : string
|
||||
>true : boolean
|
||||
|
||||
@@ -23,6 +23,6 @@ var x3 = a[0], y3 = a[1], z3 = a[2]; // emit x3, y3, z3
|
||||
declare var x: number;
|
||||
declare var x1: number, y1: string;
|
||||
declare var z1: number;
|
||||
declare var a: (string | number)[];
|
||||
declare var x2: string | number;
|
||||
declare var x3: string | number, y3: string | number, z3: string | number;
|
||||
declare var a: (number | string)[];
|
||||
declare var x2: number | string;
|
||||
declare var x3: number | string, y3: number | string, z3: number | string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
=== tests/cases/compiler/declarationEmitDestructuringArrayPattern1.ts ===
|
||||
|
||||
var [] = [1, "hello"]; // Dont emit anything
|
||||
>[1, "hello"] : (string | number)[]
|
||||
>[1, "hello"] : (number | string)[]
|
||||
>1 : number
|
||||
>"hello" : string
|
||||
|
||||
@@ -28,18 +28,18 @@ var [, , z1] = [0, 1, 2]; // emit z1: number
|
||||
>2 : number
|
||||
|
||||
var a = [1, "hello"];
|
||||
>a : (string | number)[]
|
||||
>[1, "hello"] : (string | number)[]
|
||||
>a : (number | string)[]
|
||||
>[1, "hello"] : (number | string)[]
|
||||
>1 : number
|
||||
>"hello" : string
|
||||
|
||||
var [x2] = a; // emit x2: number | string
|
||||
>x2 : string | number
|
||||
>a : (string | number)[]
|
||||
>x2 : number | string
|
||||
>a : (number | string)[]
|
||||
|
||||
var [x3, y3, z3] = a; // emit x3, y3, z3
|
||||
>x3 : string | number
|
||||
>y3 : string | number
|
||||
>z3 : string | number
|
||||
>a : (string | number)[]
|
||||
>x3 : number | string
|
||||
>y3 : number | string
|
||||
>z3 : number | string
|
||||
>a : (number | string)[]
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ declare var x11: number, y11: string;
|
||||
declare var a11: any, b11: any, c11: any;
|
||||
declare var a2: number, b2: string, x12: number, c2: boolean;
|
||||
declare var x13: number, y13: string;
|
||||
declare var a3: (string | number)[], b3: {
|
||||
declare var a3: (number | string)[], b3: {
|
||||
x: number;
|
||||
y: string;
|
||||
};
|
||||
|
||||
@@ -56,10 +56,10 @@ var [x13, y13] = [1, "hello"];
|
||||
>"hello" : string
|
||||
|
||||
var [a3, b3] = [[x13, y13], { x: x13, y: y13 }];
|
||||
>a3 : (string | number)[]
|
||||
>a3 : (number | string)[]
|
||||
>b3 : { x: number; y: string; }
|
||||
>[[x13, y13], { x: x13, y: y13 }] : [(string | number)[], { x: number; y: string; }]
|
||||
>[x13, y13] : (string | number)[]
|
||||
>[[x13, y13], { x: x13, y: y13 }] : [(number | string)[], { x: number; y: string; }]
|
||||
>[x13, y13] : (number | string)[]
|
||||
>x13 : number
|
||||
>y13 : string
|
||||
>{ x: x13, y: y13 } : { x: number; y: string; }
|
||||
|
||||
@@ -25,7 +25,7 @@ declare var a5: number[];
|
||||
declare var x14: number, a6: number[];
|
||||
declare var x15: number, y15: number, a7: number[];
|
||||
declare var x16: number, y16: number, z16: number, a8: number[];
|
||||
declare var a9: (string | number | boolean)[];
|
||||
declare var x17: string | number | boolean, a10: (string | number | boolean)[];
|
||||
declare var x18: string | number | boolean, y18: string | number | boolean, a12: (string | number | boolean)[];
|
||||
declare var x19: string | number | boolean, y19: string | number | boolean, z19: string | number | boolean, a13: (string | number | boolean)[];
|
||||
declare var a9: (number | string | boolean)[];
|
||||
declare var x17: number | string | boolean, a10: (number | string | boolean)[];
|
||||
declare var x18: number | string | boolean, y18: number | string | boolean, a12: (number | string | boolean)[];
|
||||
declare var x19: number | string | boolean, y19: number | string | boolean, z19: number | string | boolean, a13: (number | string | boolean)[];
|
||||
|
||||
@@ -34,35 +34,35 @@ var [x16, y16, z16, ...a8] = [1, 2, 3];
|
||||
>3 : number
|
||||
|
||||
var [...a9] = [1, "hello", true];
|
||||
>a9 : (string | number | boolean)[]
|
||||
>[1, "hello", true] : (string | number | boolean)[]
|
||||
>a9 : (number | string | boolean)[]
|
||||
>[1, "hello", true] : (number | string | boolean)[]
|
||||
>1 : number
|
||||
>"hello" : string
|
||||
>true : boolean
|
||||
|
||||
var [x17, ...a10] = [1, "hello", true];
|
||||
>x17 : string | number | boolean
|
||||
>a10 : (string | number | boolean)[]
|
||||
>[1, "hello", true] : (string | number | boolean)[]
|
||||
>x17 : number | string | boolean
|
||||
>a10 : (number | string | boolean)[]
|
||||
>[1, "hello", true] : (number | string | boolean)[]
|
||||
>1 : number
|
||||
>"hello" : string
|
||||
>true : boolean
|
||||
|
||||
var [x18, y18, ...a12] = [1, "hello", true];
|
||||
>x18 : string | number | boolean
|
||||
>y18 : string | number | boolean
|
||||
>a12 : (string | number | boolean)[]
|
||||
>[1, "hello", true] : (string | number | boolean)[]
|
||||
>x18 : number | string | boolean
|
||||
>y18 : number | string | boolean
|
||||
>a12 : (number | string | boolean)[]
|
||||
>[1, "hello", true] : (number | string | boolean)[]
|
||||
>1 : number
|
||||
>"hello" : string
|
||||
>true : boolean
|
||||
|
||||
var [x19, y19, z19, ...a13] = [1, "hello", true];
|
||||
>x19 : string | number | boolean
|
||||
>y19 : string | number | boolean
|
||||
>z19 : string | number | boolean
|
||||
>a13 : (string | number | boolean)[]
|
||||
>[1, "hello", true] : (string | number | boolean)[]
|
||||
>x19 : number | string | boolean
|
||||
>y19 : number | string | boolean
|
||||
>z19 : number | string | boolean
|
||||
>a13 : (number | string | boolean)[]
|
||||
>[1, "hello", true] : (number | string | boolean)[]
|
||||
>1 : number
|
||||
>"hello" : string
|
||||
>true : boolean
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts(14,28): error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'.
|
||||
Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts (1 errors) ====
|
||||
class Base {
|
||||
foo(x: { a: number }): { a: number } {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
foo(x: { a: number; b: number }): { a: number; b: number } {
|
||||
return null;
|
||||
}
|
||||
|
||||
bar() {
|
||||
var r = super.foo({ a: 1 }); // { a: number }
|
||||
var r2 = super.foo({ a: 1, b: 2 }); // { a: number }
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ a: number; b: number; }' is not assignable to parameter of type '{ a: number; }'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
|
||||
var r3 = this.foo({ a: 1, b: 2 }); // { a: number; b: number; }
|
||||
}
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
=== tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts ===
|
||||
class Base {
|
||||
>Base : Symbol(Base, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 0))
|
||||
|
||||
foo(x: { a: number }): { a: number } {
|
||||
>foo : Symbol(foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 12))
|
||||
>x : Symbol(x, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 1, 8))
|
||||
>a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 1, 12))
|
||||
>a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 1, 28))
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
>Derived : Symbol(Derived, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 4, 1))
|
||||
>Base : Symbol(Base, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 0))
|
||||
|
||||
foo(x: { a: number; b: number }): { a: number; b: number } {
|
||||
>foo : Symbol(foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 6, 28))
|
||||
>x : Symbol(x, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 7, 8))
|
||||
>a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 7, 12))
|
||||
>b : Symbol(b, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 7, 23))
|
||||
>a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 7, 39))
|
||||
>b : Symbol(b, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 7, 50))
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
bar() {
|
||||
>bar : Symbol(bar, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 9, 5))
|
||||
|
||||
var r = super.foo({ a: 1 }); // { a: number }
|
||||
>r : Symbol(r, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 12, 11))
|
||||
>super.foo : Symbol(Base.foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 12))
|
||||
>super : Symbol(Base, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 0))
|
||||
>foo : Symbol(Base.foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 12))
|
||||
>a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 12, 27))
|
||||
|
||||
var r2 = super.foo({ a: 1, b: 2 }); // { a: number }
|
||||
>r2 : Symbol(r2, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 13, 11))
|
||||
>super.foo : Symbol(Base.foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 12))
|
||||
>super : Symbol(Base, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 0))
|
||||
>foo : Symbol(Base.foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 0, 12))
|
||||
>a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 13, 28))
|
||||
>b : Symbol(b, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 13, 34))
|
||||
|
||||
var r3 = this.foo({ a: 1, b: 2 }); // { a: number; b: number; }
|
||||
>r3 : Symbol(r3, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 14, 11))
|
||||
>this.foo : Symbol(foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 6, 28))
|
||||
>this : Symbol(Derived, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 4, 1))
|
||||
>foo : Symbol(foo, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 6, 28))
|
||||
>a : Symbol(a, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 14, 27))
|
||||
>b : Symbol(b, Decl(derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts, 14, 33))
|
||||
}
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
=== tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/derivedTypeAccessesHiddenBaseCallViaSuperPropertyAccess.ts ===
|
||||
class Base {
|
||||
>Base : Base
|
||||
|
||||
foo(x: { a: number }): { a: number } {
|
||||
>foo : (x: { a: number; }) => { a: number; }
|
||||
>x : { a: number; }
|
||||
>a : number
|
||||
>a : number
|
||||
|
||||
return null;
|
||||
>null : null
|
||||
}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
>Derived : Derived
|
||||
>Base : Base
|
||||
|
||||
foo(x: { a: number; b: number }): { a: number; b: number } {
|
||||
>foo : (x: { a: number; b: number; }) => { a: number; b: number; }
|
||||
>x : { a: number; b: number; }
|
||||
>a : number
|
||||
>b : number
|
||||
>a : number
|
||||
>b : number
|
||||
|
||||
return null;
|
||||
>null : null
|
||||
}
|
||||
|
||||
bar() {
|
||||
>bar : () => void
|
||||
|
||||
var r = super.foo({ a: 1 }); // { a: number }
|
||||
>r : { a: number; }
|
||||
>super.foo({ a: 1 }) : { a: number; }
|
||||
>super.foo : (x: { a: number; }) => { a: number; }
|
||||
>super : Base
|
||||
>foo : (x: { a: number; }) => { a: number; }
|
||||
>{ a: 1 } : { a: number; }
|
||||
>a : number
|
||||
>1 : number
|
||||
|
||||
var r2 = super.foo({ a: 1, b: 2 }); // { a: number }
|
||||
>r2 : { a: number; }
|
||||
>super.foo({ a: 1, b: 2 }) : { a: number; }
|
||||
>super.foo : (x: { a: number; }) => { a: number; }
|
||||
>super : Base
|
||||
>foo : (x: { a: number; }) => { a: number; }
|
||||
>{ a: 1, b: 2 } : { a: number; b: number; }
|
||||
>a : number
|
||||
>1 : number
|
||||
>b : number
|
||||
>2 : number
|
||||
|
||||
var r3 = this.foo({ a: 1, b: 2 }); // { a: number; b: number; }
|
||||
>r3 : { a: number; b: number; }
|
||||
>this.foo({ a: 1, b: 2 }) : { a: number; b: number; }
|
||||
>this.foo : (x: { a: number; b: number; }) => { a: number; b: number; }
|
||||
>this : Derived
|
||||
>foo : (x: { a: number; b: number; }) => { a: number; b: number; }
|
||||
>{ a: 1, b: 2 } : { a: number; b: number; }
|
||||
>a : number
|
||||
>1 : number
|
||||
>b : number
|
||||
>2 : number
|
||||
}
|
||||
}
|
||||
@@ -148,8 +148,8 @@ var [,,,...c10] = [1, 2, 3, 4, "hello"];
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
>c10 : (string | number)[]
|
||||
>[1, 2, 3, 4, "hello"] : (string | number)[]
|
||||
>c10 : (number | string)[]
|
||||
>[1, 2, 3, 4, "hello"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
@@ -157,10 +157,10 @@ var [,,,...c10] = [1, 2, 3, 4, "hello"];
|
||||
>"hello" : string
|
||||
|
||||
var [c11, c12, ...c13] = [1, 2, "string"];
|
||||
>c11 : string | number
|
||||
>c12 : string | number
|
||||
>c13 : (string | number)[]
|
||||
>[1, 2, "string"] : (string | number)[]
|
||||
>c11 : number | string
|
||||
>c12 : number | string
|
||||
>c13 : (number | string)[]
|
||||
>[1, 2, "string"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"string" : string
|
||||
|
||||
@@ -149,8 +149,8 @@ var [,,,...c10] = [1, 2, 3, 4, "hello"];
|
||||
> : undefined
|
||||
> : undefined
|
||||
> : undefined
|
||||
>c10 : (string | number)[]
|
||||
>[1, 2, 3, 4, "hello"] : (string | number)[]
|
||||
>c10 : (number | string)[]
|
||||
>[1, 2, 3, 4, "hello"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
@@ -158,10 +158,10 @@ var [,,,...c10] = [1, 2, 3, 4, "hello"];
|
||||
>"hello" : string
|
||||
|
||||
var [c11, c12, ...c13] = [1, 2, "string"];
|
||||
>c11 : string | number
|
||||
>c12 : string | number
|
||||
>c13 : (string | number)[]
|
||||
>[1, 2, "string"] : (string | number)[]
|
||||
>c11 : number | string
|
||||
>c12 : number | string
|
||||
>c13 : (number | string)[]
|
||||
>[1, 2, "string"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>"string" : string
|
||||
|
||||
@@ -4,8 +4,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,29): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(8,4): error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'.
|
||||
Types of property 'pop' are incompatible.
|
||||
Type '() => string | number | string[][]' is not assignable to type '() => number | string[][]'.
|
||||
Type 'string | number | string[][]' is not assignable to type 'number | string[][]'.
|
||||
Type '() => number | string[][] | string' is not assignable to type '() => number | string[][]'.
|
||||
Type 'number | string[][] | string' is not assignable to type 'number | string[][]'.
|
||||
Type 'string' is not assignable to type 'number | string[][]'.
|
||||
Type 'string' is not assignable to type 'string[][]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(16,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
@@ -26,10 +26,10 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(37,4): error TS2345: Argument of type '{ z: boolean; }' is not assignable to parameter of type '{ z?: number; }'.
|
||||
Types of property 'z' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,4): error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,4): error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: number | string; }'.
|
||||
Types of property 'b' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'string | number'.
|
||||
Type 'boolean' is not assignable to type 'number'.
|
||||
Type 'boolean' is not assignable to type 'number | string'.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,4): error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
Types of property '2' are incompatible.
|
||||
Type 'boolean' is not assignable to type '[[any]]'.
|
||||
@@ -73,8 +73,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'.
|
||||
!!! error TS2345: Types of property 'pop' are incompatible.
|
||||
!!! error TS2345: Type '() => string | number | string[][]' is not assignable to type '() => number | string[][]'.
|
||||
!!! error TS2345: Type 'string | number | string[][]' is not assignable to type 'number | string[][]'.
|
||||
!!! error TS2345: Type '() => number | string[][] | string' is not assignable to type '() => number | string[][]'.
|
||||
!!! error TS2345: Type 'number | string[][] | string' is not assignable to type 'number | string[][]'.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number | string[][]'.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'string[][]'.
|
||||
|
||||
@@ -135,10 +135,10 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.
|
||||
c3({ b: true }); // Error, implied type is { b: number|string }.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: string | number; }'.
|
||||
!!! error TS2345: Argument of type '{ b: boolean; }' is not assignable to parameter of type '{ b: number | string; }'.
|
||||
!!! error TS2345: Types of property 'b' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string | number'.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'number | string'.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
|
||||
c5([1, 2, false, true]); // Error, implied type is [any, any, [[any]]]
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, number, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
|
||||
@@ -23,8 +23,8 @@ type stringOrNumArray = Array<String|Number>;
|
||||
>Number : Number
|
||||
|
||||
function a1(...x: (number|string)[]) { }
|
||||
>a1 : (...x: (string | number)[]) => void
|
||||
>x : (string | number)[]
|
||||
>a1 : (...x: (number | string)[]) => void
|
||||
>x : (number | string)[]
|
||||
|
||||
function a2(...a) { }
|
||||
>a2 : (...a: any[]) => void
|
||||
@@ -75,8 +75,8 @@ var array = [1, 2, 3];
|
||||
>3 : number
|
||||
|
||||
var array2 = [true, false, "hello"];
|
||||
>array2 : (string | boolean)[]
|
||||
>[true, false, "hello"] : (string | boolean)[]
|
||||
>array2 : (boolean | string)[]
|
||||
>[true, false, "hello"] : (boolean | string)[]
|
||||
>true : boolean
|
||||
>false : boolean
|
||||
>"hello" : string
|
||||
@@ -90,7 +90,7 @@ a2([...array]);
|
||||
|
||||
a1(...array);
|
||||
>a1(...array) : void
|
||||
>a1 : (...x: (string | number)[]) => void
|
||||
>a1 : (...x: (number | string)[]) => void
|
||||
>...array : number
|
||||
>array : number[]
|
||||
|
||||
@@ -109,7 +109,7 @@ a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]
|
||||
a10([1, 2, [["string"]], false, true]); // Parameter type is any[]
|
||||
>a10([1, 2, [["string"]], false, true]) : void
|
||||
>a10 : ([a, b, [[c]], ...x]: Iterable<any>) => void
|
||||
>[1, 2, [["string"]], false, true] : (number | boolean | string[][])[]
|
||||
>[1, 2, [["string"]], false, true] : (number | string[][] | boolean)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>[["string"]] : string[][]
|
||||
|
||||
@@ -23,8 +23,8 @@ type stringOrNumArray = Array<String|Number>;
|
||||
>Number : Number
|
||||
|
||||
function a1(...x: (number|string)[]) { }
|
||||
>a1 : (...x: (string | number)[]) => void
|
||||
>x : (string | number)[]
|
||||
>a1 : (...x: (number | string)[]) => void
|
||||
>x : (number | string)[]
|
||||
|
||||
function a2(...a) { }
|
||||
>a2 : (...a: any[]) => void
|
||||
@@ -75,8 +75,8 @@ var array = [1, 2, 3];
|
||||
>3 : number
|
||||
|
||||
var array2 = [true, false, "hello"];
|
||||
>array2 : (string | boolean)[]
|
||||
>[true, false, "hello"] : (string | boolean)[]
|
||||
>array2 : (boolean | string)[]
|
||||
>[true, false, "hello"] : (boolean | string)[]
|
||||
>true : boolean
|
||||
>false : boolean
|
||||
>"hello" : string
|
||||
@@ -90,7 +90,7 @@ a2([...array]);
|
||||
|
||||
a1(...array);
|
||||
>a1(...array) : void
|
||||
>a1 : (...x: (string | number)[]) => void
|
||||
>a1 : (...x: (number | string)[]) => void
|
||||
>...array : number
|
||||
>array : number[]
|
||||
|
||||
@@ -109,7 +109,7 @@ a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]]
|
||||
a10([1, 2, [["string"]], false, true]); // Parameter type is any[]
|
||||
>a10([1, 2, [["string"]], false, true]) : void
|
||||
>a10 : ([a, b, [[c]], ...x]: Iterable<any>) => void
|
||||
>[1, 2, [["string"]], false, true] : (number | boolean | string[][])[]
|
||||
>[1, 2, [["string"]], false, true] : (number | string[][] | boolean)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>[["string"]] : string[][]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(11,13): error TS2370: A rest parameter must be of an array type.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(13,13): error TS2370: A rest parameter must be of an array type.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'.
|
||||
Type 'boolean' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number | string'.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2304: Cannot find name 'array2'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
Types of property '2' are incompatible.
|
||||
@@ -9,8 +9,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
|
||||
Property '0' is missing in type 'String'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(23,4): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'.
|
||||
Property '2' is missing in type '[number, number]'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
|
||||
Type 'string | number' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(24,4): error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'.
|
||||
Type 'number | string' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(29,24): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(34,22): error TS2304: Cannot find name 'E1'.
|
||||
@@ -43,8 +43,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
|
||||
|
||||
a1(1, 2, "hello", true); // Error, parameter type is (number|string)[]
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'number'.
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number | string'.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
|
||||
a1(...array2); // Error parameter type is (number|string)[]
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'array2'.
|
||||
@@ -60,8 +60,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
|
||||
!!! error TS2345: Property '2' is missing in type '[number, number]'.
|
||||
a6([1, 2, "string"]); // Error, parameter type is number[]
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
|
||||
!!! error TS2345: Type 'string | number' is not assignable to type 'number'.
|
||||
!!! error TS2345: Argument of type '(number | string)[]' is not assignable to parameter of type 'number[]'.
|
||||
!!! error TS2345: Type 'number | string' is not assignable to type 'number'.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,16): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'.
|
||||
Types of property '0' are incompatible.
|
||||
Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'.
|
||||
Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'.
|
||||
Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (10 errors) ====
|
||||
@@ -47,5 +47,5 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1
|
||||
!!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'.
|
||||
!!! error TS2345: Types of property '0' are incompatible.
|
||||
!!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'.
|
||||
!!! error TS2345: Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'.
|
||||
var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z];
|
||||
@@ -84,8 +84,8 @@ var [...c1] = [1,2,3];
|
||||
>3 : number
|
||||
|
||||
var [...c2] = [1,2,3, "string"];
|
||||
>c2 : (string | number)[]
|
||||
>[1,2,3, "string"] : (string | number)[]
|
||||
>c2 : (number | string)[]
|
||||
>[1,2,3, "string"] : (number | string)[]
|
||||
>1 : number
|
||||
>2 : number
|
||||
>3 : number
|
||||
@@ -113,9 +113,9 @@ var temp1 = [true, false, true]
|
||||
>true : boolean
|
||||
|
||||
var [d3, d4] = [1, "string", ...temp1];
|
||||
>d3 : string | number | boolean
|
||||
>d4 : string | number | boolean
|
||||
>[1, "string", ...temp1] : (string | number | boolean)[]
|
||||
>d3 : number | string | boolean
|
||||
>d4 : number | string | boolean
|
||||
>[1, "string", ...temp1] : (number | string | boolean)[]
|
||||
>1 : number
|
||||
>"string" : string
|
||||
>...temp1 : boolean
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user