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

Function parseTypeParameter

test/fixtures/snapshot/typescript.js:33411–33440  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33409 return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
33410 }
33411 function parseTypeParameter() {
33412 var pos = getNodePos();
33413 var modifiers = parseModifiers();
33414 var name = parseIdentifier();
33415 var constraint;
33416 var expression;
33417 if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) {
33418 // It's not uncommon for people to write improper constraints to a generic. If the
33419 // user writes a constraint that is an expression and not an actual type, then parse
33420 // it out as an expression (so we can recover well), but report that a type is needed
33421 // instead.
33422 if (isStartOfType() || !isStartOfExpression()) {
33423 constraint = parseType();
33424 }
33425 else {
33426 // It was not a type, and it looked like an expression. Parse out an expression
33427 // here so we recover well. Note: it is important that we call parseUnaryExpression
33428 // and not parseExpression here. If the user has:
33429 //
33430 // <T extends "">
33431 //
33432 // We do *not* want to consume the `>` as we're consuming the expression for "".
33433 expression = parseUnaryExpressionOrHigher();
33434 }
33435 }
33436 var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined;
33437 var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType);
33438 node.expression = expression;
33439 return finishNode(node, pos);
33440 }
33441 function parseTypeParameters() {
33442 if (token() === 29 /* SyntaxKind.LessThanToken */) {
33443 return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */);

Callers

nothing calls this directly

Calls 9

getNodePosFunction · 0.85
parseModifiersFunction · 0.85
parseIdentifierFunction · 0.85
parseOptionalFunction · 0.85
isStartOfTypeFunction · 0.85
isStartOfExpressionFunction · 0.85
parseTypeFunction · 0.85
finishNodeFunction · 0.85

Tested by

no test coverage detected