diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b1559f8dd13..f8c4caa9630 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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: @@ -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 { diff --git a/tests/baselines/reference/genericAndNonGenericInheritedSignature1.errors.txt b/tests/baselines/reference/genericAndNonGenericInheritedSignature1.errors.txt new file mode 100644 index 00000000000..63ff9d9313e --- /dev/null +++ b/tests/baselines/reference/genericAndNonGenericInheritedSignature1.errors.txt @@ -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(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. + } + \ No newline at end of file diff --git a/tests/baselines/reference/genericAndNonGenericInheritedSignature1.js b/tests/baselines/reference/genericAndNonGenericInheritedSignature1.js new file mode 100644 index 00000000000..15ea71b1223 --- /dev/null +++ b/tests/baselines/reference/genericAndNonGenericInheritedSignature1.js @@ -0,0 +1,12 @@ +//// [genericAndNonGenericInheritedSignature1.ts] +interface Foo { + f(x: any): any; +} +interface Bar { + f(x: T): T; +} +interface Hello extends Foo, Bar { +} + + +//// [genericAndNonGenericInheritedSignature1.js] diff --git a/tests/baselines/reference/genericAndNonGenericInheritedSignature2.errors.txt b/tests/baselines/reference/genericAndNonGenericInheritedSignature2.errors.txt new file mode 100644 index 00000000000..05fdd68319e --- /dev/null +++ b/tests/baselines/reference/genericAndNonGenericInheritedSignature2.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/genericAndNonGenericInheritedSignature2.ts(7,11): error TS2320: Interface 'Hello' cannot simultaneously extend types 'Bar' and 'Foo'. + Named properties 'f' of types 'Bar' and 'Foo' are not identical. + + +==== tests/cases/compiler/genericAndNonGenericInheritedSignature2.ts (1 errors) ==== + interface Foo { + f(x: any): any; + } + interface Bar { + f(x: T): T; + } + interface Hello extends Bar, Foo { + ~~~~~ +!!! error TS2320: Interface 'Hello' cannot simultaneously extend types 'Bar' and 'Foo'. +!!! error TS2320: Named properties 'f' of types 'Bar' and 'Foo' are not identical. + } + \ No newline at end of file diff --git a/tests/baselines/reference/genericAndNonGenericInheritedSignature2.js b/tests/baselines/reference/genericAndNonGenericInheritedSignature2.js new file mode 100644 index 00000000000..d8353b81e98 --- /dev/null +++ b/tests/baselines/reference/genericAndNonGenericInheritedSignature2.js @@ -0,0 +1,12 @@ +//// [genericAndNonGenericInheritedSignature2.ts] +interface Foo { + f(x: any): any; +} +interface Bar { + f(x: T): T; +} +interface Hello extends Bar, Foo { +} + + +//// [genericAndNonGenericInheritedSignature2.js] diff --git a/tests/cases/compiler/genericAndNonGenericInheritedSignature1.ts b/tests/cases/compiler/genericAndNonGenericInheritedSignature1.ts new file mode 100644 index 00000000000..3e5aa480be4 --- /dev/null +++ b/tests/cases/compiler/genericAndNonGenericInheritedSignature1.ts @@ -0,0 +1,8 @@ +interface Foo { + f(x: any): any; +} +interface Bar { + f(x: T): T; +} +interface Hello extends Foo, Bar { +} diff --git a/tests/cases/compiler/genericAndNonGenericInheritedSignature2.ts b/tests/cases/compiler/genericAndNonGenericInheritedSignature2.ts new file mode 100644 index 00000000000..f35e2ffda98 --- /dev/null +++ b/tests/cases/compiler/genericAndNonGenericInheritedSignature2.ts @@ -0,0 +1,8 @@ +interface Foo { + f(x: any): any; +} +interface Bar { + f(x: T): T; +} +interface Hello extends Bar, Foo { +}