* Try and elaborate array and tuple errors. Returns false * if we have found an elaboration, or we should ignore * any other elaborations when relating the `source` and * `target` types.
(source, target, reportErrors)
| 64940 | * `target` types. |
| 64941 | */ |
| 64942 | function tryElaborateArrayLikeErrors(source, target, reportErrors) { |
| 64943 | /** |
| 64944 | * The spec for elaboration is: |
| 64945 | * - If the source is a readonly tuple and the target is a mutable array or tuple, elaborate on mutability and skip property elaborations. |
| 64946 | * - If the source is a tuple then skip property elaborations if the target is an array or tuple. |
| 64947 | * - If the source is a readonly array and the target is a mutable array or tuple, elaborate on mutability and skip property elaborations. |
| 64948 | * - If the source an array then skip property elaborations if the target is a tuple. |
| 64949 | */ |
| 64950 | if (isTupleType(source)) { |
| 64951 | if (source.target.readonly && isMutableArrayOrTuple(target)) { |
| 64952 | if (reportErrors) { |
| 64953 | reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target)); |
| 64954 | } |
| 64955 | return false; |
| 64956 | } |
| 64957 | return isArrayOrTupleType(target); |
| 64958 | } |
| 64959 | if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) { |
| 64960 | if (reportErrors) { |
| 64961 | reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target)); |
| 64962 | } |
| 64963 | return false; |
| 64964 | } |
| 64965 | if (isTupleType(target)) { |
| 64966 | return isArrayType(source); |
| 64967 | } |
| 64968 | return true; |
| 64969 | } |
| 64970 | function isRelatedToWorker(source, target, reportErrors) { |
| 64971 | return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors); |
| 64972 | } |
no test coverage detected
searching dependent graphs…