11

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?

2
  • 2
    shouldn't it be var { auth } = this.props;? Commented Jan 19, 2016 at 15:22
  • 1
    Isn't this ES7 syntax? Commented Jan 19, 2016 at 15:27

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.