babel / babel/babel

[Bug]: Name property - missing name in object binding pattern

Open
#14,988 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
44k
Forks
6k
Avg merge
5d 15h
Merged PRs (30d)
23

Description

### 💻

- [ ] Would you like to work on a fix?

### How are you using Babel?

Other (Next.js, Gatsby, vue-cli, ...)

### Input code

```js
var { x = function ( ) { } } = 0 ;
```

### Configuration file name

_No response_

### Configuration

_No response_

### Current and expected behavior

Value of `x.name`: `'x'` expected but `''` in transpiled code.
```console
❯ node
Welcome to Node.js v18.8.0.
Type ".help" for more information.
> var { x = function ( ) { } } = 0 ;
undefined
> x.name
'x'
```

### Environment

[Reproductions on Babel's own REPL](https://babeljs.io/repl#?browsers=since%202105&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=G4QwTgBA3hAeEF4IDMCuA7AxgFwJYHt0IAKCASmggF9rEIAGCAbiA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=script&lineWrap=true&presets=env%2Creact%2Cstage-2&prettier=true&targets=&version=7.19.3&externalPlugins=&assumptions=%7B%7D)

### Possible solution

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the linked Babel REPL reproduction using the object binding pattern `var { x = function ( ) { } } = 0;`, then trace how Babel transforms this syntax and assigns the function name. Done means the transpiled result gives `x.name` as `'x'`, matching native Node.js behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.