MCPcopy Create free account
hub / github.com/nodejs/node / extractRedundantTemplateLiterals

Function extractRedundantTemplateLiterals

test/fixtures/snapshot/typescript.js:61507–61528  ·  view source on GitHub ↗

* Returns `true` if the intersection of the template literals and string literals is the empty set, eg `get${string}` & "setX", and should reduce to `never`

(types)

Source from the content-addressed store, hash-verified

61505 * Returns `true` if the intersection of the template literals and string literals is the empty set, eg `get${string}` & "setX", and should reduce to `never`
61506 */
61507 function extractRedundantTemplateLiterals(types) {
61508 var i = types.length;
61509 var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); });
61510 while (i > 0) {
61511 i--;
61512 var t = types[i];
61513 if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */))
61514 continue;
61515 for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) {
61516 var t2 = literals_1[_i];
61517 if (isTypeSubtypeOf(t2, t)) {
61518 // eg, ``get${T}` & "getX"` is just `"getX"`
61519 ts.orderedRemoveItemAt(types, i);
61520 break;
61521 }
61522 else if (isPatternLiteralType(t)) {
61523 return true;
61524 }
61525 }
61526 }
61527 return false;
61528 }
61529 function eachIsUnionContaining(types, flag) {
61530 return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); });
61531 }

Callers 1

getIntersectionTypeFunction · 0.85

Calls 3

isTypeSubtypeOfFunction · 0.85
isPatternLiteralTypeFunction · 0.85
filterMethod · 0.65

Tested by

no test coverage detected