Skip to content

Commit 0b911d5

Browse files
committed
Improve comments in source and tests
1 parent 4b1f1b6 commit 0b911d5

File tree

7 files changed

+44
-43
lines changed

7 files changed

+44
-43
lines changed

src/compiler/checker.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8981,10 +8981,6 @@ namespace ts {
89818981
function typeRelatedToEachType(source: Type, target: IntersectionType, reportErrors: boolean): Ternary {
89828982
let result = Ternary.True;
89838983
const targetTypes = target.types;
8984-
// disable weak-type detection for the main check
8985-
// unless all of target.types are weak, in which case run weak type detection on the *combined* properties of target
8986-
// at a minimum, do the first part.
8987-
// but the thing should be flexible enough to easily do the second part as a separate call
89888984
const saveDynamicDisableWeakTypeErrors = dynamicDisableWeakTypeErrors;
89898985
dynamicDisableWeakTypeErrors = true;
89908986
for (const targetType of targetTypes) {

tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.errors.txt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
44
Weak type 'C' has no properties in common with 'E'.
55
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(35,5): error TS2322: Type 'F' is not assignable to type 'C'.
66
Weak type 'C' has no properties in common with 'F'.
7-
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(38,5): error TS2322: Type 'D' is not assignable to type '{ opt?: Base; }'.
7+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(36,5): error TS2322: Type 'D' is not assignable to type '{ opt?: Base; }'.
88
Weak type '{ opt?: Base; }' has no properties in common with 'D'.
9-
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(39,5): error TS2322: Type 'E' is not assignable to type '{ opt?: Base; }'.
9+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(37,5): error TS2322: Type 'E' is not assignable to type '{ opt?: Base; }'.
1010
Weak type '{ opt?: Base; }' has no properties in common with 'E'.
11-
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(40,5): error TS2322: Type 'F' is not assignable to type '{ opt?: Base; }'.
11+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(38,5): error TS2322: Type 'F' is not assignable to type '{ opt?: Base; }'.
1212
Weak type '{ opt?: Base; }' has no properties in common with 'F'.
13-
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(43,5): error TS2322: Type 'D' is not assignable to type '{ opt?: Base; }'.
14-
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(44,5): error TS2322: Type 'E' is not assignable to type '{ opt?: Base; }'.
15-
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(45,5): error TS2322: Type 'F' is not assignable to type '{ opt?: Base; }'.
13+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(39,5): error TS2322: Type 'D' is not assignable to type '{ opt?: Base; }'.
14+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(40,5): error TS2322: Type 'E' is not assignable to type '{ opt?: Base; }'.
15+
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(41,5): error TS2322: Type 'F' is not assignable to type '{ opt?: Base; }'.
1616
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(74,5): error TS2322: Type 'D' is not assignable to type 'C'.
1717
Property 'opt' is missing in type 'D'.
1818
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts(75,5): error TS2322: Type 'E' is not assignable to type 'C'.
@@ -65,7 +65,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
6565
var e: E;
6666
var f: F;
6767

68-
// all ok
68+
// disallowed by weak type checking
6969
c = d;
7070
~
7171
!!! error TS2322: Type 'D' is not assignable to type 'C'.
@@ -78,8 +78,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
7878
~
7979
!!! error TS2322: Type 'F' is not assignable to type 'C'.
8080
!!! error TS2322: Weak type 'C' has no properties in common with 'F'.
81-
c = a;
82-
8381
a = d;
8482
~
8583
!!! error TS2322: Type 'D' is not assignable to type '{ opt?: Base; }'.
@@ -92,8 +90,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
9290
~
9391
!!! error TS2322: Type 'F' is not assignable to type '{ opt?: Base; }'.
9492
!!! error TS2322: Weak type '{ opt?: Base; }' has no properties in common with 'F'.
95-
a = c;
96-
9793
b = d;
9894
~
9995
!!! error TS2322: Type 'D' is not assignable to type '{ opt?: Base; }'.
@@ -103,6 +99,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
10399
b = f;
104100
~
105101
!!! error TS2322: Type 'F' is not assignable to type '{ opt?: Base; }'.
102+
103+
// ok
104+
c = a;
105+
a = c;
106106
b = a;
107107
b = c;
108108
}
@@ -173,4 +173,5 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
173173
!!! error TS2322: Property 'opt' is missing in type 'F'.
174174
b = a; // ok
175175
b = c; // ok
176-
}
176+
}
177+

tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ module TargetHasOptional {
3030
var e: E;
3131
var f: F;
3232

33-
// all ok
33+
// disallowed by weak type checking
3434
c = d;
3535
c = e;
3636
c = f;
37-
c = a;
38-
3937
a = d;
4038
a = e;
4139
a = f;
42-
a = c;
43-
4440
b = d;
4541
b = e;
4642
b = f;
43+
44+
// ok
45+
c = a;
46+
a = c;
4747
b = a;
4848
b = c;
4949
}
@@ -87,7 +87,8 @@ module SourceHasOptional {
8787
b = f; // error
8888
b = a; // ok
8989
b = c; // ok
90-
}
90+
}
91+
9192

9293
//// [assignmentCompatWithObjectMembersOptionality2.js]
9394
// M is optional and S contains no property with the same name as M
@@ -129,18 +130,19 @@ var TargetHasOptional;
129130
var d;
130131
var e;
131132
var f;
132-
// all ok
133+
// disallowed by weak type checking
133134
c = d;
134135
c = e;
135136
c = f;
136-
c = a;
137137
a = d;
138138
a = e;
139139
a = f;
140-
a = c;
141140
b = d;
142141
b = e;
143142
b = f;
143+
// ok
144+
c = a;
145+
a = c;
144146
b = a;
145147
b = c;
146148
})(TargetHasOptional || (TargetHasOptional = {}));

tests/baselines/reference/subtypingWithObjectMembers5.errors.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
6868
~
6969
!!! error TS2420: Class 'B' incorrectly implements interface 'A'.
7070
!!! error TS2420: Weak type 'A' has no properties in common with 'B'.
71-
fooo: Derived; // ok
71+
fooo: Derived; // weak type error
7272
}
7373

7474
interface A2 {
@@ -79,7 +79,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
7979
~~
8080
!!! error TS2420: Class 'B2' incorrectly implements interface 'A2'.
8181
!!! error TS2420: Weak type 'A2' has no properties in common with 'B2'.
82-
2: Derived; // ok
82+
2: Derived; // weak type error
8383
}
8484

8585
interface A3 {
@@ -90,6 +90,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
9090
~~
9191
!!! error TS2420: Class 'B3' incorrectly implements interface 'A3'.
9292
!!! error TS2420: Weak type 'A3' has no properties in common with 'B3'.
93-
'1.0': Derived; // ok
93+
'1.0': Derived; // weak type error
9494
}
95-
}
95+
}
96+

tests/baselines/reference/subtypingWithObjectMembers5.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,26 @@ module Optional {
4242
}
4343

4444
class B implements A {
45-
fooo: Derived; // ok
45+
fooo: Derived; // weak type error
4646
}
4747

4848
interface A2 {
4949
1?: Base;
5050
}
5151

5252
class B2 implements A2 {
53-
2: Derived; // ok
53+
2: Derived; // weak type error
5454
}
5555

5656
interface A3 {
5757
'1'?: Base;
5858
}
5959

6060
class B3 implements A3 {
61-
'1.0': Derived; // ok
61+
'1.0': Derived; // weak type error
6262
}
63-
}
63+
}
64+
6465

6566
//// [subtypingWithObjectMembers5.js]
6667
// N and M have the same name, same accessibility, same optionality, and N is a subtype of M

tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ module TargetHasOptional {
2929
var e: E;
3030
var f: F;
3131

32-
// all ok
32+
// disallowed by weak type checking
3333
c = d;
3434
c = e;
3535
c = f;
36-
c = a;
37-
3836
a = d;
3937
a = e;
4038
a = f;
41-
a = c;
42-
4339
b = d;
4440
b = e;
4541
b = f;
42+
43+
// ok
44+
c = a;
45+
a = c;
4646
b = a;
4747
b = c;
4848
}
@@ -86,4 +86,4 @@ module SourceHasOptional {
8686
b = f; // error
8787
b = a; // ok
8888
b = c; // ok
89-
}
89+
}

tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers5.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ module Optional {
4141
}
4242

4343
class B implements A {
44-
fooo: Derived; // ok
44+
fooo: Derived; // weak type error
4545
}
4646

4747
interface A2 {
4848
1?: Base;
4949
}
5050

5151
class B2 implements A2 {
52-
2: Derived; // ok
52+
2: Derived; // weak type error
5353
}
5454

5555
interface A3 {
5656
'1'?: Base;
5757
}
5858

5959
class B3 implements A3 {
60-
'1.0': Derived; // ok
60+
'1.0': Derived; // weak type error
6161
}
62-
}
62+
}

0 commit comments

Comments
 (0)