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

Function checkAssertionWorker

test/fixtures/snapshot/typescript.js:77320–77340  ·  view source on GitHub ↗
(errNode, type, expression, checkMode)

Source from the content-addressed store, hash-verified

77318 return false;
77319 }
77320 function checkAssertionWorker(errNode, type, expression, checkMode) {
77321 var exprType = checkExpression(expression, checkMode);
77322 if (ts.isConstTypeReference(type)) {
77323 if (!isValidConstAssertionArgument(expression)) {
77324 error(expression, ts.Diagnostics.A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
77325 }
77326 return getRegularTypeOfLiteralType(exprType);
77327 }
77328 checkSourceElement(type);
77329 exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
77330 var targetType = getTypeFromTypeNode(type);
77331 if (!isErrorType(targetType)) {
77332 addLazyDiagnostic(function () {
77333 var widenedType = getWidenedType(exprType);
77334 if (!isTypeComparableTo(targetType, widenedType)) {
77335 checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first);
77336 }
77337 });
77338 }
77339 return targetType;
77340 }
77341 function checkNonNullChain(node) {
77342 var leftType = checkExpression(node.expression);
77343 var nonOptionalType = getOptionalExpressionType(leftType, node.expression);

Callers 2

checkAssertionFunction · 0.85

Calls 13

checkSourceElementFunction · 0.85
getBaseTypeOfLiteralTypeFunction · 0.85
getTypeFromTypeNodeFunction · 0.85
isErrorTypeFunction · 0.85
addLazyDiagnosticFunction · 0.85
getWidenedTypeFunction · 0.85
isTypeComparableToFunction · 0.85
checkTypeComparableToFunction · 0.85
checkExpressionFunction · 0.70

Tested by

no test coverage detected