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

Function checkTemplateExpression

test/fixtures/snapshot/typescript.js:79459–79472  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

79457 ts.isElementAccessExpression(parent) && parent.argumentExpression === node;
79458 }
79459 function checkTemplateExpression(node) {
79460 var texts = [node.head.text];
79461 var types = [];
79462 for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
79463 var span = _a[_i];
79464 var type = checkExpression(span.expression);
79465 if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) {
79466 error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
79467 }
79468 texts.push(span.literal.text);
79469 types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
79470 }
79471 return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType;
79472 }
79473 function isTemplateLiteralContextualType(type) {
79474 return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) ||
79475 type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */));

Callers 1

checkExpressionWorkerFunction · 0.85

Calls 10

isTypeAssignableToFunction · 0.85
isConstContextFunction · 0.85
isTemplateLiteralContextFunction · 0.85
someTypeFunction · 0.85
getContextualTypeFunction · 0.85
getTemplateLiteralTypeFunction · 0.85
checkExpressionFunction · 0.70
errorFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…