Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

i found if we are using rest props of es6 spread operator it will broken in below behaivor? #64

Closed
tianyingchun opened this issue May 22, 2017 · 3 comments

Comments

@tianyingchun
Copy link

import * as React from 'react';
import Demo2 from './Demo2';

export default class XX extends React.Component<any, any> {

  render() {
    // console.log(Demo2);
    const { children, ...restProps } = this.props;
    // const x= {};
    console.log(restProps);
    return (
      <div>demo1 {this.props.name}
        <div {...restProps}>
          <Demo2></Demo2>
        </div>
      </div>
    )
  }
}

if we use above code block the vs.code will give me the Demo2 is declared but not used, while build process, it will lose is undefined.

if we change {...restProps} to {...x} it works fine. why?

@AJamesPhillips
Copy link
Contributor

That doesn't make any sense, are you sure? If it works with one unused variable it should work with another.

@DanielRosenwasser
Copy link

This is part of microsoft/TypeScript#15469 and is fixed in TypeScript 2.3.

@wmonk
Copy link
Owner

wmonk commented May 25, 2017

@tianyingchun please update to latest version of react scripts:

npm install --save react-scripts@latest

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants