MCPcopy Index your code
hub / github.com/nodejs/node / addSpans

Function addSpans

test/fixtures/snapshot/typescript.js:61944–61978  ·  view source on GitHub ↗
(texts, types)

Source from the content-addressed store, hash-verified

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 }
61973 else if (isTextsArray) {
61974 return false;
61975 }
61976 }
61977 return true;
61978 }
61979 }
61980 function getTemplateStringForType(type) {
61981 return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value :

Callers 1

getTemplateLiteralTypeFunction · 0.85

Calls 4

getTemplateStringForTypeFunction · 0.85
isGenericIndexTypeFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected