(texts, types)
| 61913 | return links.resolvedType; |
| 61914 | } |
| 61915 | function getTemplateLiteralType(texts, types) { |
| 61916 | var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); |
| 61917 | if (unionIndex >= 0) { |
| 61918 | return checkCrossProductUnion(types) ? |
| 61919 | mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : |
| 61920 | errorType; |
| 61921 | } |
| 61922 | if (ts.contains(types, wildcardType)) { |
| 61923 | return wildcardType; |
| 61924 | } |
| 61925 | var newTypes = []; |
| 61926 | var newTexts = []; |
| 61927 | var text = texts[0]; |
| 61928 | if (!addSpans(texts, types)) { |
| 61929 | return stringType; |
| 61930 | } |
| 61931 | if (newTypes.length === 0) { |
| 61932 | return getStringLiteralType(text); |
| 61933 | } |
| 61934 | newTexts.push(text); |
| 61935 | if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) { |
| 61936 | return stringType; |
| 61937 | } |
| 61938 | var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); |
| 61939 | var type = templateLiteralTypes.get(id); |
| 61940 | if (!type) { |
| 61941 | templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); |
| 61942 | } |
| 61943 | return type; |
| 61944 | function addSpans(texts, types) { |
| 61945 | var isTextsArray = ts.isArray(texts); |
| 61946 | for (var i = 0; i < types.length; i++) { |
| 61947 | var t = types[i]; |
| 61948 | var addText = isTextsArray ? texts[i + 1] : texts; |
| 61949 | if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) { |
| 61950 | text += getTemplateStringForType(t) || ""; |
| 61951 | text += addText; |
| 61952 | if (!isTextsArray) |
| 61953 | return true; |
| 61954 | } |
| 61955 | else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { |
| 61956 | text += t.texts[0]; |
| 61957 | if (!addSpans(t.texts, t.types)) |
| 61958 | return false; |
| 61959 | text += addText; |
| 61960 | if (!isTextsArray) |
| 61961 | return true; |
| 61962 | } |
| 61963 | else if (isGenericIndexType(t) || isPatternLiteralPlaceholderType(t)) { |
| 61964 | newTypes.push(t); |
| 61965 | newTexts.push(text); |
| 61966 | text = addText; |
| 61967 | } |
| 61968 | else if (t.flags & 2097152 /* TypeFlags.Intersection */) { |
| 61969 | var added = addSpans(texts[i + 1], t.types); |
| 61970 | if (!added) |
| 61971 | return false; |
| 61972 | } |
no test coverage detected