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

Fix 'Missing class properties transform' error when parsing class properties with Typescript syntax #8007

Merged
merged 5 commits into from
Jun 12, 2018

Conversation

@babel-bot
Copy link
Collaborator

babel-bot commented May 22, 2018

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8353/

@loganfsmyth
Copy link
Member

The way to fix this in line with the Flow strip plugin would be for the Typescript plugin to remove the class properties in the Class visitor. That's how we handle this edge case for Flowtype:

// We do this here instead of in a `ClassProperty` visitor because the class transform
so all the logic in should also be run for all properties inside

@pterolex
Copy link
Contributor Author

pterolex commented May 23, 2018

@loganfsmyth Thanks, I've changed the implementation as you suggested.

Now, there's is another issue: the babel-plugin-proposal-class-properties tests broke.
For example, according to the test, the following code

class C {
    x: T;
    y = 0;
    constructor(T) {}
}

should be transpiled to

class C {
  constructor(T) {
    this.x = void 0;
    this.y = 0;
  }

}

So, the x class property is initialized with undefined, but my change removes the x entirely.

What should be the correct behavior in this case?

P.S. The CI process has hung, so these particular tests are not shown

@pterolex pterolex changed the title Fix 'Missing class properties transform' error when parsing class properties with Typescript syntax WIP: Fix 'Missing class properties transform' error when parsing class properties with Typescript syntax May 25, 2018
@pterolex pterolex changed the title WIP: Fix 'Missing class properties transform' error when parsing class properties with Typescript syntax Fix 'Missing class properties transform' error when parsing class properties with Typescript syntax May 26, 2018
@pterolex
Copy link
Contributor Author

pterolex commented Jun 11, 2018

@hzoo hzoo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Jun 12, 2018
@hzoo hzoo merged commit 0b25e33 into babel:master Jun 12, 2018
@hzoo
Copy link
Member

hzoo commented Jun 12, 2018

Thanks for the PR!

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants