@@ -7172,8 +7172,7 @@ namespace ts {
7172
7172
if (source.flags & TypeFlags.Enum && target.flags & TypeFlags.Enum && isEnumTypeRelatedTo(<EnumType>source, <EnumType>target, errorReporter)) return true;
7173
7173
if (source.flags & TypeFlags.Undefined && (!strictNullChecks || target.flags & (TypeFlags.Undefined | TypeFlags.Void))) return true;
7174
7174
if (source.flags & TypeFlags.Null && (!strictNullChecks || target.flags & TypeFlags.Null)) return true;
7175
- if (source.flags & TypeFlags.Object && target === nonPrimitiveType) return true;
7176
- if (source.flags & TypeFlags.Primitive && target === nonPrimitiveType) return false;
7175
+ if (source.flags & TypeFlags.Object && target.flags & TypeFlags.NonPrimitive) return true;
7177
7176
if (relation === assignableRelation || relation === comparableRelation) {
7178
7177
if (source.flags & TypeFlags.Any) return true;
7179
7178
if ((source.flags & TypeFlags.Number | source.flags & TypeFlags.NumberLiteral) && target.flags & TypeFlags.EnumLike) return true;
@@ -7457,19 +7456,19 @@ namespace ts {
7457
7456
}
7458
7457
else {
7459
7458
let constraint = getConstraintOfTypeParameter(<TypeParameter>source);
7460
-
7461
- if (! constraint || constraint .flags & TypeFlags.Any ) {
7462
- constraint = emptyObjectType;
7463
- }
7464
-
7465
- // The constraint may need to be further instantiated with its 'this' type.
7466
- constraint = getTypeWithThisArgument(constraint, source);
7467
-
7468
- // Report constraint errors only if the constraint is not the empty object type
7469
- const reportConstraintErrors = reportErrors && constraint !== emptyObjectType;
7470
- if (result = isRelatedTo(constraint, target, reportConstraintErrors)) {
7471
- errorInfo = saveErrorInfo ;
7472
- return result;
7459
+ // A type parameter with no constraint is not related to the non-primitive object type.
7460
+ if (constraint || !(target .flags & TypeFlags.NonPrimitive) ) {
7461
+ if (! constraint || constraint.flags & TypeFlags.Any) {
7462
+ constraint = emptyObjectType;
7463
+ }
7464
+ // The constraint may need to be further instantiated with its 'this' type.
7465
+ constraint = getTypeWithThisArgument(constraint, source);
7466
+ // Report constraint errors only if the constraint is not the empty object type
7467
+ const reportConstraintErrors = reportErrors && constraint !== emptyObjectType;
7468
+ if (result = isRelatedTo(constraint, target, reportConstraintErrors)) {
7469
+ errorInfo = saveErrorInfo;
7470
+ return result ;
7471
+ }
7473
7472
}
7474
7473
}
7475
7474
}
@@ -9237,9 +9236,6 @@ namespace ts {
9237
9236
}
9238
9237
9239
9238
function getTypeFacts(type: Type): TypeFacts {
9240
- if (type === nonPrimitiveType) {
9241
- return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts;
9242
- }
9243
9239
const flags = type.flags;
9244
9240
if (flags & TypeFlags.String) {
9245
9241
return strictNullChecks ? TypeFacts.StringStrictFacts : TypeFacts.StringFacts;
@@ -9280,6 +9276,9 @@ namespace ts {
9280
9276
if (flags & TypeFlags.ESSymbol) {
9281
9277
return strictNullChecks ? TypeFacts.SymbolStrictFacts : TypeFacts.SymbolFacts;
9282
9278
}
9279
+ if (flags & TypeFlags.NonPrimitive) {
9280
+ return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts;
9281
+ }
9283
9282
if (flags & TypeFlags.TypeParameter) {
9284
9283
const constraint = getConstraintOfTypeParameter(<TypeParameter>type);
9285
9284
return getTypeFacts(constraint || emptyObjectType);
0 commit comments