diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6e45ea4f4e5..46d50d3d24c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4340,7 +4340,7 @@ module ts { var widenedType = getWidenedType(exprType, /*supressNoImplicitAnyErrors*/ true); if (!(isTypeAssignableTo(targetType, widenedType))) { checkTypeAssignableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); - } + } } return targetType; } diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates3.errors.txt b/tests/baselines/reference/objectTypesIdentityWithPrivates3.errors.txt new file mode 100644 index 00000000000..590c1cbe7fa --- /dev/null +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates3.errors.txt @@ -0,0 +1,29 @@ +==== tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithPrivates3.ts (1 errors) ==== + interface T1 { } + interface T2 { z } + + class C1 { + private x; + } + + class C2 extends C1 { + y; + } + + var c1: C1; + c1; // Should succeed (private x originates in the same declaration) + + + class C3 { + private x: T; // This T is the difference between C3 and C1 + } + + class C4 extends C3 { + y; + } + + var c3: C3; + c3; // Should fail (private x originates in the same declaration, but different types) + ~~~~~~ +!!! Neither type 'C3' nor type 'C4' is assignable to the other: +!!! Property 'y' is missing in type 'C3'. \ No newline at end of file diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates3.js b/tests/baselines/reference/objectTypesIdentityWithPrivates3.js index bc71d791a61..7c8dac97250 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates3.js +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates3.js @@ -11,7 +11,19 @@ class C2 extends C1 { } var c1: C1; -c1; // Should succeed (private x originates in the same declaration) +c1; // Should succeed (private x originates in the same declaration) + + +class C3 { + private x: T; // This T is the difference between C3 and C1 +} + +class C4 extends C3 { + y; +} + +var c3: C3; +c3; // Should fail (private x originates in the same declaration, but different types) //// [objectTypesIdentityWithPrivates3.js] var __extends = this.__extends || function (d, b) { @@ -34,3 +46,17 @@ var C2 = (function (_super) { })(C1); var c1; c1; // Should succeed (private x originates in the same declaration) +var C3 = (function () { + function C3() { + } + return C3; +})(); +var C4 = (function (_super) { + __extends(C4, _super); + function C4() { + _super.apply(this, arguments); + } + return C4; +})(C3); +var c3; +c3; // Should fail (private x originates in the same declaration, but different types) diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates3.types b/tests/baselines/reference/objectTypesIdentityWithPrivates3.types deleted file mode 100644 index d770ededf8c..00000000000 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates3.types +++ /dev/null @@ -1,35 +0,0 @@ -=== tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithPrivates3.ts === -interface T1 { } ->T1 : T1 - -interface T2 { z } ->T2 : T2 ->z : any - -class C1 { ->C1 : C1 ->T : T - - private x; ->x : any -} - -class C2 extends C1 { ->C2 : C2 ->C1 : C1 ->T1 : T1 - - y; ->y : any -} - -var c1: C1; ->c1 : C1 ->C1 : C1 ->T2 : T2 - -c1; // Should succeed (private x originates in the same declaration) ->c1 : C2 ->C2 : C2 ->c1 : C1 - diff --git a/tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithPrivates3.ts b/tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithPrivates3.ts index 1d6997f1a4a..fa3a2ae996a 100644 --- a/tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithPrivates3.ts +++ b/tests/cases/conformance/types/typeRelationships/typeAndMemberIdentity/objectTypesIdentityWithPrivates3.ts @@ -10,4 +10,16 @@ class C2 extends C1 { } var c1: C1; -c1; // Should succeed (private x originates in the same declaration) \ No newline at end of file +c1; // Should succeed (private x originates in the same declaration) + + +class C3 { + private x: T; // This T is the difference between C3 and C1 +} + +class C4 extends C3 { + y; +} + +var c3: C3; +c3; // Should fail (private x originates in the same declaration, but different types) \ No newline at end of file