(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional)
| 66330 | return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); |
| 66331 | } |
| 66332 | function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { |
| 66333 | var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); |
| 66334 | var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); |
| 66335 | if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) { |
| 66336 | if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { |
| 66337 | if (reportErrors) { |
| 66338 | if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) { |
| 66339 | reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); |
| 66340 | } |
| 66341 | else { |
| 66342 | reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source)); |
| 66343 | } |
| 66344 | } |
| 66345 | return 0 /* Ternary.False */; |
| 66346 | } |
| 66347 | } |
| 66348 | else if (targetPropFlags & 16 /* ModifierFlags.Protected */) { |
| 66349 | if (!isValidOverrideOf(sourceProp, targetProp)) { |
| 66350 | if (reportErrors) { |
| 66351 | reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); |
| 66352 | } |
| 66353 | return 0 /* Ternary.False */; |
| 66354 | } |
| 66355 | } |
| 66356 | else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) { |
| 66357 | if (reportErrors) { |
| 66358 | reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); |
| 66359 | } |
| 66360 | return 0 /* Ternary.False */; |
| 66361 | } |
| 66362 | // Ensure {readonly a: whatever} is not a subtype of {a: whatever}, |
| 66363 | // while {a: whatever} is a subtype of {readonly a: whatever}. |
| 66364 | // This ensures the subtype relationship is ordered, and preventing declaration order |
| 66365 | // from deciding which type "wins" in union subtype reduction. |
| 66366 | // They're still assignable to one another, since `readonly` doesn't affect assignability. |
| 66367 | // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction |
| 66368 | if (relation === strictSubtypeRelation && |
| 66369 | isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) { |
| 66370 | return 0 /* Ternary.False */; |
| 66371 | } |
| 66372 | // If the target comes from a partial union prop, allow `undefined` in the target type |
| 66373 | var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState); |
| 66374 | if (!related) { |
| 66375 | if (reportErrors) { |
| 66376 | reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); |
| 66377 | } |
| 66378 | return 0 /* Ternary.False */; |
| 66379 | } |
| 66380 | // When checking for comparability, be more lenient with optional properties. |
| 66381 | if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { |
| 66382 | // TypeScript 1.0 spec (April 2014): 3.8.3 |
| 66383 | // S is a subtype of a type T, and T is a supertype of S if ... |
| 66384 | // S' and T are object types and, for each member M in T.. |
| 66385 | // M is a property and S' contains a property N where |
| 66386 | // if M is a required property, N is also a required property |
| 66387 | // (M - property in T) |
| 66388 | // (N - property in S) |
| 66389 | if (reportErrors) { |
no test coverage detected