(
this: Parser,
close: TokenType,
isPattern: boolean,
refExpressionErrors?: ExpressionErrors | null,
)
| 2085 | refExpressionErrors?: ExpressionErrors | null, |
| 2086 | ): N.ObjectExpression; |
| 2087 | parseObjectLike<T extends N.ObjectPattern | N.ObjectExpression>( |
| 2088 | this: Parser, |
| 2089 | close: TokenType, |
| 2090 | isPattern: boolean, |
| 2091 | refExpressionErrors?: ExpressionErrors | null, |
| 2092 | ): T { |
| 2093 | let sawProto = false; |
| 2094 | let first = true; |
| 2095 | const node = this.startNode<N.ObjectExpression | N.ObjectPattern>(); |
| 2096 | |
| 2097 | node.properties = []; |
| 2098 | this.next(); |
| 2099 | |
| 2100 | while (!this.match(close)) { |
| 2101 | if (first) { |
| 2102 | first = false; |
| 2103 | } else { |
| 2104 | this.expect(tt.comma); |
| 2105 | if (this.match(close)) { |
| 2106 | this.addTrailingCommaExtraToNode(node); |
| 2107 | break; |
| 2108 | } |
| 2109 | } |
| 2110 | |
| 2111 | let prop; |
| 2112 | if (isPattern) { |
| 2113 | prop = this.parseBindingProperty(); |
| 2114 | } else { |
| 2115 | prop = this.parsePropertyDefinition(refExpressionErrors); |
| 2116 | sawProto = this.checkProto(prop, sawProto, refExpressionErrors); |
| 2117 | } |
| 2118 | |
| 2119 | // @ts-expect-error Fixme: refine typings |
| 2120 | node.properties.push(prop); |
| 2121 | } |
| 2122 | |
| 2123 | this.next(); |
| 2124 | |
| 2125 | const type = isPattern ? "ObjectPattern" : "ObjectExpression"; |
| 2126 | // @ts-expect-error type is well defined |
| 2127 | return this.finishNode(node, type); |
| 2128 | } |
| 2129 | |
| 2130 | addTrailingCommaExtraToNode(node: Undone<N.Node>): void { |
| 2131 | this.addExtra(node, "trailingComma", this.state.lastTokStartLoc!.index); |
nothing calls this directly
no test coverage detected