(
this: Parser,
prop: Undone<N.ObjectProperty>,
startLoc: Position | undefined | null,
isPattern: boolean,
refExpressionErrors?: ExpressionErrors | null,
)
| 2313 | // if `isPattern` is true, parse https://tc39.es/ecma262/#prod-BindingProperty |
| 2314 | // else https://tc39.es/ecma262/#prod-PropertyDefinition |
| 2315 | parseObjectProperty( |
| 2316 | this: Parser, |
| 2317 | prop: Undone<N.ObjectProperty>, |
| 2318 | startLoc: Position | undefined | null, |
| 2319 | isPattern: boolean, |
| 2320 | refExpressionErrors?: ExpressionErrors | null, |
| 2321 | ): N.ObjectProperty | undefined | null { |
| 2322 | prop.shorthand = false; |
| 2323 | |
| 2324 | if (this.eat(tt.colon)) { |
| 2325 | prop.value = isPattern |
| 2326 | ? this.parseMaybeDefault(this.state.startLoc) |
| 2327 | : this.parseMaybeAssignAllowInOrVoidPattern( |
| 2328 | tt.braceR, |
| 2329 | refExpressionErrors, |
| 2330 | ); |
| 2331 | |
| 2332 | return this.finishObjectProperty(prop); |
| 2333 | } |
| 2334 | |
| 2335 | if (!prop.computed && prop.key.type === "Identifier") { |
| 2336 | // PropertyDefinition: |
| 2337 | // IdentifierReference |
| 2338 | // CoverInitializedName |
| 2339 | // Note: `{ eval } = {}` will be checked in `checkLVal` later. |
| 2340 | this.checkReservedWord(prop.key.name, prop.key.start!, true, false); |
| 2341 | |
| 2342 | if (isPattern) { |
| 2343 | prop.value = this.parseMaybeDefault( |
| 2344 | startLoc, |
| 2345 | this.cloneIdentifier(prop.key), |
| 2346 | ); |
| 2347 | } else if (this.match(tt.eq)) { |
| 2348 | const shorthandAssignLoc = this.state.startLoc; |
| 2349 | if (refExpressionErrors != null) { |
| 2350 | if (refExpressionErrors.shorthandAssignLoc === null) { |
| 2351 | refExpressionErrors.shorthandAssignLoc = shorthandAssignLoc; |
| 2352 | } |
| 2353 | } else { |
| 2354 | this.raise(Errors.InvalidCoverInitializedName, shorthandAssignLoc); |
| 2355 | } |
| 2356 | prop.value = this.parseMaybeDefault( |
| 2357 | startLoc, |
| 2358 | this.cloneIdentifier(prop.key), |
| 2359 | ); |
| 2360 | } else { |
| 2361 | prop.value = this.cloneIdentifier(prop.key); |
| 2362 | } |
| 2363 | prop.shorthand = true; |
| 2364 | |
| 2365 | return this.finishObjectProperty(prop); |
| 2366 | } |
| 2367 | } |
| 2368 | |
| 2369 | finishObjectProperty(node: Undone<N.ObjectProperty>) { |
| 2370 | return this.finishNode(node, "ObjectProperty"); |
nothing calls this directly
no test coverage detected