Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript Object destructuring results in "Property assignment expected."

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?

like image 810
Rick Avatar asked Jan 19 '16 15:01

Rick


1 Answers

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

like image 140
MinusFour Avatar answered Oct 19 '22 12:10

MinusFour