(options)
| 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; |
no test coverage detected