10

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?

Rick
  • 8,366
  • 8
  • 47
  • 76

1 Answers1

8

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).

MinusFour
  • 13,913
  • 3
  • 30
  • 39