(source, target, relation, errorReporter)
| 64551 | return true; |
| 64552 | } |
| 64553 | function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { |
| 64554 | var s = source.flags; |
| 64555 | var t = target.flags; |
| 64556 | if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType) |
| 64557 | return true; |
| 64558 | if (t & 131072 /* TypeFlags.Never */) |
| 64559 | return false; |
| 64560 | if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */) |
| 64561 | return true; |
| 64562 | if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && |
| 64563 | t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && |
| 64564 | source.value === target.value) |
| 64565 | return true; |
| 64566 | if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */) |
| 64567 | return true; |
| 64568 | if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && |
| 64569 | t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && |
| 64570 | source.value === target.value) |
| 64571 | return true; |
| 64572 | if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */) |
| 64573 | return true; |
| 64574 | if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */) |
| 64575 | return true; |
| 64576 | if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */) |
| 64577 | return true; |
| 64578 | if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) |
| 64579 | return true; |
| 64580 | if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) { |
| 64581 | if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) |
| 64582 | return true; |
| 64583 | if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ && |
| 64584 | source.value === target.value && |
| 64585 | isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) |
| 64586 | return true; |
| 64587 | } |
| 64588 | // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`. |
| 64589 | // Since unions and intersections may reduce to `never`, we exclude them here. |
| 64590 | if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */))) |
| 64591 | return true; |
| 64592 | if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */)) |
| 64593 | return true; |
| 64594 | if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */) |
| 64595 | return true; |
| 64596 | if (relation === assignableRelation || relation === comparableRelation) { |
| 64597 | if (s & 1 /* TypeFlags.Any */) |
| 64598 | return true; |
| 64599 | // Type number or any numeric literal type is assignable to any numeric enum type or any |
| 64600 | // numeric enum literal type. This rule exists for backwards compatibility reasons because |
| 64601 | // bit-flag enum types sometimes look like literal enum types with numeric literal values. |
| 64602 | if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */)) |
| 64603 | return true; |
| 64604 | } |
| 64605 | return false; |
| 64606 | } |
| 64607 | function isTypeRelatedTo(source, target, relation) { |
| 64608 | if (isFreshLiteralType(source)) { |
| 64609 | source = source.regularType; |
no test coverage detected
searching dependent graphs…