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

Return type is lost in transform-classes #4665

Closed
arv opened this issue Oct 4, 2016 · 5 comments
Closed

Return type is lost in transform-classes #4665

arv opened this issue Oct 4, 2016 · 5 comments
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@arv
Copy link
Contributor

arv commented Oct 4, 2016

Input Code

// @flow
class C {
  m(x: number): string {
    return 'a';
  }
}

Output Code

...
// @flow

var C = function () {
  function C() {
    (0, _classCallCheck3.default)(this, C);
  }

  (0, _createClass3.default)(C, [{
    key: 'm',
    value: function m(x: number) {  // <---
      return 'a';
    }
  }]);
  return C;
}();

Expected Behavior

I expect the return type to be kept on the function expression.

Current Behavior

Type annotation is removed.

software version
Babel 6.14.0 (babel-core 6.14.0)
node v6.6.0
npm 3.9.2
Operating System OS X
@hzoo hzoo added the i: bug label Oct 4, 2016
@hzoo
Copy link
Member

hzoo commented Oct 4, 2016

Hmm we need to check if its just not printing it out (babel-generator) or the transform is dropping it for some reason (transform-class)

Also whats the reason for not striping the flow types in the same config?

@arv
Copy link
Contributor Author

arv commented Oct 4, 2016

I found it when trying out transform-flow-comments so I'm pretty sure it is not just the printer.

@hzoo
Copy link
Member

hzoo commented Oct 4, 2016

Oh this is with flow-comments only? There are some issues with it because of the transforms - there was an old issue https://github.com/babel-plugins/babel-plugin-flow-comments/issues/17 and pr (https://github.com/babel-plugins/babel-plugin-flow-comments/pull/18) about this.

What about https://babeljs.io/docs/plugins/transform-flow-strip-types/?

@arv arv changed the title Retrun type is lost in transform-classes Return type is lost in transform-classes Oct 4, 2016
@hzoo
Copy link
Member

hzoo commented Oct 4, 2016

awesome @danharper made a fix #4668. so fast

@arv
Copy link
Contributor Author

arv commented Oct 4, 2016

@hzoo No, this is not related to transform-flow-comments.

transform-flow-strip-types removes the types so that is not related. I want to keep the types.

@hzoo hzoo closed this as completed in 7f772e9 Oct 4, 2016
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 6, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

2 participants