MCPcopy Index your code
hub / github.com/reactjs/react-rails / parseParam

Function parseParam

lib/assets/javascripts/JSXTransformer.js:8087–8150  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

8085 }
8086
8087 function parseParam(options) {
8088 var marker, token, rest, param, def;
8089
8090 token = lookahead;
8091 if (token.value === '...') {
8092 token = lex();
8093 rest = true;
8094 }
8095
8096 if (match('[')) {
8097 marker = markerCreate();
8098 param = parseArrayInitialiser();
8099 reinterpretAsDestructuredParameter(options, param);
8100 if (match(':')) {
8101 param.typeAnnotation = parseTypeAnnotation();
8102 markerApply(marker, param);
8103 }
8104 } else if (match('{')) {
8105 marker = markerCreate();
8106 if (rest) {
8107 throwError({}, Messages.ObjectPatternAsRestParameter);
8108 }
8109 param = parseObjectInitialiser();
8110 reinterpretAsDestructuredParameter(options, param);
8111 if (match(':')) {
8112 param.typeAnnotation = parseTypeAnnotation();
8113 markerApply(marker, param);
8114 }
8115 } else {
8116 param =
8117 rest
8118 ? parseTypeAnnotatableIdentifier(
8119 false, /* requireTypeAnnotation */
8120 false /* canBeOptionalParam */
8121 )
8122 : parseTypeAnnotatableIdentifier(
8123 false, /* requireTypeAnnotation */
8124 true /* canBeOptionalParam */
8125 );
8126
8127 validateParam(options, token, token.value);
8128 }
8129
8130 if (match('=')) {
8131 if (rest) {
8132 throwErrorTolerant(lookahead, Messages.DefaultRestParameter);
8133 }
8134 lex();
8135 def = parseAssignmentExpression();
8136 ++options.defaultCount;
8137 }
8138
8139 if (rest) {
8140 if (!match(')')) {
8141 throwError({}, Messages.ParameterAfterRestParameter);
8142 }
8143 options.rest = param;
8144 return false;

Callers 1

parseParamsFunction · 0.85

Calls 13

lexFunction · 0.85
matchFunction · 0.85
markerCreateFunction · 0.85
parseArrayInitialiserFunction · 0.85
parseTypeAnnotationFunction · 0.85
markerApplyFunction · 0.85
throwErrorFunction · 0.85
parseObjectInitialiserFunction · 0.85
validateParamFunction · 0.85
throwErrorTolerantFunction · 0.85

Tested by

no test coverage detected