Skip to content

Issue with rest spread and computed properties using string template #9563

@Nickman87

Description

@Nickman87

Bug Report

Current Behavior
When using string templates in computed properties, the property name isn't correctly excluded from the rest properties object.
Looking at the compiled code, it puts 'undefined' instead of the actual property name. If you use string concatenation, this does work perfectly.

Input Code
REPL sample

const input = {};
// Extract all known attributes from the user
const {
  given_name: givenName,
  'last_name': lastName,
  [`country`]: country,
  [prefix + 'state']: state,
  [`${prefix}consents`]: consents,
  // All the rest
  ...otherAttributes
} = input;

Expected behavior/code
All given computed properties should be excluded from the otherAttributes object, but the ones using template strings remain.

Environment

  • Babel version(s): v7.3.3 (probably older versions too)
  • Node/npm version: any
  • OS: any

Possible Solution
Make sure the transpiler knows what a template string is and correctly copy it over to the exclusion list. Sound like something that is easy to fix, but I have no idea where to start :).

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimedgood first issueoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions