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

Function isValidConstAssertionArgument

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

Source from the content-addressed store, hash-verified

77288 return checkAssertionWorker(node, node.type, node.expression);
77289 }
77290 function isValidConstAssertionArgument(node) {
77291 switch (node.kind) {
77292 case 10 /* SyntaxKind.StringLiteral */:
77293 case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */:
77294 case 8 /* SyntaxKind.NumericLiteral */:
77295 case 9 /* SyntaxKind.BigIntLiteral */:
77296 case 110 /* SyntaxKind.TrueKeyword */:
77297 case 95 /* SyntaxKind.FalseKeyword */:
77298 case 204 /* SyntaxKind.ArrayLiteralExpression */:
77299 case 205 /* SyntaxKind.ObjectLiteralExpression */:
77300 case 223 /* SyntaxKind.TemplateExpression */:
77301 return true;
77302 case 212 /* SyntaxKind.ParenthesizedExpression */:
77303 return isValidConstAssertionArgument(node.expression);
77304 case 219 /* SyntaxKind.PrefixUnaryExpression */:
77305 var op = node.operator;
77306 var arg = node.operand;
77307 return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) ||
77308 op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */;
77309 case 206 /* SyntaxKind.PropertyAccessExpression */:
77310 case 207 /* SyntaxKind.ElementAccessExpression */:
77311 var expr = node.expression;
77312 var symbol = getTypeOfNode(expr).symbol;
77313 if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
77314 symbol = resolveAlias(symbol);
77315 }
77316 return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
77317 }
77318 return false;
77319 }
77320 function checkAssertionWorker(errNode, type, expression, checkMode) {
77321 var exprType = checkExpression(expression, checkMode);
77322 if (ts.isConstTypeReference(type)) {

Callers 1

checkAssertionWorkerFunction · 0.85

Calls 3

getTypeOfNodeFunction · 0.85
resolveAliasFunction · 0.85
getEnumKindFunction · 0.85

Tested by

no test coverage detected