mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-12 20:01:02 -05:00
Fixed issue where the second type's signature having type parameters would not cause an error.
This commit is contained in:
@@ -4016,7 +4016,7 @@ module ts {
|
||||
result &= related;
|
||||
}
|
||||
}
|
||||
else if (source.typeParameters || source.typeParameters) {
|
||||
else if (source.typeParameters || target.typeParameters) {
|
||||
return Ternary.False;
|
||||
}
|
||||
// Spec 1.0 Section 3.8.3 & 3.8.4:
|
||||
@@ -5244,8 +5244,8 @@ module ts {
|
||||
// Return the contextual signature for a given expression node. A contextual type provides a
|
||||
// contextual signature if it has a single call signature and if that call signature is non-generic.
|
||||
// If the contextual type is a union type, get the signature from each type possible and if they are
|
||||
// all identical ignoring their return type, the result is same signature but with return type as
|
||||
// union type of return types from these signatures
|
||||
// all identical ignoring their return type, the result is same signature but with a union type of
|
||||
// the return types of these signatures
|
||||
function getContextualSignature(node: FunctionExpression | MethodDeclaration): Signature {
|
||||
Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node));
|
||||
var type = isObjectLiteralMethod(node)
|
||||
@@ -5274,7 +5274,7 @@ module ts {
|
||||
signatureList = [signature];
|
||||
}
|
||||
else if (!compareSignatures(signatureList[0], signature, /*compareReturnTypes*/ false, compareTypes)) {
|
||||
// Signatures arent identical, do not use
|
||||
// Signatures aren't identical, do not use
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
tests/cases/compiler/genericAndNonGenericInheritedSignature1.ts(7,11): error TS2320: Interface 'Hello' cannot simultaneously extend types 'Foo' and 'Bar'.
|
||||
Named properties 'f' of types 'Foo' and 'Bar' are not identical.
|
||||
|
||||
|
||||
==== tests/cases/compiler/genericAndNonGenericInheritedSignature1.ts (1 errors) ====
|
||||
interface Foo {
|
||||
f(x: any): any;
|
||||
}
|
||||
interface Bar {
|
||||
f<T>(x: T): T;
|
||||
}
|
||||
interface Hello extends Foo, Bar {
|
||||
~~~~~
|
||||
!!! error TS2320: Interface 'Hello' cannot simultaneously extend types 'Foo' and 'Bar'.
|
||||
!!! error TS2320: Named properties 'f' of types 'Foo' and 'Bar' are not identical.
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
=== tests/cases/compiler/genericAndNonGenericInheritedSignature1.ts ===
|
||||
interface Foo {
|
||||
>Foo : Foo
|
||||
|
||||
f(x: any): any;
|
||||
>f : (x: any) => any
|
||||
>x : any
|
||||
}
|
||||
interface Bar {
|
||||
>Bar : Bar
|
||||
|
||||
f<T>(x: T): T;
|
||||
>f : <T>(x: T) => T
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
}
|
||||
interface Hello extends Foo, Bar {
|
||||
>Hello : Hello
|
||||
>Foo : Foo
|
||||
>Bar : Bar
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user