Typescript Object destructuring results in "Property assignment expected."

31,983

The feature you are looking for is Object spread/rest operators (proposed for ES7). It looks like it's planned but not yet implemented:

We want to wait for the proposal to reach Stage 3 before addressing this.

More info here.

Edit: The proposal is in stage-3. We'll likely see it drafted on ES2018 (ES9). Support has been added to TypeScript as well (starting from 2.1).

Share:
31,983
Rick
Author by

Rick

Hi! I'm Rick Carlino, a software dev from the Chicago suburbs. I started programming professionally in 2012 and have been tinkering with computers since my first Windows 3.1 machine in the '90s. I am a senior software engineer at Qualia Labs. I also co-founded Fox.Build, one of the largest makerspaces in the Chicago suburbs. It's a community-led organization for engineers, artists and entrepreneurs or anyone who likes to make things. In the past, I've worked on projects for medical payment processing, IoT startups, textile manufacturers, hospitality management services, non-profits, the military, and a list of consulting clients that are too numerous to name. My public work is available on my Github page and blog. Outside of work, I enjoy long-distance running, pottery and studying the history of computing (1983-2003). My preferred languages are Typescript, Ruby, Elixir, QBasic, Esperanto.

Updated on July 15, 2022

Comments

  • Rick
    Rick almost 2 years

    I am transitioning a project from Babel to Typescript and receive the following compiler error:

    error TS1136: Property assignment expected.
    

    from code that looks like this:

    var auth = {...this.props.auth};
    

    This code previously worked fine under Babel, but causes the error above when attempting to compile via Typescript. Is object destructuring different in Typescript?