Am I making a mistake in my logic or is the compiler having trouble understanding my intentions?
Error - Line i4:
This condition will always return true since the types SubjectType.Both | SubjectType.A and SubjectType.B have no overlap.
j1 enum SubjectType {
j2 BOTH,
j3 A,
j4 B,
j5 }
i1 switch ( subjectType: SubjectType ) {
i2 case SubjectType.BOTH
i3 case SubjectType.A:
i4 if( subjectType !== SubjectType.B ) {
i5 //Do operation A
i6 }
i7 case SubjectType.B:
i8 if( subjectType !== SubjectType.A ) {
i9 //Do operation B
i10 }
i11
i12 break;
i13 default:
i14 throw new TypeError( `Unknown SubjectType ${subjectType} provided` );
i15 }
UPDATE: I have realized that there was an error in my logic.
i1 switch ( subjectType: SubjectType ) {
i2 case SubjectType.BOTH
i3 case SubjectType.A:
i4 //Do operation A, if type A | BOTH
i5
i6 case SubjectType.B:
i7 if( subjectType !== SubjectType.A ) {
i8 //Do operation B
i9 }
i10
i11 break;
i12 default:
i13 throw new TypeError( `Unknown SubjectType ${subjectType} provided` );
i14 }