Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React component spread props in version v2.3.2 not compile children module right. #15896

Closed
myxvisual opened this issue May 17, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@myxvisual
Copy link

TypeScript Version: 2.3.2

Code

import * as React from "react";

import A from "./A";

export default class Test extends React.PureComponent<any, void> {
  render() {
    const { a, ...b } = this.props;
    return (
      <div {...b}>
        <A />
        <div>Test</div>
      </div>
    );
  }
}

in version 2.3.2, compile the finished code is wrong:

"use strict";
// var __extends = (this && this.__extends) || function (d, b) {...
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var Test = (function (_super) {
    __extends(Test, _super);
    function Test() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Test.prototype.render = function () {
        var _a = this.props, a = _a.a, b = __rest(_a, ["a"]);
        return (React.createElement("div", __assign({}, b),
            React.createElement(A_1.default, null),
            React.createElement("div", null, "Test")));
    };
    return Test;
}(React.PureComponent));
exports.default = Test;

A module is not compiled.
in version 2.1.6,compile the finished code is right:

"use strict";
// var __extends = (this && this.__extends) || function (d, b) {...
var React = require("react");
var A_1 = require("./A");
var Test = (function (_super) {
    __extends(Test, _super);
    function Test() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Test.prototype.render = function () {
        var _a = this.props, a = _a.a, b = __rest(_a, ["a"]);
        return (React.createElement("div", __assign({}, b),
            React.createElement(A_1.default, null),
            React.createElement("div", null, "Test")));
    };
    return Test;
}(React.PureComponent));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Test;

Test Source Code

OS: win10 build 1703
nodeJS: v6.10.3

@mhegazy
Copy link
Contributor

mhegazy commented May 17, 2017

Duplicate of #15469. should be fixed in TS 2.3 (out later this week). the fix should already be in typescript@next please give it a try and let us know if you still running into issues.

@mhegazy mhegazy added the Duplicate An existing issue was already created label May 17, 2017
@mhegazy mhegazy closed this as completed May 17, 2017
@myxvisual
Copy link
Author

@mhegazy thanks~

@myxvisual
Copy link
Author

@mhegazy I tried the next version and it worked fine.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants